function GetDefaultPrinter {
param (
[string]$Comp
)
Invoke-Command -ComputerName $Comp -ScriptBlock {
Get-ChildItem Registry::\HKEY_Users |
Where-Object { $_.PSChildName -NotMatch ".DEFAULT|S-1-5-18|S-1-5-19|S-1-5-20|_Classes" } |
Select-Object -ExpandProperty PSChildName |
ForEach-Object { Get-ItemPropertyValue 'Registry::\HKEY_Users\' + $_ + '\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows' 'Device'}
}
}
so the path is: 'Registry::\HKEY_Users' + $_ + '\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows'
if I use: 'Registry::\HKEY_Users\S-1-5-21-166812146-2062891607-924725345-16845\SOFTWARE\Microsoft\Windows'
it works!
Thank you so much!