Powershell:从150服务器获取PowerShell中的C驱动器状态

如何以HTML格式从150台使用PowerShell的服务器获取C盘的状态。

我有这个代码

Get-WmiObject win32_logicaldisk -Computername remotecomputer 

我正在尝试获取远程服务器信息,如剩余空间和可用空间百分比,并以HTML文件格式显示。 我想在HTML文件中包含150个服务器。

将150台服务器直接或通过使用Get-Content并使用Get-Volume和ConvertTo-HTML放入一个variables中。

 $servers = "server1","server2" $props = @( "*", @{Name="Space";Expression={"$([int]($_.Size / 1024Mb)) GB"}}, @{Name='SpaceUsed';Expression={"$([int](($_.Size - $_.SizeRemaining) / 1024Mb)) GB"}}, @{Name="SpaceRemaining";Expression={"$([int]($_.SizeRemaining / 1024Mb)) GB"}}, @{Name='PercentFull';Expression={"$([int](100 - (($_.SizeRemaining / $_.Size) * 100))) %"}} ) Get-Volume -DriveLetter C -CimSession $servers | Select-Object -Property $props -ExcludeProperty *cim* | ConvertTo-Html | Out-File -FilePath $env:temp\ServerCVolumes.html 

编辑:增加剩余空间%。 Cory Knutson在我编辑我的文章之前已经免费发布了%。

这将包括可用空间百分比和以GB为单位的可读大小

 $servers = "server1","server2" $output = @() $Servers | ForEach-Object { $server = $_ $output += Get-Volume C -CimSession $_ | Select-Object @{Name="Server";Expression={$server}},` @{Name="PercentFree";Expression={$_.SizeRemaining / $_.Size}},` @{Name="RemainingReadable";Expression={"$($_.SizeRemaining / 1024Mb) GB"}},` Size,SizeRemaining,FileSystem } $output | ConvertTo-Html | Out-File C:\Report.html # OR $output | Export-Csv -NoTypeInformation -Path C:\report.csv