- List down all your target server name at the text file at Computers.txt
- Save below script as checkDisk.ps1 format.
========================================================================
$ServerName = Get-Content "C:\Users\Desktop\Computers.txt"
foreach ($Server in $ServerName) {
Copy-Item -Path D:\software\ROIScan.vbs -Destination \\$Server\d$\software\
Copy-Item -Path D:\software\MspFixUp.vbs -Destination \\$Server\d$\software\
Copy-Item -Path D:\software\wiCollectFiles.vbs -Destination \\$Server\d$\software\
Copy-Item -Path "D:\software\run fixup.txt" -Destination \\$Server\d$\software\
}
========================================================================
This version is customize by my own use with header:
========================================================================
$ServerName = Get-Content "C:\Users\admSin_Peow_Ng\Desktop\Computers.txt"
$ConvertToGB = (1024 * 1024 * 1024)
"Server Name "+ " C drive Space" + " C drive Free Space"+ " D drive Space" + " D drive Free Space"
"===============" + " ==============" + " ==================" + " =============" + " =================="
$report = foreach ($Server in $ServerName) {
$diskC = Get-WmiObject Win32_LogicalDisk -ComputerName $Server -Filter "DeviceID='C:'" | Select-Object Size,FreeSpace
$diskD = Get-WmiObject Win32_LogicalDisk -ComputerName $Server -Filter "DeviceID='D:'" | Select-Object Size,FreeSpace
$Server +" " + (($diskC.Size/ $ConvertToGB)).tostring("###.###") + " GB " + (($diskC.FreeSpace / $ConvertToGB)).tostring("###.###")+ " GB " + (($diskD.Size / $ConvertToGB)).tostring("###.###") + " GB " + (($diskD.FreeSpace / $ConvertToGB)).tostring("###.###")+ " GB "
}
$report
========================================================================
Lastly open you Windows PowerShell and run the checkDisk.ps1 .
*if have server connection problem ,you will see the error message
if you want write the output to text file , just run the below command:
*if you write to text file then will skip the error but the output will remain no data for the server have connection problem
PS : checkDisk.ps1 > report.txt
you can just copy and paste to excel to manipulate the data.
No comments:
Post a Comment