How to get Disk space of another machine(connected in LAN)

i’ve to code(powershell) get my system disk space.


    [Parameter(Mandatory=$true)] [string]$OutputFilePath

Get-WmiObject -Class Win32_logicaldisk -Filter "DeviceID = 'C:'" | 
Select-Object -Property DeviceID, DriveType, PSComputerName, 
@{L='FreeSpaceGB';E={"{0:N2}" -f ($_.FreeSpace /1GB)}},
@{L="Capacity";E={"{0:N2}" -f ($_.Size/1GB)}} | out-file -Filepath $OutputFilePath
Start-sleep 3

I wan’t the another machine’s disk space.

help me.

thanks in advance
Michael Udhaya

Hi @Michael_Udhaya

Try this command ```
Get-PSDrive D | Select-Object Used,Free


Ashwin S

You can add -ComputerName remotecomputername to your Get-WmiObject command…

Hi bcorrea,

already tried that
Invoke-Command -ComputerName <myIpAddress> -ScriptBlock { <myScript> } -credential <myDomainUserName>

It throws the access denied.