Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
757 B
2
Indexable
Never
$computer = "computername"
$user = (Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer).UserName.split('\')[-1]
$sid = (Get-ADUser $user).SID.Value
Invoke-Command -ComputerName $computer -ScriptBlock {
    Set-Location Registry::HKEY_USERS
    New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS
    Set-Location HKU:
    $drives = Get-ChildItem -Path Microsoft.PowerShell.Core\Registry::HKEY_USERS\$($args[0])\Network -Recurse
    $driveresults = foreach ($d in $drives) {
        $q = "Microsoft.PowerShell.Core\Registry::HKEY_USERS\$($args[0])\Network\" + $d.PSChildName
        Get-ItemProperty -Path $q
    }
    $driveresults | Format-Table PSChildName, RemotePath -AutoSize -HideTableHeaders
} -ArgumentList $sid
Leave a Comment