要发现特定命名空间中的类,试试这个
PS c:\>Get-WmiObject -List * "root\webadministration"
并找到匹配项
PS c:\>Get-WmiObject -List * "root\webadministration" | Where-Object {$_.name -match "Http"}
PS C:\>Get-WmiObject -Namespace "root\webadministration" -class HttpProtocolSection | Get-Member
TypeName: System.Management.ManagementObject#root\webadministration\HttpProtocolSection
Name MemberType Definition
---- ---------- ----------
PSComputerName AliasProperty PSComputerName = __SERVER
Add Method System.Management.ManagementBaseObject Add(System.String CollectionName, System.Ma...
Clear Method System.Management.ManagementBaseObject Clear(System.String CollectionName)
Get Method System.Management.ManagementBaseObject Get(System.String CollectionName, System.St...
Remove Method System.Management.ManagementBaseObject Remove(System.String CollectionName, System...
RevertToParent Method System.Management.ManagementBaseObject RevertToParent(System.String PropertyName)
AllowKeepAlive Property bool AllowKeepAlive {get;set;}
CustomHeaders Property System.Management.ManagementObject#CustomHeaderSettings CustomHeaders {get;set;}
Location Property string Location {get;set;}
Path Property string Path {get;set;}
RedirectHeaders Property System.Management.ManagementObject#RedirectHeaderSettings RedirectHeaders {get;set;}
SectionInformation Property System.Management.ManagementObject#SectionInformation SectionInformation {get;set;}
__CLASS Property string __CLASS {get;set;}
__DERIVATION Property string[] __DERIVATION {get;set;}
__DYNASTY Property string __DYNASTY {get;set;}
__GENUS Property int __GENUS {get;set;}
__NAMESPACE Property string __NAMESPACE {get;set;}
__PATH Property string __PATH {get;set;}
__PROPERTY_COUNT Property int __PROPERTY_COUNT {get;set;}
__RELPATH Property string __RELPATH {get;set;}
__SERVER Property string __SERVER {get;set;}
__SUPERCLASS Property string __SUPERCLASS {get;set;}
ConvertFromDateTime ScriptMethod System.Object ConvertFromDateTime();
ConvertToDateTime ScriptMethod System.Object ConvertToDateTime();
然后你可以做这样的事情来获取 AllowKeepAlive 的值
PS C:\> (get-wmiobject -namespace "root\webadministration" -class HttpProtocolSection).AllowKeepAlive
True
PS C:\>$a = Get-WmiObject -Namespace "root\webadministration" -class HttpProtocolSection
PS C:\>$a.AllowKeepAlive = $false
PS C:\>$a.Put()