📌  相关文章
📜  windows 执行 powershell 脚本定义用户 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:51:39.395000             🧑  作者: Mango

代码示例1
$username = "DOMAIN\User"
$password = "Password"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
Invoke-Command -FilePath "C:\Script\To\Execute.ps1" -Credential $cred -Computer localhost