Skip to content

Commit

Permalink
Improved Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
WaelHamze committed Apr 17, 2019
1 parent 5ab1f7f commit f55a290
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function Wait-XrmOperation(
[String]$ApiUrl,
[Object]$Cred,
[String]$OperationId,
[Int]$SleepDuration = 3
[Int]$SleepDuration = 5
)
{
$completed = $false
Expand All @@ -59,7 +59,7 @@ function Wait-XrmOperation(

$OperationStatus = $OpStatus.Status

Write-Verbose "Status = $OperationStatus"
Write-Host "Status = $OperationStatus" -ForegroundColor DarkYellow

if ($OperationStatus -notin "None", "NotStarted", "Ready", "Pending", "Running", "Deleting", "Aborting", "Cancelling")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ if ($WaitForCompletion)
#Sometimes instance is created but the API still returns NOT FOUND (no other instances available).
#Added this delay to give chance for operation to progress.

Write-Verbose "Starting Initial Sleep for 30 seconds"
Write-Host "Starting Initial Sleep for 30 seconds"

Start-Sleep -Seconds 30

Write-Host "Attempting to poll for instance every $SleepDuration secs"

$provisioning = $true
while ($provisioning)
Expand All @@ -180,13 +182,20 @@ if ($WaitForCompletion)

$instance = Get-XrmInstanceByName -ApiUrl $ApiUrl -Cred $Cred -InstanceName $DomainName

$State = $instance.State

Write-Verbose "Instance State: $State"

if (($instance -ne $null) -and ($State -eq "Ready"))
if ($instance)
{
$State = $instance.State

Write-Host "Instance State: $State"

if ($State -eq "Ready")
{
$provisioning = $false
}
}
else
{
$provisioning = $false
Write-Host "$DomainName not found"
}
}
}
Expand Down

0 comments on commit f55a290

Please sign in to comment.