Trond Skille

Results 4 comments of Trond Skille

I tested now again, unable to provoke the error, but still, the code does not run. Import-Module -Name Invoke-CommandAs $Credential = Get-Credential $Server = 'ServerName' Invoke-CommandAs -ComputerName $Server -AsSystem -ArgumentList...

ffs! Thanks a lot ! ;) `Invoke-CommandAs -ComputerName $server -ArgumentList $Credential -ScriptBlock { param($Cred) $Cred.username test-path $env:temp } ` Now returning both the username and True :) Have a nice...

Actually, I tested wrong when I closed the case. I forgot to add the -AsSystem switch. Adding it returns nothing. Invoke-CommandAs -ComputerName $ServerName -ArgumentList $Credential -AsSystem -ScriptBlock { param($Cred) $Cred.username...

I worked around this problem by converting the credential objects to an base64 encoded string and back. ` $Base64Credential = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes((@{ UserName = $Credential.UserName Password = $Credential.GetNetworkCredential().Password } | ConvertTo-Json)))...