Set Disk - PowerShell


Overview

The Set-Disk cmdlet in PowerShell modifies the properties of an existing data, dynamic, or read-only disk on a Storage Spaces Direct (S2D) cluster. It allows you to adjust disk properties like its access type, file system, and operational status, providing flexibility in disk management for your S2D environment.

Syntax

Set-Disk [-InputObject] <StorageSpaceDirect.Management.Disk> -FriendlyName <string> [[-DiskAccessType] <string>] [[-FileSystem] <string>] [[-OperationalStatus] <string>] [[-Force] <bool>] [[-PassThru] <bool>] [<CommonParameters>]

Options/Flags

  • -InputObject: Specifies the disk object to modify. It takes an instance of StorageSpaceDirect.Management.Disk as input.
  • -FriendlyName: Specifies the new friendly name for the disk.
  • -DiskAccessType: Modifies the disk’s access type. Valid values include “ReadOnly”, “ReadWrite”, or “Private”.
  • -FileSystem: Sets the file system type for the disk, such as “NTFS” or “ReFS”.
  • -OperationalStatus: Changes the disk’s operational status. Options include “Online”, “Offline”, “Suspended”, or “Unknown”.
  • -Force: Overrides any warnings or errors and force-applies the changes. Use with caution.
  • -PassThru: Returns the newly modified disk object after the operation completes.

Examples

Example 1: Change Disk Friendly Name

Set-Disk -InputObject $MyDisk -FriendlyName "MyNewDisk"

Example 2: Set Disk as Read Only

Set-Disk -InputObject $MyDisk -DiskAccessType ReadOnly

Example 3: Format and Activate Disk

Set-Disk -InputObject $MyDisk -FileSystem NTFS -OperationalStatus Online

Example 4: Force Offline Disk

Set-Disk -InputObject $MyDisk -OperationalStatus Offline -Force

Common Issues

  • Incorrect disk object: Ensure you are using the correct instance of StorageSpaceDirect.Management.Disk as the -InputObject.
  • Protected disk: Modifying protected disks may require additional steps or approvals.

Integration

Set-Disk can be integrated into PowerShell scripts or workflows to automate S2D disk management. It can be combined with other cmdlets like Get-Disk, New-Disk, and Remove-Disk for comprehensive disk lifecycle management.

  • Get-Disk: Retrieves information about existing disks.
  • New-Disk: Creates a new disk on an S2D cluster.
  • Remove-Disk: Removes an existing disk from an S2D cluster.
  • Initialize-Disk: Initializes a new disk for use with Storage Spaces Direct.