waar is de beste plaats om te kopen van voorschrift brillen http://hollandpillen.com/lorazepam/ beste otc koud geneeskunde
Jeff Wouters's Blog

Get-WMIObject says access is denied

by on Jun.26, 2013, under DuPSUG, PowerShell

Did you ever encountered a situation where Get-WMIObject tells you that the access is denied?
The last week I’ve been doing a lot with PowerShell and IIS, where this is not such an uncommon issue 😉
For example:

Get-WmiObject -ComputerName IIS01 -Namespace "root\microsoftiisv2" -Query "select * from IISWebInfo"
Get-WmiObject : Access denied 
At line:1 char:14 
+ Get-WmiObject <<<<  -Namespace 'root\webadministration' -List -ComputerName IIS01
    + CategoryInfo          : NotSpecified: (:) [Get-WmiObject], ManagementException 
    + FullyQualifiedErrorId : System.Management.ManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

The solution is on the Authentication parameter to the Get-WMIObject cmdlet:

Specifies the authentication level to be used with the WMI connection. Valid values are:
-1: Unchanged
0: Default
1: None (No authentication in performed.)
2: Connect (Authentication is performed only when the client establishes a relationship with the application.)
3: Call (Authentication is performed only at the beginning of each call when the application receives the request.)
4: Packet (Authentication is performed on all the data that is received from the client.)
5: PacketIntegrity (All the data that is transferred between the client and the application is authenticated and verified.)
6: PacketPrivacy (The properties of the other authentication levels are used, and all the data is encrypted.)

Now this gives us a bunch of options, but when you use option 6 (PacketPrivacy) it the command will work like a charm:

PS C:\> Get-WmiObject -ComputerName "IIS01" -Namespace "root\microsoftiisv2" -Query "select * from IISWebInfo" -Authentication 6

__GENUS               : 2
__CLASS               : IIsWebInfo
__SUPERCLASS          : CIM_LogicalElement
__DYNASTY             : CIM_ManagedSystemElement
__RELPATH             : IIsWebInfo.Name="W3SVC/INFO"
__DERIVATION          : {CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER              : IIS01
__NAMESPACE           : root\microsoftiisv2
__PATH                : \\IIS01\root\microsoftiisv2:IIsWebInfo.Name="W3SVC
Caption               : 
Description           : 
InstallDate           : 
MajorIIsVersionNumber : 7
MinorIIsVersionNumber : 5
Name                  : W3SVC/INFO
Status                :

Leave a Reply