Invoke-Command in PowerShell script without password

sometimes you need to write a script to run commands on remote servers or computers and you need to use the “Invoke-Command” method but you do not want to keep the password in clear text inside of your ps1 file.

for that you can use the “-Authentication NegotiateWithImplicitCredential” flag and just use the current logged on user’s credentials, furthermore if you run this script using scheduled task the Invoke-Command will use the user that was configured as the “run as” user in task scheduler and you will be able to have the script running with administrator credentials without keeping the password in clear text in all of your ps1 files.

full command for example:


This entry was posted in PowerShell. Bookmark the permalink.

Leave a Reply