Overwriting a Volume in Windows Server

I have been asked the question about how do you overwrite a volume using the PowerShell SDK that is connected from a Windows Server a few times so here is how its done!

In this example I have a Windows Server 2016 system that has several volumes connected using Fibre Channel, the same steps apply if you are using iSCSI. The volume that I will be working with is PSRepository. This is an PowerShell Gallery folder that contains .ps1 file.

The steps to perform an overwrite:

(1) Connect to the FlashArray

PS C:\> $FlashArray = New-PfaArray -EndPoint -Credentials (Get-Credential) -IgnoreCertificateError

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:

(2) Check the connection to the FlashArray. Optional step, just illustrating here that we have a connection to the FlashArray.

PS C:\> $FlashArray

Disposed : False
EndPoint :
UserName : pureuser
ApiVersion : 1.7
Role : ArrayAdmin
ApiToken : 58db6abf-1933-553f-1628-0c6e207aba1e

(3) Retrieve the volume. Optional step as I just want to illustrate the volume exists on the FlashArray.

PS C:\> Get-PfaVolumes -Array $FlashArray | Where-Object { $_.name -like '*PS*' } | Format-Table -AutoSize

source serial                   created              name         size
------ ------                   -------              ----         ----
       45084F3508BF4614000111A7 2016-11-02T16:21:05Z PSRepository 268435456000

(4) Create a snapshot of the PSRepository volume. For this example I use the Suffix and set to Overwrite. This is the snapshot we will restore (overwrite) in a few steps.

PS C:\> New-PfaVolumeSnapshots -Array $FlashArray -Sources PSRepository -Suffix Overwrite

source : PSRepository
serial : 45084F3508BF461400011AC1
created : 2017-05-12T16:51:46Z
name : PSRepository.Overwrite
size : 268435456000

To prove the overwrite operation takes place I have made copies of the Untitled.ps1 files into the same folder.

(5) Offline the Windows Server volume.

$Volume = Get-PfaVolume -Array $f -Name 'PSRepository'
Get-Disk -SerialNumber $Volume.serial | Set-Disk -IsOffline $true

(6) Perform the overwrite operation with the snapshot we named PSRepository.Overwrite

PS C:\> New-PfaVolume -Array $FlashArray -Source PSRepository.OverWrite -VolumeName PSRepository -Overwrite

source : PSRepository
serial : 45084F3508BF4614000111A7
created : 2017-05-12T16:51:46Z
name : PSRepository
size : 268435456000

(7) Online the Windows Server volume.

$Volume = Get-PfaVolume -Array $f -Name 'PSRepository'
Get-Disk -SerialNumber $Volume.serial | Set-Disk -IsOffline $false

From the screenshot below you can see the the original snapshot has overwritten the volume where we had made copies of the .ps1 files.

Go forth and automate!


One comment

Add Comment

Required fields are marked *. Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.