title: powershell conditional IsNullorEmpty not working as planned
body: <p>I am trying to write a conditional statement in Powershell that tests for the existence of data in a registry value name.  I have declared the following path as a variable.  <code>HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings</code> </p>
  
  <p>I have also used the <strong>Get-ItemProperty cmdlet</strong> to declare a variable for the registry name itself (i.e. <strong>ProxyOverride</strong>).  When I write my conditional statement I am using: </p>
  
  <p><code>[string]::IsNullorEmpty($proxyoverridevariable)</code></p>
  
  <p>When the conditional statement runs it always reports back that the Registry Value ProxyOverride is not Null or Empty even though I know it is. </p>
  
  <p>What I know so far is that, if I delete <strong>ProxyOverride</strong> from the registry, the conditional statement works.  I want it to work if the data field is blank.  </p>
  
  <pre><code>$regKey="HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
  
  $proxyoverride = "localhost;127.0.0.1"
  
  $proxyexception = Get-ItemProperty -path $regKey -name ProxyOverride -ErrorAction SilentlyContinue
  
  if ([string]::IsNullorEmpty($proxyexception)) { Set-ItemProperty -Path $regKey -name ProxyOverride -value $proxyoverride }
  
  else { write-host "Value not empty" }
  </code></pre>
  
  <p>Any suggestions?</p>