简体   繁体   中英

Powershell Get-ChildItem doesn't work properly on IIS directory

I was going to write up a simple alias 'iis' to invoke the IIS Manager, which is 'C:\\Windows\\System32\\inetsrv\\InetMgr.exe'

set-alias iis "OpenIIS.ps1"

and in the OpenIIS.ps1 I have

$item = "C:\Windows\system32\inetsrv\InetMgr.exe"
invoke-item -path $item

This doesn't work. The error I get is "The system cannot find the file specified"

In fact, just doing a Get-ChildItem on the inetsrv won't show the InetMgr.exe (no difference with -Force switch)

Get-ChildItem C:\Windows\system32\inetsrv\*.exe -force

伊姆古尔

Obviously I can see it in Explorer and I can launch it using cmd, but not with Powershell it seems. Also, Powershell is running as Administrator.

What is going on?

As a workaround I tried creating a link to the file and then invoking that link from Powershell. I now get a 'NotSpecified' Win32Exception.

I have originally used 64 bit Powershell, but get the same result on the x86 Powershell (both run as Administrator)

Are you at the elevated PowerShell prompt? Some system files may not show up unless you use -Force parameter with Get-ChildItem.

I think evidently the file InetMgr.exe is not there as when I do a get-childitem in the mentioned directory,it lists the "InetMgr.exe" there.

This may not be the problem with Get-ChildItem or the Alias you created but instead with ur IIS Server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM