bibi92
asked on
how can I test get-wmiobject
Hello,
How can I modify this code for testing a wmi query without having the following error :
Get-WmiObject : Invalid namespace
At line:3 char:23
+ $cluster=get-wmiobject <<<< -class "MSCluster_Cluster" -namespace "root\mscluster" -computername "$mach_name" | select -ExpandProperty Name
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException, Microsoft. PowerShell .Commands. GetWmiObje ctCommand
The query :
bibi
How can I modify this code for testing a wmi query without having the following error :
Get-WmiObject : Invalid namespace
At line:3 char:23
+ $cluster=get-wmiobject <<<< -class "MSCluster_Cluster" -namespace "root\mscluster" -computername "$mach_name" | select -ExpandProperty Name
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,
The query :
try
{
$cluster=get-wmiobject -class "MSCluster_Cluster" -namespace "root\mscluster" -computername "$mach_name" | select -ExpandProperty Name
}
catch [Exception]
{
echo "$cluster" | out-file $LOG_FILE -ErrorVariable ERR1 -encoding "default" -append -ErrorAction silentlycontinue
}
Thanksbibi
P.S.
If this is in a windows server 2008 R2 environment, use directly the Powershell cluster cmdletts
http://blogs.msdn.com/b/clustering/archive/2009/05/21/9633316.aspx
If this is in a windows server 2008 R2 environment, use directly the Powershell cluster cmdletts
http://blogs.msdn.com/b/clustering/archive/2009/05/21/9633316.aspx
ASKER
This script can be execute on windows server 2008 R2 or 2003.
Same error with -namespace "root\cluster" .
Thanks
Regards
bibi
Same error with -namespace "root\cluster" .
Thanks
Regards
bibi
On a server that is part of a cluster can you run the following in powershell?
get-wmiobject -class "MSCluster_Cluster" -namespace "root\cluster"
get-wmiobject -class "MSCluster_Cluster" -namespace "root\cluster"
ASKER
Already done, I want to test if the server is a clustered or not. If I execute the script and the server is not a cluster, the error occurs :
Get-WmiObject : Invalid namespace
At line:3 char:23
+ $cluster=get-wmiobject <<<< -class "MSCluster_Cluster" -namespace "root\mscluster" -computername "$mach_name" | select -ExpandProperty Name
Thanks
Get-WmiObject : Invalid namespace
At line:3 char:23
+ $cluster=get-wmiobject <<<< -class "MSCluster_Cluster" -namespace "root\mscluster" -computername "$mach_name" | select -ExpandProperty Name
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks regards bibi
-namespace "root\cluster"