Speicherplatz anzeigen (FreeDisk)
Aus Wiki-WebPerfect
-> This function/script is moved to GitHub!
Zeigt alle Laufwerke und dessen freien Speicherplatz an.
Version 1
$Hostname = Read-Host "Geben Sie den Hostname des Systems an:" Get-WMIObject Win32_Logicaldisk -filter "deviceid='C:'" -ComputerName $Hostname | Select PSComputername,DeviceID, @{Name="SizeGB";Expression={$_.Size/1GB -as [int]}}, @{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}}
Version 2
Function Get-FreeDiskSpace { [CmdletBinding()] param( [Parameter(Position=0,mandatory=$true)] [string] $ComputerName ) process { $Volumes = (Get-Volume -CimSession $ComputerName).DriveLetter Foreach ($Volume in $Volumes) { $Volume = $Volume + ":" Get-WMIObject Win32_Logicaldisk -filter "deviceid='$Volume'" -ComputerName $ComputerName | Select PSComputername,DeviceID, @{Name="SizeGB";Expression={$_.Size/1GB -as [int]}}, @{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}} } } }