Hi All, this is my very first post on PowerShell Script. Today, I am
going to share a script that you can use to find out free disk space from
multiple servers. You will have to create a Text file and a PowerShell script
to accomplish this.
Let’s begin by creating a Text file. I have setup a folder on my C:
Drive called PS_Script (C:\ PS_Script). I created a Text file, ServerNames.txt,
and saved it in C:\PS_Script folder.
Use following code to create a PowerShell script and save it as
DiskReport.PS1.
#Get Current date
$currdate = (Get-Date).tostring("dd-MM-yyyy")
#Set path for output file
$report = "C:\PS_Script\" +
"DiskSpaceReport_" + "$Currdate.html"
#Run command to get free disk space from multiple servers and export output to HTML file
Get-WmiObject Win32_LogicalDisk
-filter "DriveType=3"
-computer (Get-Content
C:\PS_Script\ServerNames.txt) | Select SystemName,DeviceID,VolumeName,@{Name="Size(GB)";Expression={"{0:N1}"
-f($_.size/1gb)}},@{Name="FreeSpace(GB)";Expression={"{0:N1}"
-f($_.freespace/1gb)}} | ConvertTo-HTMl | Out-File $report
When you run above PowerShell script, it will create a HTML file in
C:\PS_Script folder. Please make sure
that you are running the PowerShell script using your admin account.
I hope you like this script.
Comments
Post a Comment