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

**URL:** <https://forums.powershell.org/t/could-not-find-a-part-c-scipts-control-csv/14346>\
**Category:** PowerShell Help\
**Created:** [May 7, 2020, 4:09pm UTC](https://forums.powershell.org/t/could-not-find-a-part-c-scipts-control-csv/14346 "2020-05-07T16:09:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashtonnew](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@ashtonnew](https://forums.powershell.org/u/ashtonnew)\
**Post date:** [May 7, 2020, 4:09pm UTC](https://forums.powershell.org/t/could-not-find-a-part-c-scipts-control-csv/14346/1 "2020-05-07T16:09:07Z")

</div>

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  
}  
}

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 7, 2020, 4:23pm UTC](https://forums.powershell.org/t/could-not-find-a-part-c-scipts-control-csv/14346/2 "2020-05-07T16:23:30Z")

</div>

Winston, welcome to [Powershell.org](http://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!](https://powershell.org/forums/topic/read-me-before-posting-youll-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
```

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [May 7, 2020, 5:51pm UTC](https://forums.powershell.org/t/could-not-find-a-part-c-scipts-control-csv/14346/3 "2020-05-07T17:51:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [May 7, 2020, 6:17pm UTC](https://forums.powershell.org/t/could-not-find-a-part-c-scipts-control-csv/14346/4 "2020-05-07T18:17:40Z")

</div>

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.

> <https://gist.github.com/krzydoug/547bb2ea16986587f10a0497781644da>

---

<div class="post-metadata">

**Author:** ![ashtonnew](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@ashtonnew](https://forums.powershell.org/u/ashtonnew)\
**Post date:** [May 10, 2020, 9:19pm UTC](https://forums.powershell.org/t/could-not-find-a-part-c-scipts-control-csv/14346/5 "2020-05-10T21:19:10Z")

</div>

Thanks guys, will try it tomorrow when go to work

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:30pm UTC](https://forums.powershell.org/t/could-not-find-a-part-c-scipts-control-csv/14346/6 "2024-05-16T20:30:08Z")

</div>


