简体   繁体   English

IIS 7.5 powershell模块使用问题

[英]IIS 7.5 powershell module usage issues

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 有没有人设法成功使用这个模块,我正在运行32位Windows 7,我已经使用run as administrator打开了一个管理员shell,我已经导入了WebAdministration模块然后尝试使用这些命令有一些问题,提供了两个这里的例子

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. 然后我尝试使用命令get-website -name testsite获取站点详细信息,但它总是返回所有站点,似乎忽略-name参数。 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 当我使用appcmd时,它使用以下命令按预期工作

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

AppPools AppPools

When i try to list the apppools using the following command 当我尝试使用以下命令列出apppools时

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 然而,当我按如下方式使用appcmd时,我可以按预期获得所有apppool,而不会出现任何错误

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

Has anyone successfully managed to use the WebAdministration module ? 有没有人成功设法使用WebAdministration模块?

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. 如果您已经以管理员身份运行PowerShell并禁用了Windows UAC,并且仍然看到此错误,请确保WAS(Windows进程激活服务)正在运行。 You can stop W3SVC but PowerShell will definitely give the same head-scratching "access denied" error if WAS is stopped. 您可以停止W3SVC,但如果WAS停止,PowerShell肯定会给出同样令人头疼的“拒绝访问”错误。

您需要确保PowerShell窗口正在升级,尝试右键单击“开始”菜单并使用“以管理员身份运行”选项确保其运行提升。

Regarding Get-Website ignoring the -Name parameter, this appears to be a bug according to this forum post . 关于Get-Website忽略-Name参数,这似乎是根据此论坛帖子的错误。 The workaround is to use Get-Item 解决方法是使用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. 关于浏览应用程序池,我怀疑这是一个权限问题,正如CarlosAg所提到的那样。 Make sure that you are running PowerShell with elevated privileges. 确保使用提升的权限运行PowerShell。 I typically launch PowerShell by right-clicking on it and selecting "Run as administrator". 我通常通过右键单击并选择“以管理员身份运行”来启动PowerShell。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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