WMI IIS 6.0自定义HttpError(Powershell)

时间:2013-01-18 11:52:01

标签: iis powershell wmi

请有人看看这个并告诉我我做错了什么? 我正在尝试使用powershell和wmi修改IIS网站中的自定义错误消息属性...这就是我想出的。

    $Server = "localhost" 
    $Wmi = Get-WmiObject -Class IIsWebServerSetting -Namespace "root\microsoftiisv2" -ComputerName $server -filter "ServerComment = 'SharePoint - SP80'" -Authentication 6
    $CustomHttpError = $wmi | Foreach-Object { $_.HttpErrors | ? {$_.HttpErrorCode -contains "400"} | Select HttpErrorCode, HttpErrorSubcode, HandlerType,HandlerLocation;}
    $CustomHttpError.HandlerLocation('C:\WINDOWS\help\iisHelp\common\Custom.htm')

我收到错误消息“方法调用失败,因为[Selected.System.Management.ManagementBaseObject]不包含名为'HandlerLocation'的方法”

当我使用Get-Member检查$ CustomHttpError时,我得到以下内容。

TypeName:Selected.System.Management.ManagementBaseObject

名称成员类型定义
---- ---------- ----------
Equals方法bool Equals(System.Object obj)
GetHashCode方法int GetHashCode()
GetType方法类型GetType()
ToString方法字符串ToString()
HandlerLocation NoteProperty System.String HandlerLocation = C:\ WINDOWS \ help \ iisHelp \ common \ 400.htm HandlerType NoteProperty System.String HandlerType = FILE
HttpErrorCode NoteProperty System.String HttpErrorCode = 400
HttpErrorSubcode NoteProperty System.String HttpErrorSubcode = *

如果HandlerLocation属性不是我可以调用的方法,我如何修改它?

0 个答案:

没有答案