PowerShell for Windows Admins:

May, 2013


May 7, 2013  3:21 PM

Scripting Games–new Get-ChildItem parameters

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

One improvement that came with PowerShell v3 is the –File and –Directory parameters on Get-ChildItem If I run this Get-ChildItem -Path c:\mydata I will get a mixture of directories and files Mode LastWriteTime Length Name ---- ------------- ...

May 7, 2013  3:00 PM

Scripting Games-don’t repeat the work

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

There are some good features to this script but what really hurts is the two trips to the server for the Win32_Computersystem class Foreach ($IP in (Get-Content "C:\IPList.txt")) { $Name = (Get-WMIObject Win32_ComputerSystem -ComputerName $ip).Name $Mem = [math]::truncate((Get-WMIObject...


May 7, 2013  2:15 PM

Scripting Games–how not to output data

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I haven’t finished blogging about event 1 yet but this caught my eye. Things aren’t too bad until we hit the bunch of write-host calls $wrks = (Get-Content -path C:\IPList.txt) foreach ($wrk in $wrks) { $osver = Get-WMIObject -class win32_operatingsystem -ComputerName $wrk ...


May 6, 2013  11:53 AM

Scripting Games: event 1–use of robocopy

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The object of the exercise in both the beginners and advanced sections of event 1 was to move a set of log files older than a give data to an archive folder. A number of solutions were presented that used robocopy. This is a workable solution that meets the lettter of the objective but it...


May 6, 2013  9:27 AM

Scripting Games–major dislike #2

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I’ve already blogged about incorrect use of backticks. Here is another example of un-necessary use of backticks $Files= Get-ChildItem ` -Path $Path ` -include $Type ` -Recurse ` -File | Where-Object {$_.LastWriteTime -lt...


May 6, 2013  7:53 AM

Scripting games-major dislike

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

One of the things we were asked to blog about as Scripting Games judges was things we liked and disliked. This code is a major dislike Get-ChildItem $sourceDirectory | ? {$_.PsISContainer } | % { $subDirectory = $_ ; Get-ChildItem ("$sourceDirectory\$subDirectory") -Include *.LOG -Recurse...


May 6, 2013  4:20 AM

Scripting Games–integer parameters

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I keep seeing parameter constructs like this: [int]$age = '90' Why set the parameter to an integer and then set the default as a string. PowerShell will convert but it just doesn’t make sense. All you need is [int]$age = 90


May 5, 2013  4:30 PM

Scripting games–using parameters

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I am seeing an incredible number of scripts that have this sort of coding round parameters # Input from the user [Parameter(Mandatory=$false, ValueFromPipeline=$False, Position=0)] [ValidateScript({Test-Path $_ })] [String]$SourcePath =...


May 5, 2013  5:13 AM

Scripting Games–observation

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I don’t have the numbers to back this up but my feeling is that the Scripting Community is marking the entries for this years Games in a harsher manner than the judges did over the last few games. What will be very interesting is the level, type and usefulness of the comments that come...


May 1, 2013  3:26 PM

Scripting Games–a word of advice for competitors

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

At the moment it isn’t necessary to run your script to give a vote. Probably the quickest way to lose points is have an obvious and glaring error in your script such as . . . | where {$_.LastWriteTime –lt (date).ADDdays(-90)} | . . . or . . . | where {$_.LastWriteTime –lt...


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: