Private/Disk/Get-OSDDrive.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
<#
.SYNOPSIS Similar to Get-PSDrive, but adds IsUSB and IsNetwork Property .DESCRIPTION Similar to Get-PSDrive, but adds IsUSB and IsNetwork Property .LINK https://osd.osdeploy.com/module/functions/disk/get-osddrive .NOTES 21.3.5 Initial Release #> function Get-OSDDrive { [CmdletBinding()] param ( [string]$IsLocal ) #================================================= # PSBoundParameters #================================================= $IsConfirmPresent = $PSBoundParameters.ContainsKey('Confirm') $IsForcePresent = $PSBoundParameters.ContainsKey('Force') $IsVerbosePresent = $PSBoundParameters.ContainsKey('Verbose') #================================================= # OSD Module and Command Information #================================================= $OSDVersion = $($MyInvocation.MyCommand.Module.Version) Write-Verbose "OSD $OSDVersion $($MyInvocation.MyCommand.Name)" #================================================= # Get Variables #================================================= $GetOSDDrive = Get-PSDrive | Select-Object -Property * $GetOSDVolume = Get-Volume.osd | Select-Object -Property * #================================================= # Add Property IsUSB #================================================= foreach ($Item in $GetOSDDrive) { if ($Item.Name -in ($GetOSDVolume | Where-Object {$_.IsUSB -eq $true}).DriveLetter) { $Item | Add-Member -NotePropertyName 'IsUSB' -NotePropertyValue $true -Force } else { $Item | Add-Member -NotePropertyName 'IsUSB' -NotePropertyValue $false -Force } } #================================================= # Add Property IsNetwork #================================================= foreach ($Item in $GetOSDDrive) { if ($Item.DisplayRoot -match "\\") { $Item | Add-Member -NotePropertyName 'IsNetwork' -NotePropertyValue $true -Force } else { $Item | Add-Member -NotePropertyName 'IsNetwork' -NotePropertyValue $false -Force } } #================================================= # Return #================================================= Return $GetOSDDrive | Sort-Object Name | Select-Object Name, Root, DisplayRoot, Provider, IsNetwork, IsUSB, Used, Free, Description #================================================= } |