-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Problem description
Unable to change the optical drive letter in an Azure Windows Server 2022 VM deployment. The VM only has one optical drive installed (by default, from the image).
The issue does not seem to appear on an Azure Windows Server 2019 VM deployment.
We do not have any optical devices in our VMWare and AWS environments, so I cannot say if the issue exists there as well.
From the documentation, if the VM only has one optical drive, then the DiskID should be set to 1. Also, running the command Get-CimInstance -ClassName Win32_CDROMDrive -Property * will give you the DeviceID that is required by the resource (see below).
# 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**"
But once the DSC is run, the error below can be observed.
Get-OpticalDiskDriveLetter: Using Get-CimInstance to get the drive letter of optical disk 1 in the system.
Get-OpticalDiskDriveLetter: The optical disk 1 could not be found in the system.
Verbose logs
VERBOSE: [azhdct2022-2]: LCM: [ Start Resource ] [[OpticalDiskDriveLetter]SetCDToZ]
VERBOSE: [azhdct2022-2]: LCM: [ Start Test ] [[OpticalDiskDriveLetter]SetCDToZ]
VERBOSE: [azhdct2022-2]: [[OpticalDiskDriveLetter]SetCDToZ] Get-OpticalDiskDriveLetter: Using Get-CimInstance to get the drive letter of optical disk 1 in the system.
VERBOSE: [azhdct2022-2]: [[OpticalDiskDriveLetter]SetCDToZ] Perform operation 'Enumerate CimInstances' with following parameters, ''namespaceName' = root\cimv2,'className' = Win32_CDROMDrive'.
VERBOSE: [azhdct2022-2]: [[OpticalDiskDriveLetter]SetCDToZ] Operation 'Enumerate CimInstances' complete.
VERBOSE: [azhdct2022-2]: [[OpticalDiskDriveLetter]SetCDToZ] Get-OpticalDiskDriveLetter: The optical disk 1 could not be found in the system.
VERBOSE: [azhdct2022-2]: LCM: [ End Test ] [[OpticalDiskDriveLetter]SetCDToZ] in 1.3750 seconds.
PowerShell DSC resource DSC_OpticalDiskDriveLetter failed to execute Test-TargetResource functionality with error
message: The optical disk 1 could not be found in the system, so this resource has nothing to do. This resource does
not change the drive letter of mounted ISOs.
Parameter name: DiskId
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost
PowerShell DSC resource DSC_OpticalDiskDriveLetter failed to execute Test-TargetResource functionality with error
message: The optical disk 1 could not be found in the system, so this resource has nothing to do. This resource does
not change the drive letter of mounted ISOs.
Parameter name: DiskId
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost
DSC configuration
# Azure - Sets the CDRom drive to Z:
OpticalDiskDriveLetter SetCDToZ {
DiskId = 1
DriveLetter = 'Z'
}Suggested solution
Checking on the module, changing the DeviceID length from 10 to 20 seems to resolve the issue.
# Get the optical disk matching the Id
$opticalDisks = Get-CimInstance -ClassName Win32_CDROMDrive |
Where-Object -FilterScript {
-not (
$_.Caption -eq 'Microsoft Virtual DVD-ROM' -and
($_.DeviceID.Split('\')[-1]).Length -gt 20
)
}
Operating system the target node is running
OsName : Microsoft Windows Server 2022 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage : en-US
OsMuiLanguages : {en-US}
PowerShell version and build the target node is running
Name Value
---- -----
PSVersion 5.1.20348.1366
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.20348.1366
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
StorageDsc version
Name Version Path
---- ------- ----
StorageDsc 5.1.0 C:\Program Files\WindowsPowerShell\Modules\StorageDsc\5.1.0\StorageDsc.psd1