-
I have heard some discussions recently regarding whether Win32_LogicalDisk or Win32_Volume should be used in the answer to event 3 in the Scripting Games. The problem requires you pull the drive letter, drive size and freespace for local disks on the...
-
One of the principles of writing scripts (or any code) is the KISS principle – Keep It Simple Scripter. That principle is being abused al lot in event 3 I am seeing numerous entries that define an advanced function as the solution and then inside the...
-
In event 3 you have to get information on hard disk capacity. I’ve only looked at the first couple of dozen scripts but seen this too many times Get-WmiObject -Class Win32_LogicalDisk | where DriveType -eq 3 or if you prefer the version 2 way Get...
-
I’ve seen a lot of this type of thing in events 1 and 2 $ErrorPref = $ErrorActionPreference $ErrorActionPreference = "Stop" Don’t The default for $ErrorActionPreference is Continue. This means that the error message is shown and...
-
I saw this in one of the submissions: $Properties = @{} $Properties['Computer'] = $SystemInfo.__SERVER $Properties['OperatingSystem'] = "$($OSInfo.Caption) - $($OSInfo.CSDVersion)" $Properties['PhysicalMemory'] = $SystemInfo...
-
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...
-
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...
-
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...
-
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...
-
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...
-
I keep seeing paramter 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 Read More...
-
I am seeing an incredible number of scripts that have this sort of coding round parameters # Input from the user [Parameter(Mandatory=$false, ...
-
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...
-
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 . . Read...
-
I’ve gone through most of the Beginner event submissions over the last couple of days. One thing that has jumped out is the potential misunderstanding around using the –include or –filter parameters on get-childitem. If we look at the...