最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin10PV0评论

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

Post a comment

comment list (0)

  1. No comments so far