0

I'm trying to find the printer ports that are in use for the user that is logged in to multiple machines. However, when I run my script it is running Regedit as myself... How do I go about getting it for the user that is logged in?

Here is my current script:

Get-Content -Path c:\ListOfComputers.txt | ForEach-Object {
Get-ItemProperty -Path Registry::"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts\" | ForEach-Object {Get-ItemProperty $_.pspath} | Format-List | Out-file c:\PortResults.txt
} 
Shane Johnson
  • 157
  • 6
  • 15
  • Possible duplicate of [Check if a Registry Path Exists in Remote Machine](http://stackoverflow.com/questions/10275133/check-if-a-registry-path-exists-in-remote-machine) – user4317867 Jun 10 '16 at 22:26
  • Not really the same thing. I'm only able to pull local data, but if I use a remote IP address it gives an error – Shane Johnson Jun 10 '16 at 22:34
  • You can't directly query HKCU on a remote machine. You can only access the hive if you find the user's SID, and access it in the HKEY_USERS key. – TheMadTechnician Jun 11 '16 at 00:16
  • That is what I figured. I found this: http://powershell.com/cs/media/p/16643.aspx but it doesn't seem to work correctly... – Shane Johnson Jun 13 '16 at 15:29
  • I created a new Question here: [Link](http://stackoverflow.com/questions/37793956/how-to-use-powershell-to-find-information-for-current-users-network-printers). – Shane Johnson Jun 13 '16 at 15:43

0 Answers0