Skip to content

Instantly share code, notes, and snippets.

@jabez007
Created October 18, 2017 13:25
Show Gist options
  • Save jabez007/f99d62b5acf5ad78c0897451931f70f4 to your computer and use it in GitHub Desktop.
Save jabez007/f99d62b5acf5ad78c0897451931f70f4 to your computer and use it in GitHub Desktop.
Quick PowerShell to start SQL Express service with an admin account
# 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