Scripting Games–making work

I saw this in one of the submissions:

$Properties = @{}
$Properties[‘Computer’] = $SystemInfo.__SERVER
$Properties[‘OperatingSystem’] = “$($OSInfo.Caption) – $($OSInfo.CSDVersion)”
$Properties[‘PhysicalMemory’] = $SystemInfo.TotalPhysicalMemory  

My immediate thought was the entrant likes making work for themselves. The hash table can be created in a much simpler manner

$Properties = @{
Computer = $SystemInfo.__SERVER
OperatingSystem = “$($OSInfo.Caption) – $($OSInfo.CSDVersion)”
PhysicalMemory = $SystemInfo.TotalPhysicalMemory
}

Same result. Less typing and easiert o read when you come back to the script in 6 months time

Advertisements
This entry was posted in Powershell, Scripting Games. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s