check RAM,page file, /PAE, /3GB, SQL server memory using powershell

Posted by Manjot on Stack Overflow See other posts from Stack Overflow or by Manjot
Published on 2010-03-08T03:46:42Z Indexed on 2010/03/08 3:51 UTC
Read the original article Hit count: 443

I am a powershell novice.

After days of searching....

I have put together a small powershell script (as below) to check page file, /PAE switch, /3GB switch, SQL server max RAM, min RAM. I am running this on 1 server.

If I want to run it on many servers (from a .txt) file, How can I change it ? How can I change it to search boot.ini file's contents for a given server?

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" 

Any comments how this can be improved?

Thanks in advance

© Stack Overflow or respective owner

Related posts about powershell

Related posts about powershell-v2.0