Module/ContainerHandling/Import-BCSLicensFileToRunningContainers.ps1
<#
.SYNOPSIS .DESCRIPTION .EXAMPLE .NOTES Author: Mathias Stjernfelt Website: http://www.brightcom.se #> function Import-BCSLicensFileToRunningContainers { Param( [Parameter(Mandatory = $true)] [String] $ContainerName, [Parameter(Mandatory = $true)] [String] $LicenseFileURI ) try { $containers = docker container ls -a --no-trunc --format "{{json .Names}}" | ConvertFrom-CSV -Header "Name" $containers | ForEach-Object { $ContainerName = [String]$_.Name $inspect = Docker inspect $ContainerName | ConvertFrom-Json if ($inspect.State.Status -eq 'running') { Write-Host ("Updateing licens for Container {0}" -f $ContainerName) -ForegroundColor Green Import-BcContainerLicense -containerName $ContainerName -licenseFile $LicenseFileURI } } $containers = docker container ls -a --no-trunc --format "{{json .Names}}{{json .Status}}" | ConvertFrom-CSV -Header "Name", "Status" $containers | Format-Table -Property Name, Status } catch { throw "An error occured: $_.Exception"; } } Export-ModuleMember -Function Import-BCSLicensFileToRunningContainers |