Public/OS/Get-WindowsPartition.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Get-WindowsPartition { <# .SYNOPSIS Retrieves and displays detailed information about the system's OS volume and disk. .DESCRIPTION This function collects various details about the operating system's volume and disk, including free space, health status, file system, partition information, disk media type, bus type, and more. .EXAMPLE Get-VolumeSystem This command retrieves and displays detailed information about the system's OS volume and disk. .NOTES This function uses CIM instances to gather volume and disk information and may require appropriate permissions to execute. #> [CmdletBinding()] PARAM ( ) $Results = @() $OSVolume = Get-Volume -DriveLetter $env:SystemDrive.Substring(0,1) $OSPartition = Get-Partition -DriveLetter $env:SystemDrive.Substring(0,1) $OSDisk = Get-PhysicalDisk -DeviceNumber $OSPartition.DiskNumber $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ DriveLetter = $OSVolume.DriveLetter VolumeFreeSizeInGBs = [int]($OSVolume.SizeRemaining / 1GB) VolumeMaxSizeInGBs = [int]($OSVolume.Size / 1GB) VolumeHealthStatus = $OSVolume.HealthStatus VolumeFileSystem = $OSVolume.FileSystem IsBootPartition = $OSPartition.IsBoot PartitionNumber = $OSPartition.PartitionNumber PartitionSizeInGBs = [int]($OSPartition.Size / 1GB) DiskNumber = $OSDisk.DeviceID DiskMediaType = $OSDisk.MediaType DiskBusType = $OSDisk.BusType DiskUnallocatedSizeInGBs = ([int]($OSDisk.Size / 1GB)) - ([int]($OSDisk.AllocatedSize / 1GB)) DiskMaxSizeInGBs = [int]($OSDisk.Size / 1GB) DiskFirmwareVersion = $OSDisk.FirmwareVersion DiskLocation = $OSDisk.PhysicalLocation DiskModel = $OSDisk.Model DiskHealthStatus = $OSDisk.HealthStatus } RETURN $Results | Select-Object DriveLetter, VolumeFreeSizeInGBs, VolumeMaxSizeInGBs, VolumeHealthStatus, VolumeFileSystem, IsBootPartition, PartitionNumber, PartitionSizeInGBs, DiskNumber, DiskMediaType, DiskBusType, DiskUnallocatedSizeInGBs, DiskMaxSizeInGBs, DiskFirmwareVersion, DiskLocation, DiskModel, DiskHealthStatus } New-Alias -Name Get-VolumeSystem -Value Get-WindowsPartition |