$SQL = Get-Service -ComputerName $server -name *sql* if i run this not returning anything, can you suggest me what i would need to change.
That is setting the services whose name contains SQL to a variable
You would then call $SQL and it would show
Status Name DisplayName
------ ---- -----------
Running msftesql SQL Server FullText Search (MSSQLSE...
Running MSSQLSERVER SQL Server (MSSQLSERVER)
Stopped MSSQLServerADHe... SQL Server Active Directory Helper
Stopped SQLBrowser SQL Server Browser
Running SQLSERVERAGENT SQL Server Agent (MSSQLSERVER)
Running SQLWriter SQL Server VSS Writer
(on a 2005 box)
If you just wanted the SQL Server Database Engine Service then run
Get-Service -ComputerName $Server -name "MSSQLSERVER"
The better bet for you right now would be to run
Get-Service -ComputerName $Server
on the server and look at the list of services. You can then work out the correct name to choose for your query.
Your other question probably should be asked in a separate thread but if you put the cluster nodes into the sqlserverstxt file and run your script from this thread it will show you which cluster is running SQL and which services
Its where I blog
PASS PowerShell Virtual Group http://sqlps.io
SQL Community Slack Channel http://sqlps.io/slack
The Best PowerShell Module for the Modern SQL DBA http://dbatools.io
PASS PowerShell Virtual Group YouTube Channel - Subscribe to get notified of new videos http://sqlps.io/video
SQL South West UK User Group http://sqlsouthwest.co.uk/