diff --git a/workflows/Move-RubrikMountVMDK.ps1 b/Rubrik/Public/Move-RubrikMountVMDK.ps1 similarity index 87% rename from workflows/Move-RubrikMountVMDK.ps1 rename to Rubrik/Public/Move-RubrikMountVMDK.ps1 index 23521e1df..1e264802a 100644 --- a/workflows/Move-RubrikMountVMDK.ps1 +++ b/Rubrik/Public/Move-RubrikMountVMDK.ps1 @@ -1,4 +1,4 @@ -#Requires -Version 3 +#Requires -Version 3 -Module VMware.VimAutomation.Core function Move-RubrikMountVMDK { <# @@ -43,7 +43,7 @@ function Move-RubrikMountVMDK The file contains the TargetVM name, MountID value, and a list of all presented disks #> - [CmdletBinding()] + [CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'High')] Param( # Source virtual machine to use as a Live Mount based on a previous backup [Parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ParameterSetName = 'Create')] @@ -75,6 +75,10 @@ function Move-RubrikMountVMDK Process { + TestRubrikConnection + + ConnectTovCenter -vCenter $vCenter + if (!$Cleanup) { if (!$Date) @@ -114,30 +118,33 @@ function Move-RubrikMountVMDK $TargetHost = Get-VMHost -VM $TargetVM Write-Verbose -Message 'Migrating the Mount VMDKs to VM' - [array]$MountVMdisk = Get-HardDisk $MountVM.name - $MountedVMdiskFileNames = @() - [int]$j = 0 - foreach ($_ in $MountVMdisk) + if ($PSCmdlet.ShouldProcess($TargetVM,'Migrating Live Mount VMDK(s)')) { - if ($ExcludeDisk -contains $j) - { - Write-Verbose -Message "Skipping Disk $j" -Verbose - } - else + [array]$MountVMdisk = Get-HardDisk $MountVM.name + $MountedVMdiskFileNames = @() + [int]$j = 0 + foreach ($_ in $MountVMdisk) { - try + if ($ExcludeDisk -contains $j) { - $null = Remove-HardDisk -HardDisk $_ -DeletePermanently:$false -Confirm:$false - $null = New-HardDisk -VM $TargetVM -DiskPath $_.Filename - $MountedVMdiskFileNames += $_.Filename - Write-Verbose -Message "Migrated $($_.Filename) to $TargetVM" + Write-Verbose -Message "Skipping Disk $j" -Verbose } - catch + else { - throw $_ + try + { + $null = Remove-HardDisk -HardDisk $_ -DeletePermanently:$false -Confirm:$false + $null = New-HardDisk -VM $TargetVM -DiskPath $_.Filename + $MountedVMdiskFileNames += $_.Filename + Write-Verbose -Message "Migrated $($_.Filename) to $TargetVM" + } + catch + { + throw $_ + } } + $j++ } - $j++ } $Diskfile = "$Home\Documents\"+$SourceVM+'_to_'+$TargetVM+'-'+(Get-Date).Ticks+'.txt' diff --git a/Rubrik/Public/New-RubrikMount.ps1 b/Rubrik/Public/New-RubrikMount.ps1 index 02a0240c6..234108540 100644 --- a/Rubrik/Public/New-RubrikMount.ps1 +++ b/Rubrik/Public/New-RubrikMount.ps1 @@ -25,7 +25,7 @@ function New-RubrikMount This will create a new Live Mount for the virtual machine named Server1 based on the first snapshot that is equal to or older the current time (now) #> - [CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'Low')] + [CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'High')] Param( # Name of the virtual machine [Parameter(Mandatory = $true,Position = 0,ValueFromPipelineByPropertyName = $true)] diff --git a/Rubrik/Rubrik.psd1 b/Rubrik/Rubrik.psd1 index 8feafb1bd..e24126a91 100644 --- a/Rubrik/Rubrik.psd1 +++ b/Rubrik/Rubrik.psd1 @@ -66,7 +66,7 @@ FormatsToProcess = @() # NestedModules = @() # Functions to export from this module -FunctionsToExport = @('Connect-Rubrik','Get-RubrikMount','Get-RubrikSLA','Get-RubrikVersion','New-RubrikMount','New-RubrikSnapshot','Remove-RubrikMount','Remove-RubrikSLA','Protect-RubrikVM','Sync-RubrikTag','New-RubrikReport','Get-RubrikVM','Get-RubrikSnapshot','Protect-RubrikTag','Stop-RubrikVM','Start-RubrikVM','Get-RubrikJob','Set-RubrikVM','New-RubrikSLA','Get-RubrikRequest') +FunctionsToExport = @('Connect-Rubrik','Get-RubrikMount','Get-RubrikSLA','Get-RubrikVersion','New-RubrikMount','New-RubrikSnapshot','Remove-RubrikMount','Remove-RubrikSLA','Protect-RubrikVM','Sync-RubrikTag','New-RubrikReport','Get-RubrikVM','Get-RubrikSnapshot','Protect-RubrikTag','Stop-RubrikVM','Start-RubrikVM','Get-RubrikJob','Set-RubrikVM','New-RubrikSLA','Get-RubrikRequest','Move-RubrikMountVMDK') # Cmdlets to export from this module CmdletsToExport = @() diff --git a/docs/index.rst b/docs/index.rst index 30635fddd..3fa203e7f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -24,7 +24,7 @@ Below is a quick YouTube video that explains how to begin using the module. requirements installation getting_started - module_architecture + project_architecture support contribution licensing @@ -37,6 +37,7 @@ Below is a quick YouTube video that explains how to begin using the module. cmd_connect cmd_get + cmd_move cmd_new cmd_protect cmd_remove diff --git a/docs/module_architecture.rst b/docs/project_architecture.rst similarity index 90% rename from docs/module_architecture.rst rename to docs/project_architecture.rst index 81b71dc3a..d2ffbe356 100644 --- a/docs/module_architecture.rst +++ b/docs/project_architecture.rst @@ -1,4 +1,4 @@ -Module Architecture +Project Architecture ======================== This page contains details on the artifacts found within the repository.