Check RAM, page file, PAE, / 3GB, SQL server memory with powershell

I am a beginner novice.

After days of searching ....

I put together a small powershell script (as shown below) to check the page file, / PAE switch, / 3GB switch, SQL maximum RAM, min. RAM I run this on 1 server.

If I want to run it on many servers (from .txt), how can I change it? How can I change it to search for the contents of the boot.ini file for this 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 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 on how this can be improved?

Thanks in advance

+4
source share
1 answer

If you just want to check the boot.ini file, you can use Get-Content (in case you don't have credential problems)

 # 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 of the things you need to run on a remote computer, then you will need to use remote access and basically Invoke-Command . Recently, two resources have appeared that relate to remote objects:

+1
source

Source: https://habr.com/ru/post/1303429/


All Articles