Speicherplatz anzeigen (FreeDisk): Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) |
||
Zeile 17: | Zeile 17: | ||
param( | param( | ||
[Parameter(Position=0,mandatory=$true)] | [Parameter(Position=0,mandatory=$true)] | ||
− | [string] $ | + | [string] $ComputerName |
) | ) | ||
process { | process { | ||
− | $Volumes = (Get-Volume -CimSession $ | + | $Volumes = (Get-Volume -CimSession $ComputerName).DriveLetter |
Foreach ($Volume in $Volumes) { | Foreach ($Volume in $Volumes) { | ||
$Volume = $Volume + ":" | $Volume = $Volume + ":" | ||
− | Get-WMIObject Win32_Logicaldisk -filter "deviceid='$Volume'" -ComputerName $ | + | Get-WMIObject Win32_Logicaldisk -filter "deviceid='$Volume'" -ComputerName $ComputerName | Select PSComputername,DeviceID, |
@{Name="SizeGB";Expression={$_.Size/1GB -as [int]}}, | @{Name="SizeGB";Expression={$_.Size/1GB -as [int]}}, | ||
@{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}} | @{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}} |
Version vom 20. Juli 2018, 08:16 Uhr
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)}} } } }