Main example
List instances
# All instances of Win32_ClusterShare, with the main properties
Get-CimInstance -ClassName Win32_ClusterShare |
Select-Object -Property Name, Description, Status, Path, InstallDateExamples
Filter with WQL
# WQL filter evaluated by the provider: Type = 0 (Disk Drive)
Get-CimInstance -ClassName Win32_ClusterShare -Filter 'Type = 0' |
Select-Object -Property Name, Description, Status, Path, InstallDateThe filter is evaluated by the WMI provider: less data is transferred than with Where-Object.
Decode numeric values
# Lookup table for Type (values documented by Microsoft)
$typeName = @{
0 = 'Disk Drive'
1 = 'Print Queue'
2 = 'Device'
3 = 'IPC'
2147483648 = 'Disk Drive Admin'
2147483649 = 'Print Queue Admin'
2147483650 = 'Device Admin'
2147483651 = 'IPC Admin'
}
Get-CimInstance -ClassName Win32_ClusterShare |
Select-Object -Property @(
'Name'
'Description'
'Status'
'Path'
'InstallDate'
@{ Name = 'Type'; Expression = { $typeName[[int]$_.Type] } }
)Query a remote computer (CIM session)
review before running# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
Get-CimInstance -CimSession $cimSession -ClassName Win32_ClusterShare |
Select-Object -Property Name, Description, Status, Path, InstallDate
} finally {
Remove-CimSession -CimSession $cimSession
}WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.
Show the class structure
# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_ClusterShare
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, Flags
# Methods of the class
$cimClass.CimClassMethods |
Select-Object -Property Name, ReturnTypeProperties
| Name | Type | Access | Description | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AccessMask# | uint32 | read | This property is obsolete and is no longer used. Use the Win32_Share.GetAccessMask method instead. The value of the AccessMask property is set to null by WMI. For more information about setting access when a share is created, see the Create method. Code | |||||||||||||||||||||||||||||||||||||||
| AllowMaximum# | boolean | read | Number of concurrent users for this resource has been limited. If True, the value in the MaximumAllowed property is ignored. Code | |||||||||||||||||||||||||||||||||||||||
| Caption# | string | read | A short textual description of the object. Code | |||||||||||||||||||||||||||||||||||||||
| Description# | string | read | A textual description of the object. Code | |||||||||||||||||||||||||||||||||||||||
| InstallDate# | datetime | read | Indicates when the object was installed. Lack of a value does not indicate that the object is not installed. Code | |||||||||||||||||||||||||||||||||||||||
| MaximumAllowed# | uint32 | read | Limit on the maximum number of users allowed to use this resource concurrently. The value is only valid if the AllowMaximum property is set to FALSE. Code | |||||||||||||||||||||||||||||||||||||||
| Name# key | string | read | Alias given to a path set up as a share on a computer system running Windows. Windows 2008 example: "\SERVER01\public" - Windows Server 2008 requires that you place the UNC in the name. Code | |||||||||||||||||||||||||||||||||||||||
| Path# | string | read | Local path of the Windows share. Example: "C:\Program Files" Code | |||||||||||||||||||||||||||||||||||||||
| ServerName# | string | read | The cluster server on which the share is hosted. Code | |||||||||||||||||||||||||||||||||||||||
| Status# | string | read | String that indicates the current status of the object. Operational and non-operational status can be defined. Operational status can include "OK", "Degraded", and "Pred Fail". "Pred Fail" indicates that an element is functioning properly, but is predicting a failure (for example, a SMART-enabled hard disk drive). Non-operational status can include "Error", "Starting", "Stopping", and "Service". "Service" can apply during disk mirror-resilvering, reloading a user permissions list, or other administrative work. Not all such work is online, but the managed element is neither "OK" nor in one of the other states. Values include the following: Values (12)
Code | |||||||||||||||||||||||||||||||||||||||
| Type# | uint32 | read | Type of resource being shared. Types include: disk drives, print queues, interprocess communications (IPC), and general devices. Values (8)
Code |
Methods
Create static#
Creates a new Win32_ClusterShare instance.
uint32 Create(
[in] string Path,
[in] string Name,
[in] uint32 Type,
[in] uint32 MaximumAllowed,
[in] string Description,
[in] string Password,
[in] Win32_SecurityDescriptor Access
);Parameters
| Parameter | Type | Direction | Description |
|---|---|---|---|
| Path | string | in | Local path of the Windows share. Example, "C:\Program Files". |
| Name | string | in | The alias to a path set up as a share on a computer system running Windows. Example, "public". |
| Type | uint32 | in | Type of resource being shared. Types include: disk drives, print queues, interprocess communications (IPC), and general devices. |
| MaximumAllowed | uint32 | in | Limit on the maximum number of users allowed to use this resource concurrently. |
| Description | string | in | Description of the object. |
| Password | string | in | TBD |
| Access | Win32_SecurityDescriptor | in | Optional embedded instance of a Win32_SecurityDescriptor class that contains the security descriptor for the new share. |
Call the Create method
review before running# Warning: this method can change the system. -WhatIf shows the operation without running it.
$methodParameters = @{
ClassName = 'Win32_ClusterShare'
MethodName = 'Create'
Arguments = @{
Path = 'Example'
Name = 'Example'
Type = 1
MaximumAllowed = 0
Description = 'Example'
Password = 'Example'
Access = $null
}
WhatIf = $true # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters
# With -WhatIf nothing runs and no result is returned
if ($result) {
$result.ReturnValue
}This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.
Delete #
Deletes a Win32_ClusterShare instance.
uint32 Delete();Call the Delete method
review before running# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_ClusterShare -Filter "Name = 'Example'"
$methodParameters = @{
InputObject = $instance
MethodName = 'Delete'
WhatIf = $true # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters
# With -WhatIf nothing runs and no result is returned
if ($result) {
$result.ReturnValue
}This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.
GetAccessMask #
Returns a bitmap with the access rights to the share.
uint32 GetAccessMask();Call the GetAccessMask method
review before running# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_ClusterShare -Filter "Name = 'Example'"
$methodParameters = @{
InputObject = $instance
MethodName = 'GetAccessMask'
WhatIf = $true # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters
# With -WhatIf nothing runs and no result is returned
if ($result) {
$result.ReturnValue
}This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.
Inheritance
Superclass chain
- CIM_ManagedSystemElement
- CIM_LogicalElement
- Win32_Share
- Win32_ClusterShare
Known subclasses
No known subclass.
Requirements
- Namespace
- root/cimv2
- Minimum client
- Windows 7
- Minimum server
- Windows Server 2008 R2
- Provider
- CIMWin32
- MOF file
- Cimwin32.mof
- DLL
- CIMWin32.dll
Class qualifiers
Dynamic Provider("CIMWin32") UUID("{8502C4D6-5FBB-11D2-AAC1-006008C78BC7}") SupportsCreate CreateBy("Create") SupportsDelete DeleteBy("DeleteInstance") AMENDMENT
Microsoft source
Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.