Replaced deprecated Get-WmiObject calls with Get-CimInstance.

This commit is contained in:
jgehl99
2026-01-28 16:43:34 -05:00
parent 9d39ec8802
commit 6df32b6b34
+3 -3
View File
@@ -587,7 +587,7 @@ public static extern uint GetPrivateProfileSection(
Add-Type -MemberDefinition $definition -Namespace Win32 -Name Kernel32 -PassThru Add-Type -MemberDefinition $definition -Namespace Win32 -Name Kernel32 -PassThru
#Check if Hyper-V feature is installed (requires only checks the module) #Check if Hyper-V feature is installed (requires only checks the module)
$osInfo = Get-WmiObject -Class Win32_OperatingSystem $osInfo = Get-CimInstance -ClassName win32_OperatingSystem
$isServer = $osInfo.Caption -match 'server' $isServer = $osInfo.Caption -match 'server'
if ($isServer) { if ($isServer) {
@@ -3765,7 +3765,7 @@ Function Get-USBDrive {
# Check if external hard disk media is allowed and user has not specified USB drives # Check if external hard disk media is allowed and user has not specified USB drives
If ($AllowExternalHardDiskMedia -and (-not($USBDriveList))) { If ($AllowExternalHardDiskMedia -and (-not($USBDriveList))) {
# Get all removable and external hard disk media drives # Get all removable and external hard disk media drives
[array]$USBDrives = (Get-WmiObject -Class Win32_DiskDrive -Filter "MediaType='Removable Media' OR MediaType='External hard disk media'") [array]$USBDrives = (Get-CimInstance -ClassName Win32_DiskDrive -Filter "MediaType='Removable Media' OR MediaType='External hard disk media'")
[array]$ExternalHardDiskDrives = $USBDrives | Where-Object { $_.MediaType -eq 'External hard disk media' } [array]$ExternalHardDiskDrives = $USBDrives | Where-Object { $_.MediaType -eq 'External hard disk media' }
$ExternalCount = $ExternalHardDiskDrives.Count $ExternalCount = $ExternalHardDiskDrives.Count
$USBDrivesCount = $USBDrives.Count $USBDrivesCount = $USBDrives.Count
@@ -3910,7 +3910,7 @@ Function Get-USBDrive {
} }
else { else {
# Get only removable media drives # Get only removable media drives
[array]$USBDrives = (Get-WmiObject -Class Win32_DiskDrive -Filter "MediaType='Removable Media'") [array]$USBDrives = (Get-CimInstance -ClassName Win32_DiskDrive -Filter "MediaType='Removable Media'")
$USBDrivesCount = $USBDrives.Count $USBDrivesCount = $USBDrives.Count
WriteLog "Found $USBDrivesCount Removable USB drives" WriteLog "Found $USBDrivesCount Removable USB drives"
} }