Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

invoke-command

$
0
0

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?

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles