From 8ea6e863fc6b935da137b8a991cbbc27914977b4 Mon Sep 17 00:00:00 2001 From: Josh Swain Date: Mon, 4 Mar 2019 18:19:03 -0500 Subject: [PATCH 01/10] fixing get-partition to pull current state --- DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 b/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 index f963dd73..c5407c9c 100644 --- a/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 +++ b/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 @@ -519,7 +519,7 @@ function Set-TargetResource } # if # Get the current partition state for NoDefaultDriveLetter - $assignedPartition = $partition | + $assignedPartition = Get-Partition -PartitionNumber $partition.PartitionNumber | Where-Object -Property AccessPaths -Contains -Value $AccessPath if ($assignedPartition.NoDefaultDriveLetter -ne $NoDefaultDriveLetter) From dba31ef0fb5f475b7667a822d7111ee2b74ba4c7 Mon Sep 17 00:00:00 2001 From: Josh Swain Date: Tue, 5 Mar 2019 07:53:37 -0500 Subject: [PATCH 02/10] changing logic to get partition state --- DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 b/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 index c5407c9c..226c47a4 100644 --- a/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 +++ b/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 @@ -518,8 +518,11 @@ function Set-TargetResource ) -join '' ) } # if + # Get the partitions on the disk + $partition = $disk | Get-Partition -ErrorAction SilentlyContinue + # Get the current partition state for NoDefaultDriveLetter - $assignedPartition = Get-Partition -PartitionNumber $partition.PartitionNumber | + $assignedPartition = $partition | Where-Object -Property AccessPaths -Contains -Value $AccessPath if ($assignedPartition.NoDefaultDriveLetter -ne $NoDefaultDriveLetter) From bd6e0b1351b212c4927ef0ab7a5442a58c565a29 Mon Sep 17 00:00:00 2001 From: Josh Swain Date: Tue, 5 Mar 2019 08:14:23 -0500 Subject: [PATCH 03/10] code review updates --- .../MSFT_DiskAccessPath.psm1 | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 b/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 index 226c47a4..a361a589 100644 --- a/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 +++ b/DSCResources/MSFT_DiskAccessPath/MSFT_DiskAccessPath.psm1 @@ -525,18 +525,18 @@ function Set-TargetResource $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 '' ) + 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 + # Setting the partition property NoDefaultDriveLetter + Set-Partition -PartitionNumber $assignedPartition.PartitionNumber ` + -DiskNumber $disk.Number ` + -NoDefaultDriveLetter $NoDefaultDriveLetter + } # if } # Set-TargetResource <# From e4092320328f1f218d4e6f463894c63c23db78e9 Mon Sep 17 00:00:00 2001 From: Josh Swain Date: Thu, 11 Apr 2019 15:18:29 -0400 Subject: [PATCH 04/10] get-partition called 2 times for nodefautldriveletter unit tests --- Tests/Unit/MSFT_DiskAccessPath.Tests.ps1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Tests/Unit/MSFT_DiskAccessPath.Tests.ps1 b/Tests/Unit/MSFT_DiskAccessPath.Tests.ps1 index 5c8267bf..bd0d24a1 100644 --- a/Tests/Unit/MSFT_DiskAccessPath.Tests.ps1 +++ b/Tests/Unit/MSFT_DiskAccessPath.Tests.ps1 @@ -651,7 +651,7 @@ try -ParameterFilter $script:parameterFilter_Disk0OfflineDiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 1 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 1 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 1 @@ -724,7 +724,7 @@ try -ParameterFilter $script:parameterFilter_Disk0OfflineDiskIdUniqueId Assert-MockCalled -CommandName Set-Disk -Exactly -Times 1 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 1 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 1 @@ -797,7 +797,7 @@ try -ParameterFilter $script:parameterFilter_Disk0OfflineDiskIdGuid Assert-MockCalled -CommandName Set-Disk -Exactly -Times 1 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 1 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 1 @@ -869,7 +869,7 @@ try -ParameterFilter $script:parameterFilter_Disk0ReadonlyDiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 1 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 1 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 1 @@ -943,7 +943,7 @@ try -ParameterFilter $script:parameterFilter_Disk0OfflineRawDiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 1 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 1 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 1 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 1 @@ -1014,7 +1014,7 @@ try -ParameterFilter $script:parameterFilter_Disk0RawDiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 0 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 1 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 1 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 1 @@ -1083,7 +1083,7 @@ try -ParameterFilter $script:parameterFilter_Disk0DiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 0 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 1 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 1 @@ -1291,7 +1291,7 @@ try -ParameterFilter $script:parameterFilter_Disk0DiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 0 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 0 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 0 @@ -1354,7 +1354,7 @@ try -ParameterFilter $script:parameterFilter_Disk0DiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 0 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 0 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 0 @@ -1417,7 +1417,7 @@ try -ParameterFilter $script:parameterFilter_Disk0DiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 0 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 2 Assert-MockCalled -CommandName New-Partition -Exactly -Times 0 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 0 @@ -1478,7 +1478,7 @@ try -ParameterFilter $script:parameterFilter_Disk0DiskIdNumber Assert-MockCalled -CommandName Set-Disk -Exactly -Times 0 Assert-MockCalled -CommandName Initialize-Disk -Exactly -Times 0 - Assert-MockCalled -CommandName Get-Partition -Exactly -Times 1 + Assert-MockCalled -CommandName Get-Partition -Exactly -Times 2 Assert-MockCalled -CommandName Get-Volume -Exactly -Times 1 Assert-MockCalled -CommandName New-Partition -Exactly -Times 0 Assert-MockCalled -CommandName Format-Volume -Exactly -Times 0 From 9b8ef586ef87c97f1a56267b341783e3cd82de41 Mon Sep 17 00:00:00 2001 From: Josh Swain Date: Sat, 13 Apr 2019 08:57:36 -0400 Subject: [PATCH 05/10] update changelog for PR 198 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45779e60..12e677aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +- DiskAccessPath: + - Added a get-partion to properly handle setting the NoDefaultDriveLetter + parameter - fixes [Issue #198](https://github.com/PowerShell/StorageDsc/pull/198) + ## 4.6.0.0 - Fix example publish to PowerShell Gallery by adding `gallery_api` From cebcfd8a16af6f1efa734e805f6b2e1e8bfabdce Mon Sep 17 00:00:00 2001 From: Josh Swain Date: Sat, 13 Apr 2019 18:56:13 -0400 Subject: [PATCH 06/10] update changelog for typo spelling --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12e677aa..d8c47115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased - DiskAccessPath: - - Added a get-partion to properly handle setting the NoDefaultDriveLetter + - Added a Get-Partition to properly handle setting the NoDefaultDriveLetter parameter - fixes [Issue #198](https://github.com/PowerShell/StorageDsc/pull/198) ## 4.6.0.0 From 0a3e30ee37958b0d10b3581622d5c8f858b75f86 Mon Sep 17 00:00:00 2001 From: Josh Swain Date: Sat, 13 Apr 2019 18:59:14 -0400 Subject: [PATCH 07/10] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8c47115..9899ac75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - DiskAccessPath: - Added a Get-Partition to properly handle setting the NoDefaultDriveLetter - parameter - fixes [Issue #198](https://github.com/PowerShell/StorageDsc/pull/198) + parameter - fixes [Issue #198](https://github.com/PowerShell/StorageDsc/pull/198). ## 4.6.0.0 From 580c929c1b74f83f31c557df5c26ff5729bf431a Mon Sep 17 00:00:00 2001 From: Katie Kragenbrink Date: Wed, 15 May 2019 10:16:44 -0700 Subject: [PATCH 08/10] Releasing version 4.7.0.0 --- CHANGELOG.md | 2 ++ StorageDsc.psd1 | 23 +++++------------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9899ac75..94c229fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +## 4.7.0.0 + - DiskAccessPath: - Added a Get-Partition to properly handle setting the NoDefaultDriveLetter parameter - fixes [Issue #198](https://github.com/PowerShell/StorageDsc/pull/198). diff --git a/StorageDsc.psd1 b/StorageDsc.psd1 index 886a5096..91326055 100644 --- a/StorageDsc.psd1 +++ b/StorageDsc.psd1 @@ -3,7 +3,7 @@ # RootModule = '' # Version number of this module. - moduleVersion = '4.6.0.0' + moduleVersion = '4.7.0.0' # ID used to uniquely identify this module GUID = '00d73ca1-58b5-46b7-ac1a-5bfcf5814faf' @@ -102,23 +102,9 @@ # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = '- Fix example publish to PowerShell Gallery by adding `gallery_api` - environment variable to `AppVeyor.yml` - fixes [Issue 202](https://github.com/PowerShell/StorageDsc/issues/202). -- Added "DscResourcesToExport" to manifest to improve information in - PowerShell Gallery and removed wildcards from "FunctionsToExport", - "CmdletsToExport", "VariablesToExport" and "AliasesToExport" - fixes - [Issue 192](https://github.com/PowerShell/StorageDsc/issues/192). -- Clean up module manifest to correct Author and Company - fixes - [Issue 191](https://github.com/PowerShell/StorageDsc/issues/191). -- Correct unit tests for DiskAccessPath to test exact number of - mocks called - fixes [Issue 199](https://github.com/PowerShell/StorageDsc/issues/199). -- Disk: - - Added minimum timetowate of 3s after new-partition using the while loop. - The problem occurs when the partition is created and the format-volume - is attempted before the volume has completed. - There appears to be no property to determine if the partition is - sufficiently ready to format and it will often format as a raw volume when - the error occurs - fixes [Issue 85](https://github.com/PowerShell/StorageDsc/issues/85). + ReleaseNotes = '- DiskAccessPath: + - Added a Get-Partition to properly handle setting the NoDefaultDriveLetter + parameter - fixes [Issue 198](https://github.com/PowerShell/StorageDsc/pull/198). ' @@ -133,3 +119,4 @@ # DefaultCommandPrefix = '' } + From 6b28b7c8cc0fbedcfebd11b8c03dfab03096154b Mon Sep 17 00:00:00 2001 From: Katie Keim Date: Wed, 15 May 2019 12:17:11 -0700 Subject: [PATCH 09/10] Fixing markdown test failures --- DSCResources/MSFT_OpticalDiskDriveLetter/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/DSCResources/MSFT_OpticalDiskDriveLetter/README.md b/DSCResources/MSFT_OpticalDiskDriveLetter/README.md index 9df3ce47..38fe600f 100644 --- a/DSCResources/MSFT_OpticalDiskDriveLetter/README.md +++ b/DSCResources/MSFT_OpticalDiskDriveLetter/README.md @@ -29,8 +29,10 @@ With the Device ID, we look for the length of the string after the final backslash (crude, but appears to work so far). Example: - # DeviceID for a virtual drive in a Hyper-V VM - SCSI\CDROM&VEN_MSFT&PROD_VIRTUAL_DVD-ROM\**000006** +``` +# DeviceID for a virtual drive in a Hyper-V VM + SCSI\CDROM&VEN_MSFT&PROD_VIRTUAL_DVD-ROM\**000006** - # DeviceID for a mounted ISO in a Hyper-V VM - SCSI\CDROM&VEN_MSFT&PROD_VIRTUAL_DVD-ROM\**2&1F4ADFFE&0&000002** +# DeviceID for a mounted ISO in a Hyper-V VM + SCSI\CDROM&VEN_MSFT&PROD_VIRTUAL_DVD-ROM\**2&1F4ADFFE&0&000002** +``` From 8036a4b718d04dd9f3640e973f19a20ebae38899 Mon Sep 17 00:00:00 2001 From: Katie Keim Date: Wed, 15 May 2019 12:28:03 -0700 Subject: [PATCH 10/10] Fixing 2nd markdown error --- DSCResources/MSFT_OpticalDiskDriveLetter/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DSCResources/MSFT_OpticalDiskDriveLetter/README.md b/DSCResources/MSFT_OpticalDiskDriveLetter/README.md index 38fe600f..aba1f40d 100644 --- a/DSCResources/MSFT_OpticalDiskDriveLetter/README.md +++ b/DSCResources/MSFT_OpticalDiskDriveLetter/README.md @@ -29,10 +29,11 @@ With the Device ID, we look for the length of the string after the final backslash (crude, but appears to work so far). Example: -``` + +```powershell # DeviceID for a virtual drive in a Hyper-V VM - SCSI\CDROM&VEN_MSFT&PROD_VIRTUAL_DVD-ROM\**000006** +"SCSI\CDROM&VEN_MSFT&PROD_VIRTUAL_DVD-ROM\**000006**" -# DeviceID for a mounted ISO in a Hyper-V VM - SCSI\CDROM&VEN_MSFT&PROD_VIRTUAL_DVD-ROM\**2&1F4ADFFE&0&000002** +# DeviceID for a mounted ISO in a Hyper-V VM +"SCSI\CDROM&VEN_MSFT&PROD_VIRTUAL_DVD-ROM\**2&1F4ADFFE&0&000002**" ```