functionGet-Software
{
param
( [string]
$DisplayName='*',
[string]
$ComputerName='',
[string]
$UninstallString='*'
)
$keys='HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
Get-ItemProperty-Path$keys |
Where-Object { $_.DisplayName } |
Select-Object-Property DisplayName, DisplayVersion, UninstallString | Format-Table-AutoSize
Where-Object { $_.DisplayName-like$DisplayName } |
Where-Object { $_.UninstallString-like$UninstallString }
}
Get-Software-ComputerName'RemotePC'
The above function works when I run it without the -computername parameter, it gets all of my locally installed software. When I try to use the -computername it still returns the software from my local computer. I have confirmed that the target machine I use in -computername 'remotepc' is online, I can Invoke-Commands on it and I have rights.
Why won't this run on a remote machine?