I am trying to create an exportable report of software installed on systems, either servers or pc’s via the registry with the following line of commands and I am not sure where I am failing. I have researched online, and through forums and from what I’ve read it should be working. Any guidance would be appreciated. Thank you.
“invoke-command -scriptblock {Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate} -ComputerName (Get-content test1.txt) | export-csv software.csv” - is what I am using and below is the error I get.
Invoke-Command : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Provide an argument that is not null or empty, and then try the
command again.
At line:1 char:202
Hi,
Try putting the full path to test1.txt . I tested your code and noticed that since full paths aren’t used the script pulls from /writes to the directory the ISE is pointed at currently.
Hello. Thank you very much for your reply. I have made the change to the line and it is still generating the same error. The test1.txt file does contain valid computer names pulled from AD. If I replace the (get-content h:\test1.txt) with a single computer name without brackets it does work.
PS H:> invoke-command -scriptblock {Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate} -ComputerName (Get-content H:\test1.txt) | Export-Csv software.csv
Invoke-Command : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Provide an argument that is not null or empty, and then try the
command again.
At line:1 char:202
You probably have blank lines in your text file (possibly just one blank line at the end). This is a common problem, but it’s easy to filter out the blanks:
HI Dave. Thank you very much for the help! You were right, there was a blank space at the end of the list. I thought I had removed them all, apologies. I have not yet tried your suggestion for filtering out the spaces but I’m eager to try it out and see the results. Thank you again.