My client controls access to their database with ActiveDirectory. I would like to do the following:
$cred = Get-Credential
Start-Job -Credential $cred {
#do some stuff with the db
}
This works fine for any local user but when on the vpn and entering my ActiveDirectory credentials this fails to authenticate.
I know that I can use runas
to start processes as the ActiveDirectory user only if I provide the /netonly
flag (it does not work otherwise). I thought the following might help
$cred = (Get-Credential).GetNetworkCredential()
but the resulting object is not convertible to PsCredential
, which is what the -Credential
parameter takes.
Related to this question on SO but it seems I might have been asking the wrong thing.