Skip to content

Instantly share code, notes, and snippets.

@phillipsj
Last active May 5, 2021 02:08
Show Gist options
  • Save phillipsj/7f5b012e8107c7d95f00bf3fbe261116 to your computer and use it in GitHub Desktop.
Save phillipsj/7f5b012e8107c7d95f00bf3fbe261116 to your computer and use it in GitHub Desktop.
PowerShell script to use with Docker and custom script extension.
[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