I am trying to execute a remote invoke-command and retrieve a value from the registry remote machine.
Asumming Winre is configure and running..
$RegSessionPath="HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData"
$RegCredentialProviders
="HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential
Providers"
$result=Invoke-Command-ComputerName xxxxxxx-ScriptBlock
param($Session,$Credential)
$CurrentSessionInfoFromReg=Get-ItemProperty-Path$Session\1 ---- this is where it fails..........
$CurrentProvider=$CurrentSessionInfofromReg.LastLoggedOnProvider
$CurrentLoggedOnUser=$CurrentSessionInfofromReg.LoggedOnSAMUser
$CredentialProvider = Get-ItemProperty -Path $Credential\$CurrentProvider
Get-ItemProperty $CredentialProvider.PSPath | Select @{Name=$CurrentLoggedOnUser;Expression = "(default)"}
}
-ArgumentList$RegSessionPath,$RegCredentialProviders
Write-Host
$result
When I run remotely within my workstations it returns what I am expecting........ but IF I use another workstations I can not access the registry and it returns my user credentials instead of the account in the remote workstation that is login.
what I am doing wrong?