Skip to content

Commit

Permalink
Merge pull request #195 from PowerShell/dev
Browse files Browse the repository at this point in the history
Release of version 4.5.0.0 of StorageDsc
  • Loading branch information
kwirkykat authored Feb 20, 2019
2 parents 01c2380 + 587c178 commit 47855fb
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 26 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## Unreleased

## 4.5.0.0

- Opt-in to Example publishing to PowerShell Gallery - fixes [Issue #186](https://github.com/PowerShell/StorageDsc/issues/186).
- DiskAccessPath:
- Updated the resource to not assign a drive letter by default when adding
a disk access path. Adding a Set-Partition -NoDefaultDriveLetter
$NoDefaultDriveLetter block defaulting to true.
When adding access paths the disks will no longer have
drive letters automatically assigned on next reboot which is the desired
behavior - Fixes [Issue #145](https://github.com/PowerShell/StorageDsc/issues/145).

## 4.4.0.0

- Refactored module folder structure to move resource to root folder of
Expand Down
65 changes: 57 additions & 8 deletions DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ $localizedData = Get-LocalizedData `
.PARAMETER AccessPath
Specifies the access path folder to the assign the disk volume to
.PARAMETER NoDefaultDriveLetter
Prevents a default drive letter from being assigned to a newly created partition. Defaults to True.
.PARAMETER DiskId
Specifies the disk identifier for the disk to modify.
Expand Down Expand Up @@ -55,6 +58,10 @@ function Get-TargetResource
[System.String]
$AccessPath,

[Parameter()]
[System.Boolean]
$NoDefaultDriveLetter = $true,

[Parameter(Mandatory = $true)]
[System.String]
$DiskId,
Expand Down Expand Up @@ -115,13 +122,14 @@ function Get-TargetResource
-ErrorAction SilentlyContinue).BlockSize

$returnValue = @{
DiskId = $DiskId
DiskIdType = $DiskIdType
AccessPath = $AccessPath
Size = $assignedPartition.Size
FSLabel = $FSLabel
AllocationUnitSize = $blockSize
FSFormat = $fileSystem
DiskId = $DiskId
DiskIdType = $DiskIdType
AccessPath = $AccessPath
NoDefaultDriveLetter = $assignedPartition.NoDefaultDriveLetter
Size = $assignedPartition.Size
FSLabel = $FSLabel
AllocationUnitSize = $blockSize
FSFormat = $fileSystem
}
$returnValue
} # Get-TargetResource
Expand All @@ -133,6 +141,9 @@ function Get-TargetResource
.PARAMETER AccessPath
Specifies the access path folder to the assign the disk volume to
.PARAMETER NoDefaultDriveLetter
Prevents a default drive letter from being assigned to a newly created partition. Defaults to True.
.PARAMETER DiskId
Specifies the disk identifier for the disk to modify.
Expand Down Expand Up @@ -162,6 +173,10 @@ function Set-TargetResource
[System.String]
$AccessPath,

[Parameter()]
[System.Boolean]
$NoDefaultDriveLetter = $true,

[Parameter(Mandatory = $true)]
[System.String]
$DiskId,
Expand Down Expand Up @@ -409,7 +424,7 @@ function Set-TargetResource
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($localizedData.PartitionAlreadyAssignedMessage -f `
$AccessPath, $partition.PartitionNumber)
$AccessPath, $assignedPartition.PartitionNumber)
) -join '' )

$assignAccessPath = $false
Expand Down Expand Up @@ -502,6 +517,23 @@ function Set-TargetResource
$($localizedData.SuccessfullyInitializedMessage -f $AccessPath)
) -join '' )
} # if

# Get the current partition state for NoDefaultDriveLetter
$assignedPartition = $partition |
Where-Object -Property AccessPaths -Contains -Value $AccessPath

if ($assignedPartition.NoDefaultDriveLetter -ne $NoDefaultDriveLetter)
{
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
"$($localizedData.NoDefaultDriveLetterMismatchMessage -f $assignedPartition.NoDefaultDriveLetter, $NoDefaultDriveLetter)"
) -join '' )

# Setting the partition property NoDefaultDriveLetter to True to prevent adding drive letter on reboot
Set-Partition -PartitionNumber $assignedPartition.PartitionNumber `
-DiskNumber $disk.Number `
-NoDefaultDriveLetter $NoDefaultDriveLetter
} # if
} # Set-TargetResource

<#
Expand All @@ -511,6 +543,9 @@ function Set-TargetResource
.PARAMETER AccessPath
Specifies the access path folder to the assign the disk volume to
.PARAMETER NoDefaultDriveLetter
Prevents a default drive letter from being assigned to a newly created partition. Defaults to True.
.PARAMETER DiskId
Specifies the disk identifier for the disk to modify.
Expand Down Expand Up @@ -539,6 +574,10 @@ function Test-TargetResource
[System.String]
$AccessPath,

[Parameter()]
[System.Boolean]
$NoDefaultDriveLetter = $true,

[Parameter(Mandatory = $true)]
[System.String]
$DiskId,
Expand Down Expand Up @@ -636,6 +675,16 @@ function Test-TargetResource
return $false
} # if

# Check if the partition NoDefaultDriveLetter parameter is correct
if ($assignedPartition.NoDefaultDriveLetter -ne $NoDefaultDriveLetter)
{
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($localizedData.NoDefaultDriveLetterMismatchMessage -f $assignedPartition.NoDefaultDriveLetter, $NoDefaultDriveLetter)
) -join '' )
return $false
} # if

# Partition size was passed so check it
if ($Size)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class MSFT_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"}, Values{"Number","UniqueId","Guid"}] String DiskIdType;
[Write, Description("Specifies the size of new volume.")] Uint64 Size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
DiskReadOnlyMessage = Disk with {0} '{1}'is readonly.
DiskNotGPTMessage = Disk with {0} '{1}' is initialised with '{2}' partition style. GPT required.
AccessPathNotFoundMessage = A volume assigned to access path '{0}' was not found.
NoDefaultDriveLetterMismatchMessage = Partition default drive letter assigmemt parameter '{0}' does not match '{1}'.
SizeMismatchMessage = Partition assigned to access path '{0}' has size {1}, which does not match expected size {2}.
AllocationUnitSizeMismatchMessage = Volume assigned to access path '{0}' has allocation unit size {1} KB does not match expected allocation unit size {2} KB.
FileSystemFormatMismatch = Volume assigned to access path '{0}' filesystem format '{1}' does not match expected format '{2}'.
Expand Down
18 changes: 10 additions & 8 deletions StorageDsc.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# RootModule = ''

# Version number of this module.
moduleVersion = '4.4.0.0'
moduleVersion = '4.5.0.0'

# ID used to uniquely identify this module
GUID = '00d73ca1-58b5-46b7-ac1a-5bfcf5814faf'
Expand Down Expand Up @@ -102,13 +102,14 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '- Refactored module folder structure to move resource to root folder of
repository and remove test harness - fixes [Issue 169](https://github.com/PowerShell/StorageDsc/issues/169).
- Updated Examples to support deployment to PowerShell Gallery scripts.
- Removed limitation on using Pester 4.0.8 during AppVeyor CI.
- Moved the Code of Conduct text out of the README.md and into a
CODE\_OF\_CONDUCT.md file.
- Explicitly removed extra hidden files from release package
ReleaseNotes = '- Opt-in to Example publishing to PowerShell Gallery - fixes [Issue 186](https://github.com/PowerShell/StorageDsc/issues/186).
- DiskAccessPath:
- Updated the resource to not assign a drive letter by default when adding
a disk access path. Adding a Set-Partition -NoDefaultDriveLetter
$NoDefaultDriveLetter block defaulting to true.
When adding access paths the disks will no longer have
drive letters automatically assigned on next reboot which is the desired
behavior - Fixes [Issue 145](https://github.com/PowerShell/StorageDsc/issues/145).
'

Expand Down Expand Up @@ -137,3 +138,4 @@ PrivateData = @{




Loading

0 comments on commit 47855fb

Please sign in to comment.