我是PowerShell新手。使用powershell檢查RAM,頁面文件,/ PAE,/ 3GB,SQL服務器內存
搜索後幾天....
我已經把一個小的PowerShell腳本(如下),以檢查頁面文件,/ PAE開關,/ 3GB開關,SQL服務器最大RAM,RAM最小。 我正在1臺服務器上運行。
如果我想在很多服務器上(從.txt文件)運行它,我該如何改變它? 如何更改它以搜索給定服務器的boot.ini文件內容?
clear
$strComputer="."
$PageFile=Get-WmiObject Win32_PageFile -ComputerName $strComputer
Write-Host "Page File Size in MB: " ($PageFile.Filesize/(1024*1024))
$colItems=Get-WmiObject Win32_PhysicalMemory -Namespace root\CIMv2 -ComputerName $strComputer
$total=0
foreach ($objItem in $colItems)
{
$total=$total+ $objItem.Capacity
}
$isPAEEnabled =Get-WmiObject Win32_OperatingSystem -ComputerName $strComputer
Write-Host "Is PAE Enabled: " $isPAEEnabled.PAEEnabled
Write-Host "Is /3GB Enabled: " | Get-Content C:\boot.ini | Select-String "/3GB" -Quiet
# how can I change to search boot.ini file's contents on $strComputer
$smo = new-object('Microsoft.SqlServer.Management.Smo.Server') $strSQLServer
$memSrv = $smo.information.physicalMemory
$memMin = $smo.configuration.minServerMemory.runValue
$memMax = $smo.configuration.maxServerMemory.runValue
## DBMS
Write-Host "Server RAM available: " -noNewLine
Write-Host "$memSrv MB" -fore "blue"
Write-Host "SQL memory Min: " -noNewLine
Write-Host "$memMin MB "
Write-Host "SQL memory Max: " -noNewLine
Write-Host "$memMax MB"
任何評論如何可以改善?
在此先感謝
但請記住,這BOOT.INI是不是現在不再使用了一段時間。對於任何最近的操作系統,這隻會產生任何東西 – Joey 2010-03-08 11:03:52
如果在某些操作系統中未使用boot.ini,那麼我們將包含/ PAE和/ 3GB開關? – Manjot 2010-03-08 19:44:27