1 year ago

#356856

test-img

Alex

Multiple credentials prompts when remoting on server/Powershell

When logging on windows server to check uptime and services, I am being logged through gateway, both server and gateway are require different credentials.

I am working on powershell script that does this automatically, but I can not find way how to use multiple credentials when invoking command.

I am not sure if there is solution on this in powershell

When doing that manually, I am logging directly on server and gateway automatically pops up, asking for credentials, when I enter them, another prompt to server credentials pops up, then I logon on server.

Thanks for advice :-)

$Cred1 = [pscredential]::new($User1,$Password1) #service account to target server $Cred2 = [pscredential]::new($User2,$Password2) #gateway credentials

Invoke-Command -ComputerName xxx-ScriptBlock { xxx } -credential $Cred1

...is not working with $Cred1, cause gateway requires $cred2.

windows

powershell

powershell-remoting

windows-server

invoke-command

0 Answers

Your Answer

Accepted video resources