Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

This Script shows free space of disk

$
0
0

Hi ,

i also want to have one more coloum showing used space of disk. how much spaced is used by software etc

can you help me with that 

 

foreach ($ComputerName in (Get-Content -Path C:\servers.txt))

{

    $hostname = Get-WmiObject Win32_Computersystem -ComputerName $ComputerName |

    Select-Object -ExpandProperty Name

$IP = [System.Net.Dns]::GetHostAddresses($computername)

 

    $disks = Get-WmiObject Win32_LogicalDisk  |

    foreach {

"$($_.DeviceID) $("{0:n2}" -f ( $_.FreeSpace/ 1GB ) )"

 

    }

 

    $Os = Get-WmiObject -ComputerName $ComputerName -Class Win32_OperatingSystem 

    $lastBoot = $os.ConvertToDateTime($os.LastBootUpTime)

    $uptime = New-TimeSpan -Start $lastBoot

 

    New-Object -TypeName psObject -Property @{ 

 

IP= $IP

Hostname = $hostname

        Disks = $disks   

        Uptime = $Uptime

    } |Out-File C:\Uptime.txt -Append -Encoding ascii   

}


Viewing all articles
Browse latest Browse all 8411

Trending Articles