Below is an example using the PowerShell SDK . The below has also been added to the new Microsoft Platform GuidePowerShell section.
[crayon-68130d043791c297833674/]
[crayon-68130d0437927853865495/]
The below PowerShell script example removes the manual task of picking a specific PGroup snapshot like in Part 1.
12345678910 | # Connect to FlashArray.$f = New-PfaArray -EndPoint 10.0.0.1 -Credentials (Get-Credential) -IgnoreCertificateError# Get latest PGroup Snapshots.$psoPGroup = Get-PfaAllVolumeSnapshots -Array $f | where {$_.Source -like “*Barkz-Bootlun-06-WS2016-DC-GUI-6*” -and $_.Name -like “*z-nightly-replica-to-PureTEC*”}ForEach ($PGroupSnapshot in $psoPGroup) { If ([DateTime]($PGroupSnapshot.created) -gt (get-date).addHours(-8)) { Write-Host $PGroupSnapshot.name ” — “ $PGroupSnapshot.created }} |
Note: You will notice that the Get-PfaAllVolumeSnapshots does not return a PSObject and the “created” field is returned as a string. Using [DateTime] I convert the string to a datetime and then compare that to get snapshots >8hrs.
Output:
12 | z–nightly–replica–to–PureTEC.158.Barkz–Bootlun–06–WS2016–DC–GUI–6 — 2017–10–20T15:49:00Zz–nightly–replica–to–PureTEC.159.Barkz–Bootlun–06–WS2016–DC–GUI–6 — 2017–10–20T17:39:00Z |
Updated Information:
To align with the latest advancements, consider the following updates:
1. Utilizing the Latest PowerShell SDK:
- Installation: Ensure you have the latest version of the Pure Storage PowerShell SDK installed:powershellCopyEdit
Install-Module -Name PureStorage.FlashArray -Force -AllowClobber
- Connecting to the FlashArray:powershellCopyEdit
$FlashArray = Connect-PfaArray -EndPoint "your_flasharray_ip" -UserName "your_username" -Password "your_password"
2. Creating Volumes from Protection Group Snapshots:
- Listing Protection Group Snapshots:powershellCopyEdit
# Retrieve all protection group snapshots $PgroupSnapshots = Get-PfaProtectionGroupSnapshot -Array $FlashArray
- Creating a New Volume from a Snapshot:powershellCopyEdit
# Specify the source snapshot and new volume name $SourceSnapshot = "pgroup_name.snapshot_name" $NewVolumeName = "new_volume_name" # Create the new volume New-PfaVolume -Array $FlashArray -Source $SourceSnapshot -VolumeName $NewVolumeName
3. Implementing Per-Protection Group SafeMode:
- Enabling SafeMode on a Protection Group: With the introduction of per-protection group SafeMode, you can now enable SafeMode on specific protection groups to enhance data protection:powershellCopyEdit
# Enable SafeMode on a protection group Enable-PfaProtectionGroupSafeMode -Array $FlashArray -ProtectionGroupName "pgroup_name"
- Benefits:
- Prevents deletion or modification of snapshots within the protection group.
- Provides granular control over data protection settings.
Conclusion:
By updating to the latest PowerShell SDK and leveraging new features like per-protection group SafeMode, administrators can enhance their data protection strategies and streamline the process of creating volumes from protection group snapshots.