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
}