Last active
May 5, 2021 02:08
-
-
Save phillipsj/7f5b012e8107c7d95f00bf3fbe261116 to your computer and use it in GitHub Desktop.
PowerShell script to use with Docker and custom script extension.
This file contains 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
[CmdletBinding()] | |
param ( | |
[Parameter(Position = 0)] | |
[String] | |
$Command | |
) | |
Write-Host "It started" | |
if (Get-Service 'Docker' -ErrorAction SilentlyContinue) { | |
Write-Host "Checking Docker" | |
if ((Get-Service Docker).Status -ne 'Running') { Start-Service Docker } | |
while ((Get-Service Docker).Status -ne 'Running') { Start-Sleep -s 5 } | |
Write-Host "Running command" | |
Start-Process -NoNewWindow -FilePath "docker.exe" -ArgumentList "$($Command)" | |
exit 0 | |
} | |
else { | |
Write-Host "Docker Service was not found!" | |
exit 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment