使用不同的凭据运行 powershell 脚本 [英] Run powershell script using different credentials

查看:39
本文介绍了使用不同的凭据运行 powershell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to run a powershell script logged on as a particular user who has no "Script running" permissions. If I wanted to run the script as a different user is it possible to just add the credentials as a parameter to the script?

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

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

提前干杯!(Powershell 菜鸟)

Cheers in advance! (Powershell noob)

推荐答案

Invoke-Command -FilePath "yourPath\yourScript.ps1" -ComputerName yourServer -Credential Get-Credential

这篇关于使用不同的凭据运行 powershell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆