我打算编写一个简单的别名“iis”来调用 IIS 管理器,即“C:\Windows\System32\inetsrv\InetMgr.exe”
set-alias iis "OpenIIS.ps1"
在 OpenIIS.ps1 我有
$item = "C:\Windows\system32\inetsrv\InetMgr.exe"
invoke-item -path $item
这行不通。我得到的错误是“系统找不到指定的文件”
实际上,仅在 inetsrv 上执行 Get-ChildItem 不会显示 InetMgr.exe(与 -Force 开关没有区别)
Get-ChildItem C:\Windows\system32\inetsrv\*.exe -force
显然我可以在资源管理器中看到它,我可以使用 cmd 启动它,但似乎不能使用 Powershell。此外,Powershell 以管理员身份运行。
到底是怎么回事?
作为一种解决方法,我尝试创建指向该文件的链接,然后从 Powershell 调用该链接。我现在得到一个“未指定”的 Win32Exception。
我最初使用 64 位 Powershell,但在 x86 Powershell 上得到相同的结果(均以管理员身份运行)