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} different

i 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

Popular posts from this blog

DCOM received error "2147746132" from...

DFSR RPC replication errors 5014 1726 with large files over VPN

ADFS 3.0 Event ID 4625 | An Error occurred During Logon | Status: 0xC000035B