Last active
June 18, 2021 02:12
-
-
Save kewalaka/d13d3d1cf12a1e2857c9dbfdd80b45b9 to your computer and use it in GitHub Desktop.
This will set the service dependency of the SQL Service database engine to include netlogon and w32tm, this can help when a GMSA is used to make sure AD is available from the machine before the service is started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $dependencies = @('netlogon', 'w32time') | |
| # to remove: | |
| #$dependencies = @('') | |
| Get-CimInstance –Query 'select * from Win32_Service where name like "mssql%"' | foreach { | |
| $serviceCimInstance = $_ | |
| $serviceName = $_.name | |
| write-host "Apply service dependencies '$dependencies' to: $serviceName" | |
| $changeServiceResult = Invoke-CimMethod ` | |
| -InputObject $serviceCimInstance ` | |
| -MethodName 'Change' ` | |
| -Arguments @{ ServiceDependencies = $Dependencies } | |
| if ($changeServiceResult.ReturnValue -ne 0) { | |
| throw "Failed to apply service dependencies '{0}' to: '{1}'. Error: {2}" -f $dependencies, $serviceName, $_.Exception | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the dependencies on some database engines include the 'keyIso' service, which is hosted in the lsass.exe process.
the above also picks up the free text filter, the query needs some adjustment