【问题标题】:check RAM,page file, /PAE, /3GB, SQL server memory using powershell使用 powershell 检查 RAM、页面文件、/PAE、/3GB、SQL 服务器内存
【发布时间】:2011-01-24 20:17:11
【问题描述】:

我是一个 powershell 新手。

经过几天的搜索......

我整理了一个小的 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 已经有一段时间不再使用了。对于任何最近的操作系统,这将不会产生任何结果。
  • 如果在某些操作系统中不使用 boot.ini,我们在哪里包括 /PAE 和 /3GB 开关?

标签: sql-server powershell powershell-2.0


【解决方案1】:

如果您只想检查 boot.ini 文件,您可以使用 Get-Content(以防您不会遇到凭据问题)

# 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  

稍后,如果您添加一些需要在远程计算机上运行的东西,那么您将需要使用远程处理,基本上是Invoke-Command。最近出现了两个触摸远程处理的资源:

【讨论】:

  • 非常感谢您的资源。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-09-24
  • 1970-01-01
  • 2021-09-13
  • 1970-01-01
  • 2020-05-02
  • 1970-01-01
  • 2017-11-16
相关资源
最近更新 更多