none
Get Share drive size for a remote computer RRS feed

  • General discussion

  • $Servers = Get-Content -path  C:\temp\Sharelist.txt

    foreach ($Server in $Servers) 
    {
        $test= Test-Path $server

        if ($test -eq 'True')
                {
                
                   $m="{0:N2} MB" -f ((get-ChildItem $server -Recurse -force |Select length |Measure-Object -Sum Length).Sum /1MB)
                   Write-Host "$server is  $m"
                   $n = Write-Output "$server is  $m"
                   $n | Out-File -Append -FilePath "c:\temp\Shareresult.txt"  -Encoding string
                 }
      Else 
            {
                Write-Host "$server is not available"
               $t= write-output "$server is not available"

               $t | Out-File -Append -FilePath "c:\temp\Shareresult.txt"
            }
    }

    Note: Sharelist.txt contains the list of shares that you need get the size

    E.g

    \\server1\temp

    \\server2\users

    Output of the result will be temp folder with file name shareresult.txt

                
    • Edited by Khan_Bilal Friday, March 29, 2019 3:05 AM
    Friday, March 29, 2019 3:00 AM

All replies