简体   繁体   中英

Get IIS application pool WMI object for a Non-admin account

I wrote a powershell script to stop and start an IIS application pool on a windows server 2008 machine. IIS version is 7.5

I have administrator privileges on the machine and when I run it the script works fine. But when I trigger the same script with a Non-admin Service account it is failing.

The trigger is from CA Release Automation tool, the agent is configured on the machine with the service account. Following is the command where I am stuck.

gwmi -Namespace root\webAdministration -class ApplicationPool -Authentication PacketPrivacy | Where-Object { $_.Name -eq "siteURL" }

Error:

*****Get-WmiObject : Provider load failure At C:\\Users\\SVC_DEV_APP\\AppData\\Local\\Temp\\tempz_891958570065876740601304.ps1:2 char:5
+ gwmi <<<< -Namespace root\\webAdministration -class ApplicationPool
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand Get-WmiObject : Provider load failure At C:\\Users\\SVC_DEV_APP\\AppData\\Local\\Temp\\tempz_891958570065876740601304.ps1:2 char:5
+ gwmi <<<< -Namespace root\\webAdministration -class ApplicationPool + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand*****

I have tried getting a WMI object for other windows services(Win32_Service) and it works fine. Only for IIS objects it is throwing the error.

I have given the service account, control(Execute methods, Enable Account, Remote enable) over the namespace(in fact Root and its sub namespaces) as suggested in some forums.

I have also added the service account as IIS Manager, but nothing worked out.

I think you are bumping into UAC. UAC unfortunately impacts WMI.

How to address it: https://msdn.microsoft.com/en-us/library/aa826699(v=vs.85).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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