I'm an admin on two servers (Win 2008 R2). I have a scheduled task that copies large files from a share on one server to another. Before I do the copy, I check that the destination disk on the other server has enough free space. I've been running these tasks under my own account and want to change to a system account with lower privileges than me.
I've been using the following recipe to get the free space ratio:
PowerShell.exe Get-WmiObject Win32_LogicalDisk -ComputerName <REMOTESERVER> -Filter "DeviceID='C:'" | Foreach-Object {$_.FreeSpace / $_.Size}
It works on my account, but gives me 0x80070005 (E_ACCESS DENIED) from the non-admin account.
Should I even be using WMI for this or is there something simpler?