Lets assign the results of our “anything” name SQL request into a variable called “$sqlservices” $sqlservices = Get-service -ComputerName VMServer01 -Name '*SQL*' In order to deal with multiple services and/or instances we can assign the results to a variable and work with that instead of all this repeating code. ( Get-service -ComputerName VMServer01 -Name 'MSSQL$VMSQL01' ).DisplayName Multiple Services Status and StartupType ( Get-service -ComputerName VMServer01 -Name 'MSSQL$VMSQL01' ).StartType ( Get-service -ComputerName VMServer01 -Name 'MSSQL$VMSQL01' ).Status ( Get-service -ComputerName VMServer01 -Name 'MSSQL$VMSQL01' ).DependentServices Try the following: ( Get-service -ComputerName VMServer01 -Name 'MSSQL$VMSQL01' ).MachineName ![]() I like to assign the results to a variable and work with it using the dot notation but we can also just add parenthesis. There is more that we can collect from the objects returned by this cmdlet. If you are working with a default instance than the name will just be MSSQLSERVER. Also note that I had to use the single quotes because of the dollar sign ($) identifying the SQL instance. The DependantServices option goes the other way and shows what services depend on the specified. You will notice here the SQL Agent has a requirement for the SQL Service but MSSQL does not. Get-service -ComputerName VMServer01 -Name 'MSSQL$VMSQL01' -DependentServices Get-service -ComputerName VMServer01 -Name 'MSSQL$VMSQL01' -RequiredServices We can find the service dependencies easily: Get-service -ComputerName VMServer01 -Name 'SQLAgent$VMSQL01' -RequiredServices One last option you should be aware of is certain services have dependencies such as the SQL Agent which needs SQL Service to be running for example. Then when you have it you can complete the name and retrieve only that services details. In this case the asterisk is useful to find multiple services where you are not sure of the exact name. Get-service -ComputerName VMServer01 -Name 'MSSQL$VMSQL01' ![]() Get-service -ComputerName VMServer01 -Name SQLBrowser What if we want to see only the SQL services or just one service by name? Get-service -ComputerName VMServer01 -Name *SQL* Find whether Salesforce instance is Up and Active Get-service -ComputerName VMServer01Īs you can see this is simple and useful for a single machine if you want to browse the running services.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |