-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path10_Initialize-EBSVolume.ps1
39 lines (28 loc) · 1.15 KB
/
10_Initialize-EBSVolume.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
.SYNOPSIS
Makes EBS volumes available (including NVMe instance store volumes).
.DESCRIPTION
Once the EBS volume is made available for use, you can access it just like any other volume.
Any data written to this file system is directed to the EBS volume and remains transparent to applications utilizing the device.
.EXAMPLE
Initialize-EBSVolume
.LINK
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-using-volumes.html
.NOTES
Copyright 2023-2024 The MathWorks, Inc.
#>
function Initialize-EBSVolume {
Write-Output 'Starting Initialize-EBSVolume...'
Stop-Service -Name ShellHWDetection
Get-Disk | Where-Object PartitionStyle -EQ 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel 'Data' -Confirm:$false
Start-Service -Name ShellHWDetection
Write-Output 'Done with Initialize-EBSVolume.'
}
try {
Initialize-EBSVolume
}
catch {
$ScriptPath = $MyInvocation.MyCommand.Path
Write-Output "ERROR - An error occurred while running script 'Initialize-EBSVolume': $ScriptPath. Error: $_"
throw
}