amazon ec2 - AWS, EC2 Instance, Windows, Userdata not able to set disk online with script - Stack Overflow

admin2025-03-19  0

I have EC2 instance with template on cloudformation on AWS and if anything fails or instance is terminated my template created new instance with latest EBS backup. But this attached voleme to newly created instance is not online on the server(windows). I tried 2 different userdata scripts for setting mz volume online and none of this works. Can anyone help me where i'm doing misstake:

This is my old code

$secondDisk = (Get-Disk | Select-Object -Skip 1 -First 1).DiskNumber
Set-Disk -Number $secondDisk -IsOffline $false
sleep 5
Set-Disk -InputObject $(Get-Disk -Number 1) -IsReadOnly $false
echo "Volume - $volumeId back ONLINE."

This is my new code

$secondDisk = (Get-Disk | Select-Object -Skip 1 -First 1).DiskNumber
Set-Disk -Number $secondDisk -IsOffline $false
echo "Disk $secondDisk is now online."
Set-Disk -InputObject (Get-Disk -Number $secondDisk) -IsReadOnly $false
echo "Disk $secondDisk is no longer ReadOnly."
echo "Disk $secondDisk is now ready to be used with existing data."

Thanks for advice

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1742363547a209754.html

最新回复(0)