最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

I can not run php shell_exec with powershell 7.4 - Stack Overflow

programmeradmin0浏览0评论

I have a powershell script that would output system variable values:

env_output.ps1

$Env:UserDomain
$Env:ComputerName
$Env:UserName

I can get an output when I use this php function to call powershell v5 file

$output_switch = shell_exec('powershell.exe -File C:\inetpub\env_output.ps1');
print_r ($output_switch);

But when I switch to to use powershell v7.4, I got no output.

$output_switch = shell_exec('pwsh.exe -File C:\inetpub\env_output.ps1');
print_r ($output_switch);

Windows 2019 Server with IIS and PHP.

Both powershell executables are in the system path variable.

发布评论

评论列表(0)

  1. 暂无评论