使用不同的凭据运行powershell脚本

use*_*585 3 powershell scripting

我试图运行一个powershell脚本作为没有"脚本运行"权限的特定用户登录.如果我想以不同的用户身份运行脚本,是否可以将凭据作为参数添加到脚本中?

./Get-Something-computerName SERVER1 -filePath C:\ Whatever -credentials ??

提前干杯!(Powershell noob)

Nai*_*gel 6

Invoke-Command -FilePath "yourPath\yourScript.ps1" -ComputerName yourServer -Credential Get-Credential
Run Code Online (Sandbox Code Playgroud)