Automating the world one-liner at a time…
< Kapil Mathur is in the process of learning PowerShell to work with WMI and wrote up his findings to date – jps>
Automating admin scenarios using PowerShell
The preferred scripting language for the WMI world has been vbscript. But if you are a windows administrator writing WMI scripts, chances are that you have been hearing another name lately- PowerShell.
To compare the scripting experience in between the two, I tried out my hand at automating some admin scenarios by converting "vbscript" scripts into "PowerShell" scripts.
I took two scripts from Alain Lissoir's book "Leveraging Windows Management Instrumentation (WMI) Scripting" (http://www.lissware.net ) and rewrote them into PowerShell.
The scripts covered the following areas -
So here's my experience with PowerShell vis-à-vis vbscript so far –
$IPAddresses = "18.104.22.168","22.214.171.124"
$IPAddresses = $ IPAddresses + "250.250.250.250"
Or if you want to create a string array of some size and initialize it, you write - [string]$IPAddresses = @("cool")*$ParsedValue.length
In another post, I'll cover the wmi based monitoring story with PowerShell.
1) I fail to see how: "$var2 = [int]var1" is any better (or quicker) than "var2=cint(var1)".
2) String processing: In powershell you do '$value.split(",")' which, to be honest, isn't much of an improvement on 'var2 = Split(var1,",")' that you get is VBScript.
3) My only problem with fomat-list and format-table is that the output of these isn't always as readable as I would like.
ps> 3) My only problem with fomat-list and format-table is that the output of these isn't always as readable as I would like.
Can you give an example and/or offer suggestions of what we should do better?
Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
Last week the powershell team posted some of my thoughts on how well wmi and poeershell work together