About Me

My photo
I am an MCSE in Data Management and Analytics, specializing in MS SQL Server, and an MCP in Azure. With over 19+ years of experience in the IT industry, I bring expertise in data management, Azure Cloud, Data Center Migration, Infrastructure Architecture planning, as well as Virtualization and automation. I have a deep passion for driving innovation through infrastructure automation, particularly using Terraform for efficient provisioning. If you're looking for guidance on automating your infrastructure or have questions about Azure, SQL Server, or cloud migration, feel free to reach out. I often write to capture my own experiences and insights for future reference, but I hope that sharing these experiences through my blog will help others on their journey as well. Thank you for reading!

How to Retrieve MSSQLSERVER or SQL Server engine running on a set of Servers.

How to Retrieve MSSQLSERVER  or SQL Server engine running on a set of Servers.





Create a Notepad file and add all server name

Save the file in C:\Temp Folder


.\Get-SQLServer.ps1 -ComputerList "Computer.txt"

Save the powershell script with name "Get-SQLServer.ps1" in C:\Temp folder.

#Requires -Version 2.0

param
(
[Parameter(Position=0,ValuefromPipeline=$true)][string][alias("cn")]$computer,
[Parameter(Position=1,ValuefromPipeline=$false)][string]$computerlist
)

If (-not ($computer -or $computerlist))
{
$computers = $Env:COMPUTERNAME
}

If ($computer)
{
$computers = $computer
}

If ($computerlist)
{
$computers = Get-Content $computerlist
}

foreach ($computer in $computers)
{
$object = Get-WmiObject win32_service -ComputerName $computer  | where {($_.name -like "MSSQL$*" -or $_.name -like "MSSQLSERVER" -or $_.name -like "SQL Server (*") -and $_.name -notlike "*helper*" -and $_.name -notlike "*Launcher*"}
if ($object)
{
write-host "####################Retrieving Details for Computer:  $computer" -ForegroundColor Green
$instInfo= $object | select Name,StartMode,State, Status
$instInfo
}else
{
 Write-Host "No instance found!"
 }
}

No comments: