Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Getting prompted for credentials for invoke command even though suppressed

$
0
0

Hello Team,

I am attempting to suppress an credential prompt when running the invoke command - but I am still getting prompted even though I shouldn't be. May I borrow your pair of fresh eyes?

Code:

$adminusername = "domain\administrator"
$password= cat c:\mysecurepassword.txt | convertto-securestring
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $adminusername, $password

invoke-command -filepath "c:\mypowershellscript.ps1" -authentication default -credential $cred -computername $env:COMPUTERNAME

FYI - the converted secure password is in the txt file, but I'm still getting prompted for credentials.

Any pointers much appreciated.


Viewing all articles
Browse latest Browse all 21975

Trending Articles