could not find a part c:\scipts\control.csv

I wrote this script below to get applications that is install on remote desktops, I got admin rights to run it on remote desktops, I am getting the following error ‘c:\scipts\control.csv’

Foreach ($computer in (“GC C:\Scripts\computer.txt”)){
Invoke-command -computerName “$computer” -ScriptBlock {
Get-ItemProperty “HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall*” | Select-Object DispalyName,`
DisplayVersion, Publisher, @{Name=“Installdate”; Expression={([DateTime]::ParseExact($_InstallDate, ‘yyyymmdd’, $null)).toshortdatestring()}}
_ Export-csv -path c:\scipts\control.csv
}
}

Winston, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

When you post code or error messages or sample data or console output format it as code, please.
In the “Text” view you can use the code tags “PRE”, in the “Visual” view you can use the format template “Preformatted”. You can go back edit your post and fix the formatting - you don’t have to create a new one.
Thanks in advance.

You should collect the result of the loop in a variable and export this to your local CSV file …

$Result = foreach ($computer in (Get-Content -Path C:\Scripts\computer.txt)) {
    Invoke-command -computerName $computer -ScriptBlock {
        Get-ItemProperty 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | 
            Select-Object -Property DispalyName, DisplayVersion, Publisher, 
                @{Name = 'Installdate'; Expression = { ([DateTime]::ParseExact($_.InstallDate, 'yyyyMMdd', $null)).toshortdatestring() } },
                @{Name = 'Computername';Expression = {$computer}}
    }
}

$Result  | Export-csv -path c:\scipts\control.csv

I wrote a function to get software listings from local and remote systems. What I found was that you also need to get listings from both registry hives and remove duplicates to get the most accurate listing. At least that is what I did. I started out using WMI Win32_Product but found out not only does it take forever, it causes a re-validation of the software component which creates tons of banter in the event logs.

‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall’
‘SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall’

Then, I ran into issues where null/blank entries would cause an unrecoverable error that I was never able to solve (even with try/catch) and moved to [Microsoft.Win32.Registry]::OpenBaseKey(‘LocalMachine’, ‘Default’) and [Microsoft.Win32.Registry]::OpenRemoteBaseKey(‘LocalMachine’, $hostTocheck) for remote systems.

You also need to watch for DisplayName being null.

Here’s a function I wrote some time ago. I used it as part of a script to automate removal of a program. I had some weird issue with 2 PCs that after reboot the get-service would fail the first attempt no matter how long I waited but would work second time so there is a retry. It also will try to start remote registry if needed and then set it back to the state/startuptype it was. It seemed sufficient and reliable.

Thanks guys, will try it tomorrow when go to work