I sign my Dlls with SNK-Files. This is done without problems through the visual studio build.
Now i want to validate the DLLs that I really gave them a strong name. I found this powershell script, but I think powershell hates my path.
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
}
And my error is
In Line:1 Character:19
- C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 ...
- ~~~
- CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
I translated more error information.
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.
Do I have to escape the x86? And if yes - How can i do it? I tried this.
I tried this with allways the same result.
$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"
Powershell Version
Major: 5
Minor: 1
Build: 14393
Revision: 103
EDIT
I fixed my snPath
I gave more examples
more error Information
instead of
$expression = $snPath + ' -vf "' + $item.FullName +'"'
$verify = Invoke-Expression $expression
you could do it like that:
$verify = & $snPath -vf $item.FullName