Containers/Wait-ForTenantReady.ps1
function Wait-ForTenantReady { Param( [Parameter(Mandatory = $true)] [string]$containerName, [Parameter(Mandatory = $true)] [string]$tenant ) $status = "" do { try { $tenantStatus = (Get-BcContainerTenants -containerName $ContainerName -Tenant default -ForceRefresh -ErrorAction SilentlyContinue) $status = $tenantStatus.State } catch { $status = "Mounting" } if ($status -ne "Operational") { if ($status -eq "OperationalWithSyncFailure") { Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Sync-NAVTenant -ServerInstance BC -tenant $args[0] - Force } -argumentList $tenant } Start-Sleep -Seconds 2 } } while ($status -ne "Operational") } |