views:

380

answers:

1

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

+1  A: 

In case you would like just to check the boot.ini file you could use Get-Content (in case you will not have problems with credentials)

# create a test file with server names
@"
server1
server2
"@ | set-content c:\temp\serversso.txt

# read the file and get the content
get-content c:\temp\serversso.txt | 
    % { get-content "\\$_\c`$\boot.ini" } |
    Select-String "/3GB" -Quiet  

Later if you add some stuff that will be needed to run on remote computer then you will need to use remoting and basically Invoke-Command. Recently two resources appeared that touch remoting:

stej
Thanks very much for the resources.
Manjot