how to use if condition in server 2008R2 in powershell?


hi, 

i running  the below script in powershell in server 2008 r2 datacenter .but not displaying output. can me in this.

$version=(get-wmiobject win32_operatingsystem).caption

 if($version -eq 'microsoft windows server 2008 r2 datacenter') {
    echo '2008 r2'
        }

in above code should display "2008 r2 " running script in server 2008r2 data center. nothing displayed

thanks

ravitej


thanks ravitej reddy

i think may need trim - 


$version=(get-wmiobject win32_operatingsystem).caption   if($version.trim() -eq 'microsoft windows server 2008 r2 datacenter') {     echo '2008 r2'         }



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...