$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 bloghttp://sqlps.io
PASS PowerShell Virtual Chapter http://sqlps.io/slack
SQL Community Slack Channelhttp://sqlps.io/vote
Help Microsoft prioritise improvements to sqlserver PowerShell modulehttp://dbatools.io
The Best PowerShell Module for the Modern SQL DBAhttp://dbareports.io
PowerShell, SQL, SSRS, PowerBi and Cortana to report on your estate http://sqlps.io/video
PASS PowerShell Virtual Chapter YouTube Channel - Subscribe to get notified of new videos
SQL South West UK User Grouphttp://sqlsouthwest.co.uk/