我有一个带有php 5.6的IIS。
我正在编写一个PHP脚本,它应该执行一个PowerShell脚本。
powershell脚本必须切换到另一个用户,因为IUSR用户没有powershell中所需命令的权限。
来源:
PowerShell的PHP调用:
$content = shell_exec("powershell.exe -NonInteractive -command " . getcwd() . "\\ps-helper.ps1 -ps_password '".$powershell_password."' < NUL");
由于(据我所知)无法在脚本中切换用户,我将它们分成两个文件。 ps-helper.ps1应该使用不同的凭据启动第二个脚本:
PS-helper.ps1:
$psuser_secpassword = ConvertTo-SecureString $ps_password -AsPlainText -Force
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.CreateNoWindow = $true
$psi.FileName = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$psi.Arguments = "/?"
$psi.UseShellExecute = $false;
$psi.RedirectStandardInput = $true;
$psi.RedirectStandardError = $true;
$psi.RedirectStandardOutput = $True;
$psi.Username = 'username'
$psi.Domain = 'DOMAIN'
$psi.Password = $psuser_secpassword
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $psi
$p.Start()
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
$p.WaitForExit()
如果我通过Windows中的cmd.exe以普通用户身份执行命令,则可以正常使用。
问题:
Windows,IIS,PHP或PowerShell中是否存在阻止用户从IUSR更改为其他内容的设置?