Output format has brackets
hi folks,
after having looks through forums answer on query , observing level of complexity in of discussions i'm embarrassed ask this.
i writing script use detection method in config mgr 2012. detect if win7 sp1 installation has completed.
$sp1 = "6.1.7601" $spinstalled = get-wmiobject win32_operatingsystem | select version if (compare-object $spinstalled $sp1) { write-host $sp1 "and" $spinstalled "are different" } else { write-host $sp1 " , " $spinstalled " equal" } return 6.1.7601 , @{version=6.1.7601} differenti long time vbscripter know possible manipulate output of wmi query regular expressions , remove unwanted text @{version= }
however, have no doubt there built in powershell function return value of version attribute. what's best way this?
thanks,
mic
you can use expand property -
$sp1 = "6.1.7601" $spinstalled = get-wmiobject win32_operatingsystem | select -expandproperty version if (compare-object $spinstalled $sp1) { write-host $sp1 "and" $spinstalled "are different" } else { write-host $sp1 " , " $spinstalled " equal" } or grab version value
$sp1 = "6.1.7601" $spinstalled = get-wmiobject win32_operatingsystem | select version if (compare-object $spinstalled $sp1) { write-host $sp1 "and" $spinstalled.version "are different" } else { write-host $sp1 " , " $spinstalled.version " equal" }
Windows Server > Windows PowerShell
Comments
Post a Comment