بررسی فضای دیسک در کامپیوترهای راهدور
اول از همه باید بگوییم که این اسکریپت در هر دستگاهی کار نمیکند. و مورد استفاده آن تنها درWindows 10، Windows Server 2012 ، Windows Server 2012 R2،Windows Server 2008، Windows Server 2008 R2 و Windows 7 است. به نظر میرسد که این اسکریپت در ویندوز 8 و ویندوز 8.1 کار کند، اما هنوز آزمایش نشده است.
در ابتدا کار را با دانلود این فایل اسکریپت پاول شل از TechNet آغاز میکنیم. فقط کافیست آن را در کامپیوتر خود ذخیره کنید.
سپس این فایل را با استفاده از Notepad باز کنید، کدی شبیه به کد زیر را خواهید دید:
<# .Synopsis Gets Disk Space of the given remote computer name .DESCRIPTION Get-RemoteComputerDisk cmdlet gets the used, free and total space with the drive name. .EXAMPLE Get-RemoteComputerDisk -RemoteComputerName "abc.contoso.com" Drive UsedSpace(in GB) FreeSpace(in GB) TotalSpace(in GB) C 75 52 127 D 28 372 400 .INPUTS Inputs to this cmdlet (if any) .OUTPUTS Output from this cmdlet (if any) .NOTES General notes .COMPONENT The component this cmdlet belongs to .ROLE The role this cmdlet belongs to .FUNCTIONALITY The functionality that best describes this cmdlet #>
function Get-RemoteComputerDisk
{
Param
(
$RemoteComputerName="The Address Goes Here"
)
Begin
{
$output="Drive `t UsedSpace(in GB) `t FreeSpace(in GB) `t TotalSpace(in GB) `n"
}
Process
{
$drives=Get-WmiObject Win32_LogicalDisk -ComputerName $RemoteComputerName
foreach ($drive in $drives){
$drivename=$drive.DeviceID
$freespace=[int]($drive.FreeSpace/1GB)
$totalspace=[int]($drive.Size/1GB)
$usedspace=$totalspace - $freespace
$output=$output+$drivename+"`t`t"+$usedspace+"`t`t`t`t`t`t"+$freespace+"`t`t`t`t`t`t"+$totalspace+"`n"
}
}
End
{
return $output
}
}
حال باید آدرس کامپیوتر راه دور خود را در فضای مشخص شده در داخل نقل قول -The Address Goes Here- وارد کنید.
روی فایل راست کلیک کنید و سپس گزینه Run with Poweshell را انتخاب کنید. اگر پیغام UAC یا User Account Control Prompt را مشاهده کردید کلید Yes را فشار دهید. اکنون خروجی ترمینال پاور شکل را با همان فرمتی که با آن آشنایی دارید همانند تصویر زیر مشاهده خواهید کرد.
از این پس هر زمان که نیاز داشتید، این توانایی را دارید تا فایل فوق را اجرا کنید.