Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
Access is denied error while opening com object in Powershell
I am using below code in my powershell
$Clu = New-Object -com "MSCluster.Cluster"
$GroupOwner = $Clu.ResourceGroups.Item($
but while opening the object it is throwing error of access denied , what permissions is required to run the above code other than adding the account to Admin group that is not permitted..
below is the error I am getting
Exception calling "Open" with "1" argument(s): "Access is denied. (Exception fr
om HRESULT: 0x80070005 (E_ACCESSDENIED))"
+ $Clu.Open <<<< ($ClusterName)
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
You cannot call a method on a null-valued expression.
+ $GroupOwner = $Clu.ResourceGroups.Item <<<< ($ClusterName).OwnerNode.N
+ CategoryInfo : InvalidOperation: (Item:String) , RuntimeExcep
+ FullyQualifiedErrorId : InvokeMethodOnNull
Microsoft Server OS
8/22/2022 - Mon
different approach to get cluster owner:
Are you running the Powershell as administrator? Right click on Powershell and click "Run as administrator"..
Thanks , actually there is no issue when I run as admin ,the issue is I am running from an account that is not admin and it is failing with access denied ,even the querying the wmi (get-wmi) , I am looking what minimum permission I can give to that domain account to get it working..
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
I was talking about running PowerShell console with "Run as administrator"
Following article may help if you are trying to access WMI with a non admin account..
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent