Created
September 29, 2020 08:22
-
-
Save techdecline/2564dbbdd392f1bc3c4d0c003708a4fd to your computer and use it in GitHub Desktop.
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
| function Get-DockerInfo { | |
| $rtnObj = New-Object PSCustomObject | |
| if (Get-Command "docker" -ErrorAction SilentlyContinue) { | |
| $dockerArr = (docker version 2>0) -split '\n' | Select-Object -First 2 | ForEach-Object {($_ -replace "^.*:").trim()} | |
| foreach ($dockerProp in $dockerArr) { | |
| switch -regex ($dockerProp) { | |
| "^Docker.*" { | |
| $rtnObj | Add-Member -MemberType NoteProperty -Name "DockerName" -Value $dockerProp | |
| } | |
| "^\d{2}\.\d{2}\.\d{2}" { | |
| $rtnObj | Add-Member -MemberType NoteProperty -Name "DockerVersion" -Value $dockerProp | |
| } | |
| } | |
| } | |
| } | |
| else { | |
| return $null | |
| } | |
| return $rtnObj | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment