【发布时间】:2014-04-03 12:03:05
【问题描述】:
我在 C:\setup 中有两个脚本:script.ps1 和 script1.ps1。
我希望能够以另一个用户身份并以提升的权限从 withing script.ps1 运行 script1.ps1,但我无法使其工作。新的 powershell 窗口打开但立即关闭...
这是脚本:
$cspath = $MyInvocation.MyCommand.Path
$sfolder = Split-Path $cspath
$spath = Join-Path $sfolder "\Script1.ps1"
$sa = "domain\user"
$sap = "userpassword"
$sasp = ConvertTo-SecureString -String $sap -AsPlainText -Force
$sac = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $sa, $sasp
Start-Process $PSHOME\powershell.exe `
-Credential $sac `
-ArgumentList "-Command Start-Process $PSHOME\powershell.exe -ArgumentList `"'$spath'`" -Verb Runas" -Wait
任何帮助将不胜感激...
【问题讨论】:
-
您通过
Start-Process调用的脚本有什么作用?
标签: powershell powershell-2.0 powershell-3.0