Our datacenter had some power issues and I needed to quickly determine if our SAN had come back online. The quickest way I could come up with was a
gwmi
call to the remote machine. My first effort was on the Win32_LogicalDisk
class:gwmi -class Win32_LogicalDisk -computer 192.168.0.14 | select deviceid,drivetype,status,mediatype,access,volumename | ft -auto
If you are not familiar with this class, check out the definition at MSDN:http://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspxTo get a better idea, as this didn't actually list shares but rather all drives, I used the
Win32_Share
class:gwmi -class win32_share -computer 192.168.0.14 | select name,status
For more information on this class check out this page:http://msdn.microsoft.com/en-us/library/aa394435(v=VS.85).aspxInterestingly enough, I did a
Get-Member
to be sure I was picking all the info I needed. Since we are in a clustered environment, there is actually a Win32_ClusterShare
class that derives from the Win32_Share
class. If you run this command:gwmi -class win32_share -computer 192.168.0.14 | select *you can see all of the main fields
__GENUS
__CLASS
__SUPERCLASS
__DYNASTY
__RELPATH
__PROPERTY_COUNT
__DERIVATION
__SERVER
__NAMESPACE
__PATH
AccessMask
AllowMaximum
Caption
Description
InstallDate
MaximumAllowed
Name
Path
ServerName
Status
Type
Scope
Options
ClassPath
Properties
SystemProperties
Qualifiers
Site
Container
About the Win32_ClusterShare
class:http://support.microsoft.com/kb/971403As noted by Radjin Sardjoe Missier in the
Win32_Share
community content section,Suppose I have a server namedSERVER01
that has a share namedSHARE01
.
To get this share object in powershell use the command:[wmi]file://server01/root/cimv2:Win32_Share.Name='SHARE01'
This will also work for a Windows 2003 cluster whereSERVER01
is the network name for a cluster group.
However, for a Windows 2008 cluster using CAP this will NOT work, because theName
property is now the UNC path to the share.
In such cases use:[wmi]file://server01/root/cimv2:Win32_Share.Name='//SERVER01/SHARE01'
Actually for a cluster server the class name isWin32_ClusterShare
which is a subclass ofWin32_Share
.
0 komentar:
Posting Komentar