开发者

IIS 7.5 powershell module usage issues

开发者 https://www.devze.com 2022-12-27 06:30 出处:网络
Has anyone managed to use this module with success, i\'m running 32bit Windows 7, where i have opened an administrator shell using run as administrator, i have imported the WebAdministration module an

Has anyone managed to use this module with success, i'm running 32bit Windows 7, where i have opened an administrator shell using run as administrator, i have imported the WebAdministration module and then attempted to use the commands with some issues, have provided two examples here

Websites

I created a web site with the following command

new-website -name testsite -port 80 -hostheader testsite -physicalpath c:\temp

Then i attempted to get the sites details using the command get-website -name testsite but it always returns all sites, seems to ignore the -name parameter. Only way i can get the site is using a filter

get-website | ? { $_.name -eq 'testsite' } | get-member

When i use appcmd it works as expected using the following command

C:\> C:\Windows\System32\inetsrv\appcmd.exe list site testsite

AppPools

When i try to list the apppools using the following c开发者_如何学Goommand

dir iis:\apppools

i get the following error

Get-ChildItem : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Yet when i use appcmd as follows i get all the apppools as expected without any error

C:\Windows\System32\inetsrv\appcmd.exe list apppool

Has anyone successfully managed to use the WebAdministration module ?

Thanks in advance

Pat


If you are already running PowerShell as an administrator and have Windows UAC disabled and you are still seeing this error, make sure WAS (Windows Process Activation Service) is running. You can stop W3SVC but PowerShell will definitely give the same head-scratching "access denied" error if WAS is stopped.


You need to make sure that the PowerShell window is running elevated, try right-clicking in the Start Menu and using the "Run as administrator" option to ensure it runs elevated.


Regarding Get-Website ignoring the -Name parameter, this appears to be a bug according to this forum post. The workaround is to use Get-Item

$website = "Default Web Site"
Get-Item "IIS:\sites\$website"

Be sure to use double quotes, variables are not expanded when single quotes are used.

Regarding browsing the application pools I suspect this is a permissions issue as CarlosAg mentioned. Make sure that you are running PowerShell with elevated privileges. I typically launch PowerShell by right-clicking on it and selecting "Run as administrator".

0

精彩评论

暂无评论...
验证码 换一张
取 消