Is it possible to hide the PSScriptAnalyzer messeage in Visual studio code "The variable is assigned but never used" ?
I tried with: [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUserDeclaredVarsMoreThanAssignments')]
But then the handle is not cached, and I cant get an exitcode
Code:
$SplatArgs = @{
FilePath = $FilePath
NoNewWindow = $true
Passthru = $true
ErrorAction = "Stop"
}
$Execute = Start-Process @SplatArgs
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUserDeclaredVarsMoreThanAssignments')]
$Handle = $Execute.Handle
$Execute.WaitForExit()
The code is working fine, it's just the error message I want gone, initially I got the idea from :
Obtaining ExitCode using Start-Process and WaitForExit instead of -Wait
How to silence a warning or even better if you know why: is assigned but never