I can not get the Hyper-V / vMWare drive type part to work and gave my self a migrain looking at it, PLEASE HELP!.
##============================================================================== ## START ##============================================================================== #> clear #---------- Configurations - Start. # $cre = get-Credential # This user account should be Adminstrator. $Servers = get-Content "list.txt" # Replace this with your TXT file containg Server names. # Do not change below this line. $OS = (gwmi win32_operatingsystem).caption $MediaType = gwmi -Class MSFT_PhysicalDisk -Namespace root\Microsoft\Windows\Storage $HVDrive = Get-VMHardDiskDrive | Where-Object { $_.DriveType -eq 1 } $LogicalDisks = gwmi Win32_LogicalDisk | Where-Object { $_.DriveType -eq 2 } $LocalHDisks = $LogicalDisks | Where-Object { $_.DriveType -eq 3 } $RemoteDrives = gwmi Win32_LogicalDisk | Where-Object { $_.DriveType -eq 4 } $OpticalDrives = gwmi Win32_CDRomDrive | Where-Object { $_.DriveType -eq 5 } $HVDrive = Get-VM | Select-Object VMID | Get-VHD | Select-Object VhdFormat # Do not change above this line. $Records = 1000 # Sets Max Records $CSV = "DiskSpaceReport_$(((get-date).ToUniversalTime()).ToString("yyyy-MM-dd")).csv" # File to export to. #---------- Configurations - End. Clear-Host #---------- The report - Start. Write-Host " Your Report started at: $(((get-date).ToUniversalTime()).ToString("yyyy-MM-dd"))." #---------- Wright to File - Start. #Get-WmiObject Win32_LogicalDisk -filter 'DriveType=3' -computerName $servers | ## use this if you want to show only Drive Type 3 drives. Get-WmiObject Win32_LogicalDisk -computerName $servers | Select-Object ` SystemName, DeviceID, VolumeName, @{N='Size(MB)';E={ '{0:N2}' -f ($_.Size/1MB) }}, @{N='FreeSpace(MB)';E={ '{0:N2}' -f ($_.FreeSpace/1MB) }}, @{N='Used(MB)';E={ '{0:N2}' -f (($_.Size-$_.FreeSpace)/1MB) }}, @{N='PercentFree';E={ '{0:P2}' -f ($_.FreeSpace/$_.Size) }}, @{N='PercentUsed';E={ '{0:P2}' -f (($_.Size-$_.FreeSpace)/$_.Size) }}, @{N="Drive Type";E={switch ($_.DriveType) { 0 {"(unknown)"} 2 {"USB/FD"} 3 {"HDD"} 4 {"SSD"} 5 {"CD/DVD/BD"} 6 {"RAM disk"}}}}, @{N="VM Drv";E={if($hvdrive) {$_VhdFormat}else{'no VM Disk'}}}, @{N="Operating System";E={$OS}}, @{N='Free Space (Warning)';E={if($_.FreeSpace/$_.Size -lt .10){'Below 10%'}else{'GOOD'}}} | Export-CSV $CSV -NoTypeInformation -Encoding UTF8 | Format-Table -AutoSize #---------- Wright to File - END. #---------- Wright to Screen - Start. #Get-WmiObject Win32_LogicalDisk -filter 'DriveType=3' -computerName $servers | ## use this if you want to show only Drive Type 3 drives. Get-WmiObject Win32_LogicalDisk -computerName $servers | Select-Object ` SystemName, DeviceID, VolumeName, @{N='Size(MB)';E={ '{0:N2}' -f ($_.Size/1MB) }}, @{N='FreeSpace(MB)';E={ '{0:N2}' -f ($_.FreeSpace/1MB) }}, #@{N='Used(MB)';E={ '{0:N2}' -f (($_.Size-$_.FreeSpace)/1MB) }}, @{N='PercentFree';E={ '{0:P2}' -f ($_.FreeSpace/$_.Size) }}, #@{N='PercentUsed';E={ '{0:P2}' -f (($_.Size-$_.FreeSpace)/$_.Size) }}, @{N="Drive Type";E={switch ($_.DriveType) { 0 {"(unknown)"} 2 {"(USB/FD)"} 3 {"HDD"} 4 {"SSD"} 5 {"CD/DVD/BD"} 6 {"RAM disk"}}}}, @{N="VM Drv";E={if($hvdrive) {$_VhdFormat}else{'no VM Disk'}}}, @{N="Operating System";E={$OS}}, @{N='Above 10%';E={if($_.FreeSpace/$_.Size -lt .10){'Below 10%'}else{'GOOD'}}} | Write-Output | Format-Table #---------- Wright to Screen - END. # Show Progress Bar - START for($i = 1; $i -lt 101; $i++ ) {write-progress Updating progress-> -perc $i} for($i = 1; $i -lt 101; $i++ ) { write-progress Updating progress -percentcomplete $i -id 1} # Show Progress Bar - END Write-Host " Your Report finished at: $(((get-date).ToUniversalTime()).ToString("yyyy-MM-dd"))." #---------- The Report - End.