1 Resposta
- Mais recentes
- Mais votos
- Mais comentários
0
got it working now
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 = @(
'$driveletter = "d"'
'$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
}
$driveletter = "d" needs to be inside $commands. not sure why
respondido há 2 anos
Conteúdo relevante
- AWS OFICIALAtualizada há 3 anos
- AWS OFICIALAtualizada há 2 anos
- AWS OFICIALAtualizada há um ano
- AWS OFICIALAtualizada há 2 anos