Windows Server 2012 and 2012 R2 introduced a new set of storage cmdlets that provided specific support for disk management, multipath I/O configuration, MSDSM settings and more. These new cmdlets allowed for much simpler scripting which was a great advantage, but at the same time caused some headaches with customers that were running older versions of the Server such as 2008 or 2008 R2. The issue was that these new cmdlets were not available in the older versions of Windows Server which meant this took writing script that used Get-WmiObject (aka gwmi) with specific classes such as Win32_LogicalDisk, Win32_DiskDrive or Win32_DiskPartition.
Most (if not all) customers running Microsoft Server run multiple versions which means everyone faces this problem of supporting either one common approach using Get-WmiObject or two sets of scripts using the old and new cmdlets. Some times supporting the two different approaches can be a daunting task so I wanted to put together the command specifics that supports the Server 2008 R2 and Windows Server 2012/2012 R2.
The following sections describe the settings that we recommend to our customers when configuring the Server. This includes configuring MPIO HW values, formatting volumes, initializing volumes (aka disks) and other tasks. I have mapped out the differences in cmdlets and command line tools between Windows Server 2008 R2 and Windows Server 2012/2012 R2 so that everyone can benefit from understanding the specific commands.
Get Logical Disk & Partition Windows Information
Server 2008 R2 SP1
1 |
Get-WmiObject Win32_DiskPartition -ComputerName $env:COMPUTERNAME | select Name, Index, BlockSize, StartingOffset | Format-Table * |
Server 2012 or 2012 R2
1 |
Get-Partition |
Get Installed Windows Hotfixes
Server 2008 R2 SP1
1 |
Get-WmiObject -Class Win32_QuickFixEngineering | Select-Object -Property Description, HotFixID, InstalledOn | Format-Table –Autosize |
Windows Server 2012 or 2012 R2
1 |
Get-Hotfix |
Install MultiPath I/O (MPIO)
Windows Server 2008 R2 SP1
1 2 |
Import-Module Servermanager Add-WindowsFeature Multipath-IO |
Windows Server 2012 or 2012 R2
1 |
Add-WindowsFeature -Name “Multipath-IO” |
Configure New MPIO Device
Windows Server 2008 R2 SP1
1 2 3 4 |
Start > Run > mpiocpl mpclaim -e mpclaim –i –r –d “PURE FlashArray “ Manually reboot |
Note: Format is important including spaces, Vendor=PURE + 4 spaces, ProductId= FlashArray + 6 spaces
Windows Server 2012 or 2012 R2
1 2 3 |
Get-MSDSMSupportedHW New-MSDSMSupportedHW -ProductId FlashArray -VendorId PURE Restart-Computer |
Note: No need for the spaces.
Windows Disk Management
View Pure Storage FlashArray Volumes Only
Server 2008 R2 SP1
1 |
Get-WmiObject -Class Win32_DiskDrive | Where-Object { $_.Model -like “PURE*” }| Format-Table –Autosize |
Server 2012 or 2012 R2
1 |
Get-Disk | Where-Object FriendlyName -like “PURE*” |
Rescan for new volumes
Server 2008 R2 SP1 & Windows Server 2012/2012 R2
1 |
”rescan” | diskpart |
Initialize Newly Added Pure Storage Volumes
Server 2008 R2 SP1
1 2 3 4 5 6 7 8 9 10 |
$PureVolumes = gwmi win32_diskdrive | where {$_.model -like “PURE*”} foreach ($disk in $PureVolumes) { $diskID = $disk.index $dpscript = @” select disk $diskID online disk noerr “@ $dpscript | diskpart } |
Server 2012 or 2012 R2
1 |
Initialize-Disk <DiskNumber> |
Create New Partition, Set Mount Point and Format Volume
Server 2008 R2 SP1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
$PureVolumes = Get–WmiObject Win32_DiskDrive | where {$_.model -like “PURE FlashArray*”} foreach ($disk in $PureVolumes) { $diskID = $disk.index $dpscript = @“ rem Select the Disk. select disk $diskID rem Online the selected disk. online disk rem Convert to GPT, or use MBR. convert gpt rem Create the primary partition. create partition primary rem Assign Drive Letter manually. rem letter=P rem Enable Automount to set Drive Letter automatically. automount enable rem Create a new simple volume. create volume simple rem Quick format the volume with NTFS and set volume label to PURE STORAGE. format fs=ntfs label=”PURE STORAGE” quick “@ $dpscript | diskpart } |
Windows Server 2012 or 2012 R2
1 2 3 |
New-Partition -DiskNumber <DiskNumber> –UseMaximumSize –AssignDriveLetter Add-PartitionAccessPath -DiskNumber -PartitionNumber <#> -AccessPath C:MyMountPoint Format-Volume -DriveLetter <DriveLetter> -FileSystem NTFS |
Set SAN Policy
Windows Server 2008 R2 SP1
1 |
“SAN Policy=OnlineAll” | diskpart |
Server 2012 or 2012 R2
1 |
Set-StorageSetting –NewDiskPolicy OnlineAll |
Note: When using Server Failover Clustering be sure to keep the default setting of OfflineShared.
Configure MPIO Windows Policies
Display Current MPIO Policies
Server 2008 R2 SP1
1 |
mpclaim –s |
Server 2012 or 2012 R2
1 |
Get-MPIOSetting |
Get & Set Recommended MPIO Policy Settings
Windows Server 2008 R2 SP1
1 2 3 4 5 6 7 8 9 10 11 |
(Get-ItemProperty “HKLM:SystemCurrentControlSetServicesMSDSMParameters”).RetryInterval Set-ItemProperty -Path “HKLM:SystemCurrentControlSetServicesMSDSMParameters” -Name RetryInterval -Value 20 (Get-ItemProperty “HKLM:SystemCurrentControlSetServicesmpioParameters”).UseCustomPathRecoveryInterval Set-ItemProperty -Path “HKLM:SystemCurrentControlSetServicesmpioParameters” -Name UseCustomPathRecoveryInterval -Value 1 (Get-ItemProperty “HKLM:SystemCurrentControlSetServicesMSDSMParameters”).PDORemovePeriod Set-ItemProperty -Path “HKLM:SystemCurrentControlSetServicesMSDSMParameters” -Name PDORemovePeriod -Value 30 (Get-ItemProperty “HKLM:SystemCurrentControlSetServicesDisk”) Set-ItemProperty -Path “HKLM:SystemCurrentControlSetServicesDisk” -Name TimeOutValue -Value 60 |
Windows Server 2012 or 2012 R2
1 2 3 4 |
Set-MPIOSetting -NewPathRecoveryInterval 20 Set-MPIOSetting -CustomPathRecovery Enabled Set-MPIOSetting -NewPDORemovePeriod 30 Set-MPIOSetting -NewDiskTimeout 60 |
Windows References
- mpclaim parameters – https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ee619743(v=ws.10)
- Storage Cmdlets in Windows PowerShell – https://learn.microsoft.com/en-us/powershell/module/storage/?view=windowsserver2022-ps
It is easy to see that the Windows Server 2012/2012 R2 approach is much simpler and less prone to scripting snafus.
Thanks,
barkz