Search found 1789 matches

by jhicks
Tue Jul 31, 2012 2:16 am
Forum: Windows PowerShell
Topic: Powershell v3 question
Replies: 3
Views: 1033

Powershell v3 question

What is the error message? I don't have that cmdlet handy but what type of object is the RegisterThisConnectionAddress? Is it a switch? A boolean? That will help figure out the right format. But I know I've seen some cmdlets where you need to do this: -RegisterThisConnectionAddress:False
by jhicks
Mon Jul 30, 2012 3:33 am
Forum: Windows PowerShell
Topic: PowerShell and Date math to exclude Weekends
Replies: 5
Views: 6428

PowerShell and Date math to exclude Weekends

The forum is a fine place for picking my brain as other people might have the same question. Even trying to figure out how to do something or planning a PowerShell script is just as important as the actual mechanics and techniques. As long as it is scripting related it isn't spam. Fire away.
by jhicks
Mon Jul 30, 2012 3:13 am
Forum: Windows PowerShell
Topic: PowerShell and Date math to exclude Weekends
Replies: 5
Views: 6428

PowerShell and Date math to exclude Weekends

See if this code makes sense to you: $start=Get-Date $end=$start.Adddays(14) #define a counter $i=0 #test every date between start and end to see if it is a weekend for ($d=$start;$d -le $end;$d=$d.AddDays(1)){ if ($d.DayOfWeek -notmatch "Sunday|Saturday") { #if the day of the week is not a Saturday...
by jhicks
Wed Jul 11, 2012 11:51 pm
Forum: Windows PowerShell
Topic: Returning numbers to 2 decimal places
Replies: 3
Views: 852

Returning numbers to 2 decimal places

Using -f ends up with a string that happens to look like a number. Using the [math] class gives you a [double] which works better for sorting.
by jhicks
Wed Jun 27, 2012 3:52 am
Forum: Windows PowerShell
Topic: how do i force the second command to execute
Replies: 6
Views: 1265

how do i force the second command to execute

You just want files with SQL somewhere in the name?

dir $env:temp -filter "*sql*"

Want to also search subfolders? Add -recurse to the command.
by jhicks
Wed May 30, 2012 9:12 am
Forum: Windows PowerShell
Topic: How can I make the following script more efficient
Replies: 6
Views: 1997

How can I make the following script more efficient

Sometimes the best approach is no coding at all: 1. get the content of spns.txt 2. Use a regex for each line to get the computername filtering out duplicates with -unique and ping the computer. 3. If it can be pinged, write the corresponding SPN to a new file. Since you are only pinging once, you co...
by jhicks
Tue May 29, 2012 6:19 am
Forum: Windows PowerShell
Topic: Remotely gather registry info
Replies: 1
Views: 582

Remotely gather registry info

If you want to go a little further, take a look at http://jdhitsolutions.com/blog/2011/07/ ... -resource/
by jhicks
Fri May 25, 2012 1:19 am
Forum: Windows PowerShell
Topic: sub-methods of [ADSI] Type Adapter
Replies: 2
Views: 728

sub-methods of [ADSI] Type Adapter

None of this is documented very well and PowerShell's adaptation of ADSI is far from perfect. For example, there is no SetInfo method that you can see but you can call it. You just have to know. Some things like what you have in your example are the sorts of things we have to deal with. All of the A...
by jhicks
Thu May 24, 2012 12:42 am
Forum: Windows PowerShell
Topic: Help with for, foreach
Replies: 7
Views: 1919

Help with for, foreach

It is not clear exactly what you are attempting to achieve, primarily because you are using something that isn't common, like Select-Window. I have no idea what kind of object it is returning. The best I can make out is that each object has a property that will give you the window title and then you...
by jhicks
Wed May 23, 2012 2:24 am
Forum: Windows PowerShell
Topic: output from commandline to table
Replies: 4
Views: 1298

output from commandline to table

I've written a lot about turning CLI tools into PowerShell tools. You might take a look at http://jdhitsolutions.com/blog/2012/01/ ... t-updated/ and http://jdhitsolutions.com/blog/2011/10/ ... 2012-05-23 09:26:23