troubleshooting Question

Access is denied error while opening com object in Powershell

Avatar of sacgar
sacgar asked on
Microsoft Server OSPowershellIT Administration
5 Comments1 Solution1215 ViewsLast Modified:
I am using below code in my powershell

$Clu = New-Object -com "MSCluster.Cluster"
$ClusterName="xx"
$Clu.Open($ClusterName)
$GroupOwner = $Clu.ResourceGroups.Item($ClusterName).OwnerNode.Name
$Servername=Hostname

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))"
At E:\do_not_delete\Script\Main_Task.ps1:3 char:10
+ $Clu.Open <<<< ($ClusterName)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation

You cannot call a method on a null-valued expression.
At E:\do_not_delete\Script\Main_Task.ps1:4 char:39
+ $GroupOwner = $Clu.ResourceGroups.Item <<<< ($ClusterName).OwnerNode.Name
    + CategoryInfo          : InvalidOperation: (Item:String) [], RuntimeExcep
   tion
    + FullyQualifiedErrorId : InvokeMethodOnNull




Thanks
ASKER CERTIFIED SOLUTION
sacgar

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros