I have a file with two workstations I want to pull a software list from. This list will grow to about 20 or 30 soon. I wrote this little simple script but can’t get it to work. Can someone please point me in the right direction? It seems like it should work but doesn’t. I can write-output and show the variable is correct and I can use any of the computer names in the file by themselves in the invoke-command statement and it works fine. Any advice is appreciated.
$computers=Get-Content C:\temp\UDDElist.txt
Foreach ($computer in $computers) {Invoke-command -cn $computer -ScriptBlock { Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\uninstall* |
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table -AutoSize > c:\temp"$computer"Software_list.txt }}
Invoke-command : One or more computer names are not valid. If you are trying to pass a URI, use the -ConnectionUri
parameter, or pass URI objects instead of strings.
At C:\Users\xxx.xxxx.wa\documents\Windows powershell\software.ps1:3 char:37
- … computers) {Invoke-command -cn $computer -ScriptBlock { Get-ItemPrope …
-
- CategoryInfo : InvalidArgument: (System.String:String) [Invoke-Command], ArgumentException
- FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.InvokeCommandCommand