Questions tagged with Amazon EC2

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

resize windows drive with aws ssm

trying to use this script to resize a volume ``` Param ( [string][Parameter(Mandatory = $True)] $VolumeId, [string][Parameter(Mandatory = $True)] $driveletter, [int][Parameter(Mandatory = $True)] $NewSize ) $CurrentSize = Get-EC2Volume -Volume $VolumeId If ($NewSize -lt $CurrentSize.Size) { Write-Host "New volume must be larger than current" -ForegroundColor Red; break} Edit-EC2Volume -VolumeId $VolumeId -Size $NewSize | Out-Null $ModifiedSize = (Get-EC2Volume -Volume $VolumeId).Size While ($ModifiedSize -ne $NewSize) { Start-Sleep 5 $ModifiedSize = (Get-EC2Volume -Volume $VolumeId).Size } Write-Host "" Write-Host "Volume:$VolumeId is resized to size:$NewSize" -ForegroundColor Green $InstanceId = (Get-EC2Volume -Volume $VolumeId | Select-Object -ExpandProperty Attachments)[0].InstanceId write-output $driveletter $Commands = @( '$DiskNumber = (Get-Partition -DriveLetter $driveletter).DiskNumber', 'Update-Disk -Number "$DiskNumber"', '$Size = Get-PartitionSupportedSize -DriveLetter $driveletter', 'Resize-Partition -DriveLetter $driveletter -Size $Size.SizeMax' ) $Parameter = @{ commands = $Commands } $Document = 'AWS-RunPowerShellScript' Write-Host "" Write-Host "Extending $driveletter : drive..." -ForegroundColor Green Try { $Cmd = Send-SSMCommand -DocumentName $Document -Parameter $Parameter -InstanceId $InstanceId While ($Cmd.Status -ne 'Success') { $Cmd = Get-SSMCommand -CommandId $Cmd.CommandId Start-Sleep 5 } Write-Host "" Write-Host $driveletter ": drive is extended" -ForegroundColor Green } Catch { Write-Host "" Write-Host "Failed to extend drive" -ForegroundColor Red } ``` but keep getting Failed to extend drive when extending the windows part
1
answers
0
votes
14
views
drago
asked 7 days ago