I want to run a PowerShell command if drive has X amount free storage capacity.
using following command we can get the free space information.
gwmi Win32_LogicalDisk -Filter "DeviceID='D:'" | Select-Object {$_.FreeSpace/1gb}
i tried like this
$space = gwmi Win32_LogicalDisk -Filter "DeviceID='C:'" | Select-Object {$_.FreeSpace/1gb}
If ($space -gt 10) {
Copy-Item -Path "C:\1\*" -Destination "C:\2\" -recurse -Force -Verbose
}
Sorry I have very limited knowledge about PowerShell. i getting error objects are not the same type
. I think it's because $space
giving text name information before the digit.