Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-DiskByIdentifier: Allow selection based on Serial Number #260

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Azure Pipelines - Fixes [Issue #255](https://github.com/dsccommunity/StorageDsc/issues/255).
- Updated build to use `Sampler.GitHubTasks` - Fixes [Issue #254](https://github.com/dsccommunity/StorageDsc/issues/254).
- Updated pipeline tasks to latest pattern.
- Added serial number as disk identifier to Disk, DiskAccessPath and WaitForDisk resources - Fixes [Issue #259](https://github.com/dsccommunity/StorageDsc/issues/259).

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions source/DSCResources/DSC_Disk/DSC_Disk.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Get-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -190,7 +190,7 @@ function Set-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -687,7 +687,7 @@ function Test-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down
2 changes: 1 addition & 1 deletion source/DSCResources/DSC_Disk/DSC_Disk.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class DSC_Disk : OMI_BaseResource
{
[Key, Description("Specifies the identifier for which disk to modify.")] String DriveLetter;
[Required, Description("Specifies the disk identifier for the disk to modify.")] String DiskId;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location"}, Values{"Number","UniqueId","Guid","Location"}] String DiskIdType;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location","SerialNumber"}, Values{"Number","UniqueId","Guid","Location","SerialNumber"}] String DiskIdType;
[Write, Description("Specifies the partition style of the disk. Defaults to GPT."), ValueMap{"MBR","GPT"}, Values{"MBR","GPT"}] String PartitionStyle;
[Write, Description("Specifies the size of new volume. Leave empty to use the remaining free space.")] Uint64 Size;
[Write, Description("Define volume label if required.")] String FSLabel;
Expand Down
6 changes: 3 additions & 3 deletions source/DSCResources/DSC_Disk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ The resource is used to initialize, format and mount the partition/volume as a d
letter.
The disk to add the partition/volume to is selected by specifying the _DiskId_ and
optionally _DiskIdType_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_ or _Location_.
The _DiskId_ value can be a _Disk Number_, _Serial Number_, _Unique Id_, _Guid_ or _Location_.

**Important: The _Disk Number_ is not a reliable method of selecting a disk because
it has been shown to change between reboots in some environments.
It is recommended to use the _Unique Id_ if possible.**

The _Disk Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
The _Disk Number_, _Serial Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
disk by using the PowerShell command:

```powershell
Get-Disk | Select-Object -Property FriendlyName,DiskNumber,UniqueId,Guid,Location
Get-Disk | Select-Object -Property FriendlyName,DiskNumber,SerialNumber,UniqueId,Guid,Location
```

Note: The _Guid_ identifier method of specifying disks is only supported as an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function Get-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -173,7 +173,7 @@ function Set-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -585,7 +585,7 @@ function Test-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DSC_DiskAccessPath : OMI_BaseResource
[Key, Description("Specifies the access path folder to the assign the disk volume to.")] String AccessPath;
[Write, Description("Specifies no automatic drive letter assignment to the partition: Defaults to True")] Boolean NoDefaultDriveLetter;
[Required, Description("Specifies the disk identifier for the disk to modify.")] String DiskId;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location"}, Values{"Number","UniqueId","Guid","Location"}] String DiskIdType;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location","SerialNumber"}, Values{"Number","UniqueId","Guid","Location","SerialNumber"}] String DiskIdType;
[Write, Description("Specifies the size of new volume.")] Uint64 Size;
[Write, Description("Define volume label if required.")] String FSLabel;
[Write, Description("Specifies the allocation unit size to use when formatting the volume.")] Uint32 AllocationUnitSize;
Expand Down
6 changes: 3 additions & 3 deletions source/DSCResources/DSC_DiskAccessPath/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ The resource is used to initialize, format and mount the partition/volume to a f
access path.
The disk to add the partition/volume to is selected by specifying the _DiskId_ and
optionally _DiskIdType_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_ or _Location_.
The _DiskId_ value can be a _Disk Number_, _Serial Number_, _Unique Id_, _Guid_ or _Location_.

**Important: The _Disk Number_ is not a reliable method of selecting a disk because
it has been shown to change between reboots in some environments.
It is recommended to use the _Unique Id_ if possible.**

The _Disk Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
The _Disk Number_, _Serial Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
disk by using the PowerShell command:

```powershell
Get-Disk | Select-Object -Property FriendlyName,DiskNumber,UniqueId,Guid,Location
Get-Disk | Select-Object -Property FriendlyName,DiskNumber,SerialNumber,UniqueId,Guid,Location
```

Note: The _Guid_ for a disk is only assigned once the partition table for the disk
Expand Down
6 changes: 3 additions & 3 deletions source/DSCResources/DSC_WaitForDisk/DSC_WaitForDisk.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Get-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number','UniqueId','Guid','Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -94,7 +94,7 @@ function Set-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number','UniqueId','Guid','Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -176,7 +176,7 @@ function Test-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number','UniqueId','Guid','Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'SerialNumber')]
[System.String]
$DiskIdType = 'Number',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class DSC_WaitForDisk : OMI_BaseResource
{
[Key, Description("Specifies the disk identifier for the disk to wait for.")] String DiskId;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location"}, Values{"Number","UniqueId","Guid","Location"}] String DiskIdType;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location","SerialNumber"}, Values{"Number","UniqueId","Guid","Location","SerialNumber"}] String DiskIdType;
[Write, Description("Specifies the number of seconds to wait for the disk to become available.")] Uint32 RetryIntervalSec;
[Write, Description("The number of times to loop the retry interval while waiting for the disk.")] Uint32 RetryCount;
[Read, Description("Will indicate whether Disk is available.")] Boolean IsAvailable;
Expand Down
6 changes: 3 additions & 3 deletions source/DSCResources/DSC_WaitForDisk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
This resource is used to wait for a disk to become available.
The disk to wait for is selected by specifying the _DiskId_ and optionally
_DiskIdType_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_ or _Location_.
The _DiskId_ value can be a _Disk Number_, _Serial Number_, _Unique Id_, _Guid_ or _Location_.

**Important: The _Disk Number_ is not a reliable method of selecting a disk because
it has been shown to change between reboots in some environments.
It is recommended to use the _Unique Id_ if possible.**

The _Disk Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
The _Disk Number_, _Serial Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
disk by using the PowerShell command:

```powershell
Get-Disk | Select-Object -Property FriendlyName,DiskNumber,UniqueId,Guid,Location
Get-Disk | Select-Object -Property FriendlyName,DiskNumber,SerialNumber,UniqueId,Guid,Location
```

Note: The _Guid_ for a disk is only assigned once the partition table for the disk
Expand Down
4 changes: 2 additions & 2 deletions source/Modules/StorageDsc.Common/StorageDsc.Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ function Get-DiskByIdentifier
$DiskId,

[Parameter()]
[ValidateSet('Number','UniqueId','Guid','Location')]
[ValidateSet('Number','UniqueId','Guid','Location','SerialNumber')]
[System.String]
$DiskIdType = 'Number'
)

switch -regex ($DiskIdType)
{
'Number|UniqueId' # for filters supported by the Get-Disk CmdLet
'Number|UniqueId|SerialNumber' # for filters supported by the Get-Disk CmdLet
{
$diskIdParameter = @{
$DiskIdType = $DiskId
Expand Down
Loading