title: PowershellScript ObjectNotFoundException CommandNotFoundException Path
body: <p>I sign my Dlls with SNK-Files. This is done without problems through the visual studio build.</p>
  
  <p>Now i want to validate the DLLs that I really gave them a strong name. I found <a href="http://practicethis.com/script-validate-assemblys-snk-using-powershell/" rel="nofollow">this powershell script</a>, but I think powershell hates my path.</p>
  
  <pre><code>Clear-Host
  
  $path="C:\Users\MyName\Desktop\BuildOutput\Debug"
  $snPath = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
  
  
  foreach ($item in Get-ChildItem $path -Recurse -Include *.dll, *.exe)
  {
      $reportLine = $item.FullName + "," + $item.Extension
  
  #validate integrity
  $expression = $snPath + ' -vf "' +  $item.FullName +'"'
  $verify = Invoke-Expression $expression
  $isValid = $verify | Select-String -Pattern "is valid"
  
  if($isValid)
  {
      $reportLine = $reportLine + ",ist signiert"
  }
  else
  {
      $reportLine = $reportLine + ",ist nicht signiert"
  }
  
  #extract token
  $expression = $snPath + ' -Tp "' +  $item.FullName +'"'
  $result = Invoke-Expression $expression
  
  $tokenString = $result | Select-String -Pattern "key token is"
  if($tokenString)
  {
      $token = $tokenString.Tostring().Substring(20)
      $reportLine = $reportLine + "," +$token
  }
  
      $reportLine
  } 
  </code></pre>
  
  <p>And my error is</p>
  
  <blockquote>
    <p>In Line:1 Character:19</p>
    
    <ul>
    <li>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1  ...</li>
    <li>~~~
    
    <ul>
    <li>CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException</li>
    <li>FullyQualifiedErrorId : CommandNotFoundException</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <p>I translated more error information.</p>
  
  <blockquote>
    <p>The term "x86" was not recognized as the name of a cmdlet, function, script file, or executable.
    Check the spelling of the name, or if the path is correct (if included), and retry.</p>
  </blockquote>
  
  <p>Do I have to escape the x86? And if yes - How can i do it? I tried <a href="http://www.jonathanmedd.net/2013/03/powershell-quick-tip-accessing-the-programfilesx86-environment-variable.html" rel="nofollow">this</a>.</p>
  
  <p>I tried this with allways the same result.</p>
  
  <pre><code>$snPath = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
  
  $snPath = ${env:CommonProgramFiles(x86)} + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
  
  $snPath =  ${env:ProgramFiles(x86)} + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
  
  $snPath = [Environment]::GetEnvironmentVariable("ProgramFiles(x86)") + + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
  </code></pre>
  
  <p>Powershell Version</p>
  
  <p>Major: 5<br>
  Minor: 1
  Build: 14393
  Revision: 103</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I fixed my snPath</p>
  
  <p>I gave more examples</p>
  
  <p>more error Information</p>