Open jdkang opened 4 years ago
The code:
41 $pdisk = Get-PhysicalDisk -ErrorAction SilentlyContinue | Where-Object {
42 $_.DeviceId -eq $disk.Number
The filter also picks up multiple disks when there are disks without a number and physical disks without a DeviceID
PS > Get-Disk
Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition Style
0 Virtual HD Healthy Online 61 GB MBR 1 Virtual HD Healthy Online 7 GB MBR 3 Msft Virtual Disk Healthy Online 256 GB RAW 2 Msft Virtual Disk Healthy Online 15 GB GPT 4 Msft Virtual Disk Healthy Online 256 GB RAW Msft Virtual Disk Healthy Online 15 GB GPT
PS > Get-PhysicalDisk | ft -auto DeviceId, FriendlyName, Size
DeviceId FriendlyName Size
2 Msft Virtual Disk 16106127360 0 Virtual HD 65498251264 1 Virtual HD 7516192768 Msft Virtual Disk 274877906944 Msft Virtual Disk 274877906944
SUMMARY
module
win_disk_facts
throws an error when multiple physical disks exists for a givenDeviceID
Specifically, line 73 calling
$vdisk = Get-VirtualDisk -PhysicalDisk $pdisk -ErrorAction SilentlyContinue
wherein$pdisk
is an object array rather than a single CIM instance.Note that I can reproduce this by hand by logging into the server and executing the relevant commands/logic.
ISSUE TYPE
COMPONENT NAME
win_disk_facts.ps1
ANSIBLE VERSION
2.9.2
CONFIGURATION
OS / ENVIRONMENT
Windows 6.3.9600.0 (Server 2012)
STEPS TO REPRODUCE
Given the following setup:
The problem is specifically that the filter logic picks up multiple physical disks with the same
DeviceID
EXPECTED RESULTS
Not to error out.
ACTUAL RESULTS
Throws an exception