Reputation:
When debugging, $var
is not equivalent to "folder\that\isNot\equivalent\".
I have tried changing it to an equivalency statement, but it is not working. Any insight would be appreciated.
Here is all the relevant code:
$process = "Explorer++.exe"
$var = Get-WmiObject Win32_Process -Filter "name = '$process'" | select -expandproperty CommandLine
$var = $var -split '\\\\' | select -Last 1
Write-Host $var
if ($var -ne "folder\that\isNot\equivalent\")
{
Stop-Process -processname explorer++
Stop-Process -processname curProc
}
else
{
return $true
}
Upvotes: 0
Views: 71
Reputation:
The issue was whitespace surrounding the $var. I used the command $var = $var -replace "\s",""
That replaces every space symbol with an empty string, I also changed it to an equivalency statement.
if ($var -eq "\folder\that\is\")
Upvotes: 1