Created
October 18, 2017 13:25
-
-
Save jabez007/f99d62b5acf5ad78c0897451931f70f4 to your computer and use it in GitHub Desktop.
Quick PowerShell to start SQL Express service with an admin account
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
# Sometimes my SQLEXPRESS service doesnt start with the rest of my services even though it is set to automatic | |
# In order to get it started, I would have to explicity switch over to my domain admin account and kick the service | |
# This allows me to shortcut all of that | |
$PSPath = "C:\Windows\System32\WindowsPowerShell\v1.0" | |
$admin = Get-Credential; | |
$startSqlService = @' | |
$(Get-Service 'MSSQL$SQLEXPRESS').Start(); | |
'@ | |
Start-Process -WorkingDirectory $PSPath -FilePath "powershell.exe" -Credential $admin -LoadUserProfile -ArgumentList '-Command',$startSqlService; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment