Introduction

The xDisk module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources. This module contains the xDisk and xWaitforDisk resources. These resources enable you to wait for a disk to become available and then initialize, format, and bring it online using PowerShell DSC.

NOTE:  This resource follows a process to detect the existance of a RAW disk, initialize the disk, create a volume of maximum size, and then format the new volume.  Before beginning that operation, the disk is marked 'Online' and if it is set to 'Read-Only', that property is removed.  While this is intended to be non-destructive, as with all expiremental resources the scripts contained should be thoroughly evaluated and well understood before implementing in a production environment or where disk modifications could result in lost data.

All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service. The "x" in xDisk stands for experimental, which means that these resources will be fix forward and monitored by the module owner(s).

Please leave comments, feature requests, and bug reports in the Q & A tab for this module.

If you would like to modify xDisk module, feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify this resource as long as they are used on the Windows Platform.

For more information about Windows PowerShell Desired State Configuration, check out the blog posts on the PowerShell Blog (this is a good starting point). There are also great community resources, such as PowerShell.org , or PowerShell Magazine . For more information on the DSC Resource Kit, check out this blog post.

Installation

To install xDisk module

  • If you are using WMF4 / PowerShell Version 4: Unzip the content under $env:ProgramFiles\WindowsPowerShell\Modules folder
  • If you are using WMF5 Preview: From an elevated PowerShell session run ‘Install-Module xDisk’

To confirm installation:

  • Run Get-DSCResource to see that the resources listed above are among the DSC Resources displayed

Requirements

This module requires the latest version of PowerShell (v4.0, which ships in Windows 8.1 or Windows Server 2012R2). To easily use PowerShell 4.0 on older operating systems, install WMF 4.0. Please read the installation instructions that are present on both the download page and the release notes for WMF 4.0.

Details

xDisk resource has following properties:

  • DiskNumber: Specifies the identifier for which disk to modify.
  • DriveLetter: Specifies the preffered letter to assign to the disk volume.

xWaitforDisk resource has following properties:

  • DiskNumber: Specifies the identifer for which disk to wait for.
  • RetryIntervalSec: Specifies the number of secods to wait for the disk to become available.
  • Count: The number of times to loop the retry interval while waiting for the disk.

Renaming Requirements

When making changes to these resources, we suggest the following practice:

  1. Update the following names by replacing MSFT with your company/community name and replacing the "x" with "c" (short for "Community") or another prefix of your choice:
    • Module name (ex: xDisk becomes cDisk)
    • Resource folder (ex: MSFT_xDisk becomes Contoso_xDisk)
    • Resource Name (ex: MSFT_xDisk becomes Contoso_cDisk)
    • Resource Friendly Name (ex: xDisk becomes cDisk)
    • MOF class name (ex: MSFT_xDisk becomes Contoso_cDisk)
    • Filename for the <resource>.schema.mof (ex: MSFT_xDisk.schema.mof becomes Contoso_cDisk.schema.mof)
  2. Update module and metadata information in the module manifest
  3. Update any configuration that use these resources

We reserve resource and module names without prefixes ("x" or "c") for future use (e.g. "MSFT_Disk" or "MSFT_ADUser"). If the next version of Windows Server ships with a "Disk" resource, we don't want to break any configurations that use any community modifications. Please keep a prefix such as "c" on all community modifications.

Versions

1.0

  • Initial release with the following resources
    • xDisk
    • xWaitforDisk

Examples

Example 1:  Wait for disk 2 to become available, and then make the disk available as a new formatted volume.

{
    
    Import-DSCResource -ModuleName xDisk
 
    Node localhost'
    {
        xWaitforDisk Disk2
        {
             DiskNumber = 2
             RetryIntervalSec = 60
             Count = 60
        }
        xDisk GVolume
        {
             DiskNumber = 2
             DriveLetter = 'G'
        }
    }
}
 
DataDisk -outputpath C:\DataDisk