I have written a script in PowerShell which creates aws ebs snapshot , its working fine without an issue , except i am not able get the Progress status at regular interval to proceed with next step in script. Until unless i dont get update that snapshot is 100% completed i cannot proceed with next step in my script which is upgrade of application. Any help is appreciated.
Import-Module -name AWSPowerShell
$CostIdValue = Read-Host "Please provide ID , e.g.:- 111"
$CostId = Get-EC2Volume -profilename xyz -region us-east-2 | ? { $_.Tags.Count -gt 0 -and $_.Tags.Key -eq "CostId" -and $_.Tags.Value -eq $CostIdValue} | Select-Object -ExpandProperty VolumeId
$snapshot = New-EC2Snapshot -profilename xyz -region us-east-2 -VolumeId $CostId
#$snapshotId = Get-EC2Volume -profilename xyz -region us-east-2 | ? { $_.Tags.Count -gt 0 -and $_.Tags.Key -eq "CostId" -and $_.Tags.Value -eq $CostIdValue} | Select-Object -ExpandProperty SnapshotId
$a = $snapshot.SnapshotId
#Write-Output $a
New-EC2Tag -profilename xyz -region us-east-2 -Resource $a -Tag @{ Key="CostId"; Value = $CostIdValue }
$i = Get-EC2Snapshot -profilename xyz -region us-east-2 | ? { $_.Tags.Count -gt 0 -and $_.Tags.Key -eq "CostId" -and $_.Tags.Value -eq "$CostIdValue"} | Select-Object -ExpandProperty State
for ($i = 1; $i -le 100; $i++ )
{
Write-Progress -Activity "Search in Progress" -Status "$i% Complete:" -PercentComplete $i;
}