Powershell and SQL Server – 2- List SQL Server Service Name and Service Account with SMO

The Script pulls out SQL Server Service Name (Instance Name) and Service Account (Log on Account)

$SQLserverDB=@() 
$SQLserverDB=Get-Content "C:\PowershellScript\ServerList.txt"

    foreach($SqlServer in $SQLserverDB)
    {
        Write-Host "Server :"$SqlServer -ForegroundColor Yellow
        $server = New-Object Microsoft.SqlServer.Management.Smo.Server($SqlServer)
        
        $server|SELECT ServiceName,ServiceAccount,Status,PhysicalMemory |ft -AutoSize   
    }

SMO3

Leave a Reply

Your email address will not be published. Required fields are marked *