PowerSQL – Find OS and Memory Usage Details – Multi Server Script – No Input files

Multi Server script to find OS and Memory details.  It doesn’t require a text file as its input but you have to pass computer names as its parameters which are separated by comma.

function Get-OSMemory {
[string[]]$ComputerName = “.”

foreach ($Computer in $ComputerName) {
if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
Write-Verbose “$Computer online”
$OS = (Get-WmiObject -computername $computer -class Win32_OperatingSystem ).Caption
if ((Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer -ea 0).OSArchitecture -eq ’64-bit’)
$architecture = “64-Bit”
} else {
$architecture = “32-Bit”
$SystemInfo = Get-WmiObject -Class Win32_OperatingSystem -computername $Computer | Select-Object Name, TotalVisibleMemorySize, FreePhysicalMemory
$TotalRAM = $SystemInfo.TotalVisibleMemorySize/1MB
$FreeRAM = $SystemInfo.FreePhysicalMemory/1MB
$UsedRAM = $TotalRAM – $FreeRAM
$RAMPercentFree = ($FreeRAM / $TotalRAM) * 100
$TotalRAM = [Math]::Round($TotalRAM, 2)
$FreeRAM = [Math]::Round($FreeRAM, 2)
$UsedRAM = [Math]::Round($UsedRAM, 2)
$RAMPercentFree = [Math]::Round($RAMPercentFree, 2)

$OutputObj = New-Object -Type PSObject
$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
$OutputObj | Add-Member -MemberType NoteProperty -Name Architecture -Value $architecture
$OutputObj | Add-Member -MemberType NoteProperty -Name OperatingSystem -Value $OS
$OutputObj | Add-Member -MemberType NoteProperty -Name TotalRAM -Value $TotalRAM
$OutputObj | Add-Member -MemberType NoteProperty -Name FreeRAM -Value $FreeRAM
$OutputObj | Add-Member -MemberType NoteProperty -Name UsedRAM -Value $UsedRAM
$OutputObj | Add-Member -MemberType NoteProperty -Name FreeRAMPer -Value $RAMPercentFree

Execution Details:-

  1. PS:\>Get-OSMemory
  2. PS:\>Get-OSMemory  AQDBSP18
  3. PS:\>Get-OSMemory AQDBSP18,AQDBSP17,AQDBSP1

You can download the code here Code-OSMemory

Output: –



About Prashanth Jayaram

DB Technologist, Author, Blogger, Operations-Mgr at CTS, Automation Expert, Technet WIKI Ninja, MVB and Powershell Geek You can connect me via https://social.technet.microsoft.com/profile/prashanth jayaram/ http://www.sqlshack.com/author/prashanth/ https://www.tumblr.com/blog/prashantjayaram http://www.sqlservercentral.com/blogs/powersql-by-prashanth-jayaram/ http://www.toadworld.com/members/prashanthjayaram/ My Articles are published in following sites http://www.ssas-info.com/analysis-services-articles/ http://db-pub.com/ http://www.sswug.org/sswugresearch/community/
This entry was posted in PowerShell and tagged , , , . Bookmark the permalink.

2 Responses to PowerSQL – Find OS and Memory Usage Details – Multi Server Script – No Input files

  1. david says:

    Would you be interested in exchanging links?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s