I have this code:
$pc=Read-Host"Enter machine name"
$software=Read-Host"Enter software to search for"
$software
Invoke-Command-ComputerName$pc-ScriptBlock {
Get-ChildItem-Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName-like"*$software*" } | Select-Object DisplayName, DisplayVersion, UninstallString
Write-host"your software is $software"
}
When I run this $software has my value before the loop. But $software will be blank in the Write-host line. Why, how come it gets wiped out?