diff --git a/VERSION b/VERSION index 045169b..cff98fe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.26.0 +7.26.1 diff --git a/build.ps1 b/build.ps1 index 5eefb46..e413569 100644 --- a/build.ps1 +++ b/build.ps1 @@ -99,6 +99,25 @@ Write-Host "Root Directory is: $PSScriptRoot" Write-Host '#################################################################################' Write-Host +# Search for MSBuild in both Program Files directories and the Windows Microsoft.NET folder +$pathsToSearch = @( + "${env:ProgramFiles(x86)}\Microsoft Visual Studio", + "${env:ProgramFiles}\Microsoft Visual Studio", + "${env:WINDIR}\Microsoft.NET" +) + +$MSBUILD = Get-ChildItem -Path $pathsToSearch -Filter msbuild.exe -Recurse -ErrorAction SilentlyContinue -Force | Select-Object -First 1 + +if ($null -ne $MSBUILD) { + # MSBuild.exe found, output the path + Write-Output "MSBuild.exe found at: $($msbuild.FullName)" +} else { + # MSBuild.exe not found + Write-Error "MSBuild.exe not found." + exit 1 +} + + $NSWAG_FRAMEWORK = 'NetCore31' $CONFIGURATION = 'Release' $FRAMEWORK = 'netcoreapp3.1' @@ -146,10 +165,10 @@ Set-Location -Path $VCDR_SWAG_DIR Set-Location -Path $VCDRSERVICE_SRC & dotnet build -& msbuild -t:Rebuild -p:Configuration=$CONFIGURATION -p:Platform=$PLATFORM +& $MSBUILD -t:Rebuild -p:Configuration=$CONFIGURATION -p:Platform=$PLATFORM Copy-Item -Path "$VCDRSERVICE_SRC\*.cs" -Destination $VCDRSERVICE_LEGACY_SRC -Verbose Set-Location -Path $VCDRSERVICE_LEGACY_SRC -& msbuild VMware.VCDRService_legacy.csproj /p:Configuration=$CONFIGURATION /p:Platform=$PLATFORM /p:TargetFrameworkVersion=$LEGACYFRAMEWORK -t:Rebuild +& $MSBUILD VMware.VCDRService_legacy.csproj /p:Configuration=$CONFIGURATION /p:Platform=$PLATFORM /p:TargetFrameworkVersion=$LEGACYFRAMEWORK -t:Rebuild Set-Location $BASEDIR #endregion build diff --git a/publish/VMware.VCDRService-7-26-0.zip b/publish/VMware.VCDRService-7-26-0.zip deleted file mode 100644 index e9b6cfa..0000000 Binary files a/publish/VMware.VCDRService-7-26-0.zip and /dev/null differ diff --git a/publish/VMware.VCDRService/7.26.0/LICENSE b/publish/VMware.VCDRService/7.26.0/LICENSE deleted file mode 100644 index 25f87be..0000000 --- a/publish/VMware.VCDRService/7.26.0/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (C) 2020, VMware, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/publish/VMware.VCDRService/7.26.0/Types.ps1xml b/publish/VMware.VCDRService/7.26.0/Types.ps1xml deleted file mode 100644 index 5a6919e..0000000 --- a/publish/VMware.VCDRService/7.26.0/Types.ps1xml +++ /dev/null @@ -1,165 +0,0 @@ - - - - VMware.VCDRService.ProtectionGroup - - - PSStandardMembers - - - DefaultDisplayPropertySet - - Name - Health - used_gib - - - - - - - - VMware.VCDRService.ProtectionGroupSnapshot - - - PSStandardMembers - - - DefaultDisplayPropertySet - - Name - vm_count - failed_vm_snap_count - total_used_data_gib - - - - - - - - VMware.VCDRService.CloudFileSystem - - - PSStandardMembers - - - DefaultDisplayPropertySet - - Name - Capacity_gib - Used_gib - - - - - - - - VMware.VCDRService.ProtectedSite - - - PSStandardMembers - - - DefaultDisplayPropertySet - - Name - Type - - - - - - - - VMware.VCDRService.VCDRServer - - - PSStandardMembers - - - DefaultDisplayPropertySet - - Server - Version - OrgId - Region - - - - - - - - VMware.VCDRService.VmSummary - - - PSStandardMembers - - - DefaultDisplayPropertySet - - Name - Size - Vcdr_vm_id - - - - - - - - VMware.VCDRService.RecoverySddc - - - PSStandardMembers - - - DefaultDisplayPropertySet - - Name - Region - Availability_zones - - - - - - - - VMware.VCDRService.VCDRService - - - PSStandardMembers - - - DefaultDisplayPropertySet - - OrgId - NumberOfRegions - - - - - - - - VMware.VCDRService.VcdrSummary - - - PSStandardMembers - - - DefaultDisplayPropertySet - - Id - Url - Region - - - - - - - \ No newline at end of file diff --git a/publish/VMware.VCDRService/7.26.0/VMware.VCDRService.psd1 b/publish/VMware.VCDRService/7.26.0/VMware.VCDRService.psd1 deleted file mode 100644 index 9fa5d3e..0000000 --- a/publish/VMware.VCDRService/7.26.0/VMware.VCDRService.psd1 +++ /dev/null @@ -1,121 +0,0 @@ -# -# Module manifest for module 'VMware.VCDRService' Core & Desktop -# -# Generated by: build.ps1 -# -# Generated on: 11/06/2023 16:07:08 -# -@{ - # Version number of this module. - ModuleVersion = '7.26.0' - - # Supported PSEditions - CompatiblePSEditions = 'Desktop', 'Core' - - # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '5.1' - # Type files (.ps1xml) to be loaded when importing this module - TypesToProcess = @("Types.ps1xml") - - # Script module or binary module file associated with this manifest. - RootModule = 'VMware.VCDRService.psm1' - - # ID used to uniquely identify this module - GUID = '151f6501-a080-4b44-851f-3626c97ea1a3' - - # Author of this module - Author = 'VMware' - - # Company or vendor of this module - CompanyName = 'VMware, Inc.' - - # Copyright statement for this module - Copyright = '2023(c) VMware Inc. All rights reserved.' - - # Description of the functionality provided by this module - Description = 'PowerCLI VMware Cloud Disaster Recovery module' - - # Processor architecture (None, X86, Amd64) required by this module - # ProcessorArchitecture = '' - - # Modules that must be imported into the global environment prior to importing this module - RequiredModules = @( - @{"ModuleName"="VMware.VimAutomation.Sdk";"ModuleVersion"="12.7.0.20067606"} - @{"ModuleName"="VMware.VimAutomation.Common";"ModuleVersion"="12.7.0.20067789"} - @{"ModuleName"="VMware.Vim";"ModuleVersion"="7.0.3.19601056"} - @{"ModuleName"="VMware.VimAutomation.Core";"ModuleVersion"="12.7.0.20091293"} - ) - - # Script files (.ps1) that are run in the caller's environment prior to importing this module. - # ScriptsToProcess = @() - - # Type files (.ps1xml) to be loaded when importing this module - #TypesToProcess = @("Types.ps1xml") - - # Format files (.ps1xml) to be loaded when importing this module - # FormatsToProcess = @() - - # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - # NestedModules = @() - - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - # FunctionsToExport = @() - - # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = @("Connect-VCDRService","Disconnect-VCDRService","Get-VCDRInstance","Get-DefaultVCDRInstance","Set-DefaultVCDRInstance", "Get-VCDRCloudFileSystem", "Get-VCDRProtectedSite", "Get-VCDRProtectionGroup", "Get-VCDRSnapshot", "Get-VCDRProtectedVm", "get-VCDRRecoverySddc","Get-VmFromVCDR","Remove-HFSFilter","Get-HFSFilter") - - # Variables to export from this module - VariablesToExport = '*' - - # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. - AliasesToExport = @("Connect-VCDRServer", "Disconnect-VCDRServer") - - # DSC resources to export from this module - # DscResourcesToExport = @() - - # List of all modules packaged with this module - # ModuleList = @() - - # List of all files packaged with this module - # FileList = @() - - # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. - PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() - - # A URL to the license for this module. - LicenseUri = 'https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery/blob/main/LICENSE' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery' - - # A URL to an icon representing this module. - IconUri = 'https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/1710f7ccbdd9fe9a3ab3f000e920fa6e8e042c63/resources/powercli-psgallery-icon.svg' - - # ReleaseNotes of this module - ReleaseNotes = 'VMware Cloud Disaster Recovery PowerShell CmdLets' - - # Prerelease string of this module - #Prerelease = 'Alpha' - - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = False - - # External dependent modules of this module - # ExternalModuleDependencies = @() - - } # End of PSData hashtable - - } # End of PrivateData hashtable - - # HelpInfo URI of this module - # HelpInfoURI = '' - - # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. - # DefaultCommandPrefix = '' - -} diff --git a/publish/VMware.VCDRService/7.26.0/VMware.VCDRService.psm1 b/publish/VMware.VCDRService/7.26.0/VMware.VCDRService.psm1 deleted file mode 100644 index d9b5e72..0000000 --- a/publish/VMware.VCDRService/7.26.0/VMware.VCDRService.psm1 +++ /dev/null @@ -1,28 +0,0 @@ -# -# Script module for module 'VMware.VCDRService' -# -Set-StrictMode -Version Latest - -$binaryModuleFileName = 'VMware.VCDRService.psd1' - -# Set up some helper variables to make it easier to work with the module -$PSModule = $ExecutionContext.SessionState.Module -$PSModuleRoot = $PSModule.ModuleBase - -# Import the appropriate nested binary module based on the current PowerShell version -$binaryModuleRoot = $PSModuleRoot - -if (($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop')) { - $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'netcore' -} -else { - $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'net' -} - -$binaryModulePath = Join-Path -Path $binaryModuleRoot -ChildPath $binaryModuleFileName -$binaryModule = Import-Module -Name $binaryModulePath -PassThru - -# When the module is unloaded, remove the nested binary module that was loaded with it -$PSModule.OnRemove = { - Remove-Module -ModuleInfo $binaryModule -} diff --git a/publish/VMware.VCDRService/7.26.0/net/Newtonsoft.Json.dll b/publish/VMware.VCDRService/7.26.0/net/Newtonsoft.Json.dll deleted file mode 100644 index 341d08f..0000000 Binary files a/publish/VMware.VCDRService/7.26.0/net/Newtonsoft.Json.dll and /dev/null differ diff --git a/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.dll b/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.dll deleted file mode 100644 index 8bb96a7..0000000 Binary files a/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.dll and /dev/null differ diff --git a/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.psd1 b/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.psd1 deleted file mode 100644 index a9f744f..0000000 --- a/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.psd1 +++ /dev/null @@ -1,130 +0,0 @@ -# -# Module manifest for module 'VMware.VCDRService' Core & Desktop -# -# Generated by: build.ps1 -# -# Generated on: 11/06/2023 16:07:08 -# -@{ - # Version number of this module. - ModuleVersion = '7.26.0' - - # Supported PSEditions - CompatiblePSEditions = 'Desktop' - - # Assemblies that must be loaded prior to importing this module - RequiredAssemblies = @("VMware.VCDRService.dll") - - # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '5.1' - - # Minimum version of the Windows PowerShell host required by this module - PowerShellHostVersion = '' - - # Minimum version of the .NET Framework required by this module - DotNetFrameworkVersion = '4.5' - - # Minimum version of the common language runtime (CLR) required by this module - CLRVersion = '4.0' - # Script module or binary module file associated with this manifest. - RootModule = 'VMware.VCDRService.psm1' - - # ID used to uniquely identify this module - GUID = '151f6501-a080-4b44-851f-3626c97ea1a3' - - # Author of this module - Author = 'VMware' - - # Company or vendor of this module - CompanyName = 'VMware, Inc.' - - # Copyright statement for this module - Copyright = '2023(c) VMware Inc. All rights reserved.' - - # Description of the functionality provided by this module - Description = 'PowerCLI VMware Cloud Disaster Recovery module' - - # Processor architecture (None, X86, Amd64) required by this module - # ProcessorArchitecture = '' - - # Modules that must be imported into the global environment prior to importing this module - RequiredModules = @( - @{"ModuleName"="VMware.VimAutomation.Sdk";"ModuleVersion"="12.7.0.20067606"} - @{"ModuleName"="VMware.VimAutomation.Common";"ModuleVersion"="12.7.0.20067789"} - @{"ModuleName"="VMware.Vim";"ModuleVersion"="7.0.3.19601056"} - @{"ModuleName"="VMware.VimAutomation.Core";"ModuleVersion"="12.7.0.20091293"} - ) - - # Script files (.ps1) that are run in the caller's environment prior to importing this module. - # ScriptsToProcess = @() - - # Type files (.ps1xml) to be loaded when importing this module - #TypesToProcess = @("Types.ps1xml") - - # Format files (.ps1xml) to be loaded when importing this module - # FormatsToProcess = @() - - # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - # NestedModules = @() - - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - # FunctionsToExport = @() - - # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = @("Connect-VCDRService","Disconnect-VCDRService","Get-VCDRInstance","Get-DefaultVCDRInstance","Set-DefaultVCDRInstance", "Get-VCDRCloudFileSystem", "Get-VCDRProtectedSite", "Get-VCDRProtectionGroup", "Get-VCDRSnapshot", "Get-VCDRProtectedVm", "get-VCDRRecoverySddc","Get-VmFromVCDR","Remove-HFSFilter","Get-HFSFilter") - - # Variables to export from this module - VariablesToExport = '*' - - # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. - AliasesToExport = @("Connect-VCDRServer", "Disconnect-VCDRServer") - - # DSC resources to export from this module - # DscResourcesToExport = @() - - # List of all modules packaged with this module - # ModuleList = @() - - # List of all files packaged with this module - # FileList = @() - - # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. - PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() - - # A URL to the license for this module. - LicenseUri = 'https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery/blob/main/LICENSE' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery' - - # A URL to an icon representing this module. - IconUri = 'https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/1710f7ccbdd9fe9a3ab3f000e920fa6e8e042c63/resources/powercli-psgallery-icon.svg' - - # ReleaseNotes of this module - ReleaseNotes = 'VMware Cloud Disaster Recovery PowerShell CmdLets' - - # Prerelease string of this module - #Prerelease = 'Alpha' - - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = False - - # External dependent modules of this module - # ExternalModuleDependencies = @() - - } # End of PSData hashtable - - } # End of PrivateData hashtable - - # HelpInfo URI of this module - # HelpInfoURI = '' - - # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. - # DefaultCommandPrefix = '' - -} diff --git a/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.psm1 b/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.psm1 deleted file mode 100644 index b547f57..0000000 --- a/publish/VMware.VCDRService/7.26.0/net/VMware.VCDRService.psm1 +++ /dev/null @@ -1,1113 +0,0 @@ -################################################################################# -# Copyright (C) 2022, VMware Inc -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -################################################################################# - -class AWSRegions : System.Management.Automation.IValidateSetValuesGenerator { - [String[]] GetValidValues() { - return $Script:AwsActiveRegion - } -} - -class HFSFilter { - [String ]$VendorId - [String ]$DiskUuid - [String ]$FileName - HFSFilter ( $VendorId, $DiskUuid, $FileName) { - $this.VendorId = $VendorId - $this.DiskUuid = $DiskUuid - $this.FileName = $FileName - } -} - -New-Variable -Scope Script -Name DefaultVCDRService -New-Variable -Scope Script -Option Constant -Name AWSRegions -Value @('us-east-2', 'us-east-1', 'us-west-1', 'us-west-2', 'af-south-1', 'ap-east-1', 'ap-southeast-3', 'ap-south-1', 'ap-northeast-3', 'ap-northeast-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'ca-central-1', 'eu-central-1', 'eu-west-1', 'eu-west-2', 'eu-south-1', 'eu-west-3', 'eu-north-1', 'me-south-1', 'sa-east-1', 'unknow') -New-Variable -Scope Script -Name AwsActiveRegion -Value $AWSRegions -New-Variable -Scope Script -Name PagingSize -Value 100 -New-Variable -Scope Script -Option Constant -Name NotConnectedMsg -Value 'You are not currently connected to any servers. Please connect first using a Connect cmdlet.' - -<# - .SYNOPSIS - This cmdlet establishes a connection to a VCDR Service. - .DESCRIPTION - This cmdlet establishes a connection to a VCDR Service. The cmdlet starts a new session or re-establishes - a previous session with a VCDR Server system using the specified parameters. - .PARAMETER Token - The tokne used to authenticate VMC - .PARAMETER Region - The Region set as default for any cmdlet operation - .PARAMETER Server - The Server set as default for any cmdlet operation (alternative connection) - .PARAMETER cspBaseUrl - Specifies the IP address or the DNS name of the VMware managed cloud service. If not specified, the cmdlet assumes that you are connecting to the public commercial instance and the default value of - `vmc.vmware.com` is used - .PARAMETER vcdrBackendUrl - Specifies the IP address or the DNS name of the VMware managed disaster recovery cloud service. If not specified, the cmdlet assumes that you are connecting to the public commercial instance and the default value of - `vdp.vmware.com` is used - .EXAMPLE - $token="" - - $VCDR=Connect-VCDRService -token $token - - Description - ----------- - This example connect to a VCDR Service using a VMC token - - - .NOTES - FunctionName : Connect-VCDRService - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -Function Connect-VCDRService { - [OutputType([VMware.VCDRService.VCDRService])] - [CmdletBinding(DefaultParameterSetName = 'Default')] - Param( - [Parameter( Mandatory = $true, ParameterSetName = 'Default')] - [Parameter( Mandatory = $true, ParameterSetName = 'Host')] - [String] $Token, - [Parameter( Mandatory = $false, ParameterSetName = 'Default')] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region, - - [Parameter( Mandatory = $false, ParameterSetName = 'Host')] - [Parameter( Mandatory = $false, ParameterSetName = 'Default')] - [String] $cspBaseUrl , - - [Parameter( Mandatory = $false, ParameterSetName = 'Default')] - [String] $vcdrBackendUrl, - - [Parameter( Mandatory = $true, ParameterSetName = 'Host')] - [String] $Server - ) - if ($Script:DefaultVCDRService) { - # if ($Script:DefaultVCDRService.CompareToken($Token)) - # { - # throw 'Already connected to Org:' + $Script:DefaultVCDRService.OrgId + ' . Use Disconnect-VCDRService to disconnect from this Org.' - # } - $Script:DefaultVCDRService.Disconnect - } - if ($Server) { - [System.Uri] $serverUri = [System.Uri]"https://$Server" - [VMware.VCDRService.VCDRService] $VCDRServiceClient = New-Object VMware.VCDRService.VCDRService($Token, $serverUri, $cspBaseUrl) - } else { - [VMware.VCDRService.VCDRService] $VCDRServiceClient = New-Object VMware.VCDRService.VCDRService($Token, $cspBaseUrl, $vcdrBackendUrl) - } - Set-Variable -Scope Script -Name DefaultVCDRService -Value $VCDRServiceClient - $Script:AwsActiveRegion = $VCDRServiceClient.GetActiveRegions() - return $VCDRServiceClient -} - -<# - .SYNOPSIS - This cmdlet closes the connection to a VCDR Service . - .DESCRIPTION - This cmdlet closes the connection to a VCDR Service . - - .EXAMPLE - $token="" - $VCDR=Connect-VCDRService -token $token - - Disconnect-VCDRService - - Description - ----------- - This example connect to a VCDR Server system using a VMC token.Then disconnects from the specified server. - - - .NOTES - FunctionName : Disconnect-VCDRService - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -Function Disconnect-VCDRService { - if ($Script:DefaultVCDRService) { - $Script:DefaultVCDRService.Disconnect() - Remove-Variable -Scope Script -Name DefaultVCDRService - Set-Variable -Scope Script -Name AwsActiveRegion -Value $AWSRegions - } -} - - - - -<# - .SYNOPSIS - This cmdlet return the list of VCDR instances available in the Org . - .DESCRIPTION - This cmdlet return each VCDR Server instance on each available region. - .PARAMETER Region - Return the VCDR server for this specific region - .EXAMPLE - $token="" - $VCDR=Connect-VCDRService -token $token - Get-VCDRInstance - - Disconnect-VCDRService - - Description - ----------- - This example connect to a VCDR Server system using a VMC token.Set the new default VCDR Server and then disconnects. - - - .NOTES - FunctionName : Get-VCDRInstance - Created by : VMware - - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> - -Function Get-VCDRInstance { - [OutputType([VMware.VCDRService.VcdrSummary[]])] - param( - [Parameter( Mandatory = $False)] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region - ) - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.VcdrSummary[]] $Result = @() - $Result = $Script:DefaultVCDRService.GetVcdrInstances($Region) - return $Result - } else { - throw $NotConnectedMsg - } - -} - - - - -<# - .SYNOPSIS - This cmdlet set the default VCDR Server in the Org . - .DESCRIPTION - This cmdlet set the defult server. - .PARAMETER Region - The Region set as default for any cmdlet operation - .EXAMPLE - $token="" - $VCDR=Connect-VCDRService -token $token - Set-DefaultVCDRInstance -Region eu-west-1 - - Disconnect-VCDRService - - Description - ----------- - This example connect to a VCDR Server system using a VMC token.Set the new default VCDR Server and then disconnects. - - - .NOTES - FunctionName : Set-DefaultVCDRInstance - Created by : VMware - - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> - -Function Set-DefaultVCDRInstance { - [OutputType([VMware.VCDRService.VcdrSummary])] - [CmdletBinding(DefaultParameterSetName = 'Default')] - param( - [Parameter( Mandatory = $True)] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region - ) - if ($Script:DefaultVCDRService) { - $Server = $Script:DefaultVCDRService.SelectRegion($Region) - $Result = New-Object -TypeName 'VMware.VCDRService.VcdrSummary' -ArgumentList $Server - return $Result - } else { - throw $NotConnectedMsg - } -} - - -<# - .SYNOPSIS - This cmdlet return the default VCDR Server in the Org . - .DESCRIPTION - This cmdlet return the defult server. - - .EXAMPLE - $token="" - $VCDR=Connect-VCDRService -token $token -region us-west-2 - Get-DefaultVCDRInstance - - Disconnect-VCDRService - - Description - ----------- - This example connect to a VCDR Server system using a VMC token.Return the default VCDR Server and then disconnects. - - - .NOTES - FunctionName : Get-DefaultVCDRInstance - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -Function Get-DefaultVCDRInstance { - [OutputType([VMware.VCDRService.VcdrSummary])] - $Server = $Script:DefaultVCDRService.ActiveVcdrInstance - if ($Script:DefaultVCDRService) { - $Result = New-Object -TypeName 'VMware.VCDRService.VcdrSummary' -ArgumentList $Server - return $Result - } else { - throw $NotConnectedMsg - } - -} - - - - - -<# - .SYNOPSIS - List of cloud file systems - .DESCRIPTION - Get a list of any deployed cloud file systems in your VMware Cloud DR organization with details. - .PARAMETER Region - Specifies the region on which you want to run the cmdlet. If no value is provided to this parameter, the command runs on the default region. - .PARAMETER Name - The name of the Cloud File System - .PARAMETER Id - The identifier of the cloud file system. - .EXAMPLE - Get-VCDRCloudFileSystem -Name "cloud-backup-1" - - Description - ----------- - This example shows recalling of any Cloud Files System that matches the given name - - .EXAMPLE - Get-VCDRCloudFileSystem -Region us-west-2 - - Description - ----------- - This example shows recalling of any Cloud Files System residing in us-west-2 region - - .EXAMPLE - Get-VCDRCloudFileSystem -Id "dbd913aa-6cbe-11ec-9871-0a3e56ef2005" - - Description - ----------- - This example shows recalling of any Cloud Files System that matches the given id - .NOTES - FunctionName : Get-VCDRCloudFileSystem - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -Function Get-VCDRCloudFileSystem { - [CmdletBinding(DefaultParameterSetName = 'Default')] - [OutputType([VMware.VCDRService.CloudFileSystem[]])] - Param( - [Parameter( Mandatory = $false)] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region, - [Parameter( Mandatory = $false, ParameterSetName = 'ByName', HelpMessage = 'The name of the Cloud File System ')] - [String] $Name , - [Parameter( Mandatory = $false, ParameterSetName = 'ById', HelpMessage = 'The identifier of the cloud file system.')] - [String] $Id - ) - Begin { - if ($Script:DefaultVCDRService) { - $Server = $Script:DefaultVCDRService.SelectRegion($Region) - } else { - throw $NotConnectedMsg - } - [VMware.VCDRService.CloudFileSystem[]] $Result = @() - } - Process { - $cfs = $Server.GetCloudFileSystems() - if ($cfs.Cloud_file_systems) { - if ($name) { - $cf = $cfs.Cloud_file_systems | Where-Object { $_.Name -eq $Name } - if ($cf) { - $Result += $Server.GetCloudFileSystemDetails($cf.id) - } - } elseif ($id) { - $cf = $cfs.Cloud_file_systems | Where-Object { $_.Id -eq $id } - if ($cf) { - $Result += $Server.GetCloudFileSystemDetails($cf.id) - } - } else { - foreach ($cf in $cfs.Cloud_file_systems) { - $Result += $Server.GetCloudFileSystemDetails($cf.Id) - } - } - } - } - End { - return $Result - } -} - - -<# - .SYNOPSIS - List of protected sites. - .DESCRIPTION - Get a list of all protected sites associated with an individual cloud file system with details. - A protected site is a logical grouping of vCenters with VMs that are "protected" by the DRaaS Connector using snapshot replication to a cloud file system. - A protected site is associated with a unique cloud file system. - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of all protected sites. - .PARAMETER Vcenter - Unique identifier(s) of one or more vCenter(s) - .PARAMETER ProtectionGroup - Unique identifier(s) of one or more Protection Group(s) - .EXAMPLE - $CloudFS=Get-VCDRProtectedSite -CloudFileSystem "dbd913aa-6cbe-11ec-9871-0a3e56ef2005" - Get-VCDRProtectedSite -CloudFileSystem $CloudFS - - Description - ----------- - This example shows list any protected site protected by the Cloud Files System dbd913aa-6cbe-11ec-9871-0a3e56ef2005 - - .NOTES - FunctionName : Get-VCDRProtectedSite - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> - -Function Get-VCDRProtectedSite { - [CmdletBinding(DefaultParameterSetName = 'Default')] - [OutputType([VMware.VCDRService.ProtectedSite[]])] - Param( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem, - [Parameter( Mandatory = $false , HelpMessage = 'vCenter')] - [VMware.VimAutomation.Types.VIServer[]] $Vcenter , - [Parameter( Mandatory = $false, HelpMessage = 'Protection Group')] - [VMware.VCDRService.ProtectionGroupDetails[]] $ProtectionGroup - - ) - Begin { - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.ProtectedSite[]] $Result = @() - - $protectedSitesFilterSpec = New-Object -TypeName 'VMware.VCDRService.ProtectedSitesFilterSpec' - $protectedSitesFilterSpec.Protection_group_ids = New-Object -TypeName System.Collections.Generic.List[String] - $protectedSitesFilterSpec.Vcenter_ids = New-Object -TypeName System.Collections.Generic.List[String] - - if ($ProtectionGroup) { - foreach ($item in $ProtectionGroup) { - $protectedSitesFilterSpec.Protection_group_ids.Add($item.Id) - } - } - if ($Vcenter) { - foreach ($item in $Vcenter) { - $protectedSitesFilterSpec.Vcenter_ids.Add($item.InstanceUuid) - } - } else { - foreach ($vi in $global:DefaultVIServers) { - $protectionGroupsFilterSpec.Vcenter_ids.Add($vi.InstanceUuid) - } - } - } else { - throw $NotConnectedMsg - } - } - Process { - foreach ($Cfs in $CloudFileSystem) { - $Server = $Cfs.Server - [String] $Cursor = $Null - [VMware.VCDRService.ProtectedSiteSummary[]]$protectedSites = @() - do { - $protectedSitesResponse = $Server.GetProtectedSites($Cfs, $PagingSize, $protectedSitesFilterSpec, $Cursor) - if (! $protectedSitesResponse) { - break - } - $protectedSites += $protectedSitesResponse.Protected_sites - $Cursor = $protectedSitesResponse.Cursor - } while ($Cursor -and $protectedSitesResponse.Protected_sites -gt 0 ) - - foreach ($ps in $protectedSites) { - $Result += $Server.GetProtectedSiteDetails($Cfs, $ps.Id) - } - } - } - End { - return $Result - } -} - - - -<# - .SYNOPSIS - List of any protection groups associated with an individual cloud file system. - .DESCRIPTION - Get a detailed list of all protection groups associated with an individual cloud file system - A protection group defines a collection of VMs on a protected site that are being snapshotted and replicated to a cloud file system. - A protection group is associated with exactly one protected site (and by extension, exactly one cloud file system). - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of all protected sites - .PARAMETER vCenter - List of vCenters ID to be used as filter - .PARAMETER Site - List of Sites ID to be used as filter - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $ProtectionGroups=Get-VCDRProtectionGroup -CloudFileSystem $cloudFileSystem - - Description - ----------- - This example shows any protecion groups associated with the cloud file system - - .NOTES - FunctionName : Get-VCDRProtectionGroup - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> -Function Get-VCDRProtectionGroup { - [OutputType([VMware.VCDRService.ProtectionGroup[]])] - [CmdletBinding()] - Param( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem, - [Parameter( Mandatory = $false , HelpMessage = 'vCenter')] - [VMware.VimAutomation.Types.VIServer[]] $Vcenter , - [Parameter( Mandatory = $false, HelpMessage = 'Site ID')] - [String[]] $Site - ) - Begin { - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.ProtectionGroup[]] $Result = @() - - $protectionGroupsFilterSpec = New-Object -TypeName 'VMware.VCDRService.ProtectionGroupsFilterSpec' - $protectionGroupsFilterSpec.Site_ids = New-Object -TypeName System.Collections.Generic.List[String] - $protectionGroupsFilterSpec.Vcenter_ids = New-Object -TypeName System.Collections.Generic.List[String] - if ($Site) { - foreach ($item in $Site) { - $protectionGroupsFilterSpec.Site_ids.Add($item) - } - } - if ($Vcenter) { - foreach ($item in $Vcenter) { - $protectionGroupsFilterSpec.Vcenter_ids.Add($item.InstanceUuid) - } - } else { - foreach ($vi in $global:DefaultVIServers) { - $protectionGroupsFilterSpec.Vcenter_ids.Add($vi.InstanceUuid) - } - } - } else { - throw $NotConnectedMsg - } - } - Process { - foreach ($Cfs in $CloudFileSystem) { - $Server = $CloudFileSystem.Server - [VMware.VCDRService.ProtectionGroupSummary[]] $protectedGroups = @() - [String] $Cursor = $Null - do { - $protectedGroupsResponse = $Server.GetProtectionGroups($Cfs, $PagingSize, $protectionGroupsFilterSpec, $Cursor) - if (!$protectedGroupsResponse.Protection_groups ) { break } - $protectedGroups += $protectedGroupsResponse.Protection_groups - $Cursor = $protectedGroupsResponse.Cursor - } while ($Cursor -and $protectedGroupsResponse.Protection_groups -gt 0 ) - - foreach ($ps in $protectedGroups) { - $Result += $Server.GetProtectionGroupDetails($Cfs, $ps.Id) - } - } - } - End { - return $Result - } -} - - -<# - .SYNOPSIS - List of any snpashots associated to a specific protection group. - .DESCRIPTION - Get a list of all snpashots in a specific protection group. - A protection group snapshot encodes the point-in-time state of all the VMs defined in a specific protection group. - Protection group snapshots are immutable but are deleted when they expire, or when the containing protection group is deleted. A protection group snapshot is associated with exactly one protection group.. - .PARAMETER ProtectionGroup - Unique identifier(s) of one or more Protection Group(s) - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $ProtectionGroups=Get-VCDRProtectionGroup -CloudFileSystem $cloudFileSystem - Get-VCDRSnapshot -ProtectionGroup $ProtectionGroups - - Description - ----------- - This example shows any snapshot in the protection group - - .NOTES - FunctionName : Get-VCDRSnapshot - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> -Function Get-VCDRSnapshot { - [OutputType([VMware.VCDRService.ProtectionGroupSnapshot[]])] - [CmdletBinding()] - Param( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Protection Groups')] - [VMware.VCDRService.ProtectionGroup[] ] $ProtectionGroups, - [Parameter( Mandatory = $false, HelpMessage = 'Snapshot Id')] - [String ] $SnapshotID - ) - Begin { - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.ProtectionGroupSnapshot[]]$Result = @() - } else { - throw $NotConnectedMsg - } - } - Process { - - if ( $SnapshotID ) { - foreach ($ProtectionGroup in $ProtectionGroups) { - $Server = $ProtectionGroup.Server - $Result += $Server.GetProtectionGroupSnapshotDetails($ProtectionGroup, $SnapshotID) - } - } else { - - foreach ($ProtectionGroup in $ProtectionGroups) { - $Server = $ProtectionGroup.Server - [String] $Cursor = $Null - $Snapshots = [VMware.VCDRService.GetProtectionGroupSnapshotsResponse[]]@() - do { - $protectionGroupSnapshotResponse = $Server.GetProtectionGroupSnapshots( $ProtectionGroup, $PagingSize, $Cursor) - if (!$protectionGroupSnapshotResponse) { break } - if (!$protectionGroupSnapshotResponse.Snapshots) { break } - $Cursor = $protectionGroupSnapshotResponse.Cursor - $Snapshots += $protectionGroupSnapshotResponse.Snapshots - } while ($Cursor -and $protectionGroupSnapshotResponse.Snaphsots -gt 0 ) - foreach ($ps in $Snapshots) { - $Result += $Server.GetProtectionGroupSnapshotDetails($ProtectionGroup, $ps.Id) - } - } - } - } - End { - return $Result - } -} - - - - - - -<# - .SYNOPSIS - List of VMs associated with an individual cloud file system - .DESCRIPTION - A "protected" VM is a VM that is contained in at least one protection group snapshot that has been replicated to a cloud file system. - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of all protected sites - .PARAMETER vCenter - List of vCenters ID to be used as filter - .PARAMETER Site - List of Sites ID to be used as filter - .PARAMETER ProtectionGroup - List of protection groups to be used as filter - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $Vms=Get-VCDRProtectedVm -CloudFileSystem $cloudFileSystem - - Description - ----------- - This example shows any protecion groups associated with the cloud file system - - .NOTES - FunctionName : Get-VCDRProtectedVm - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> -Function Get-VCDRProtectedVm { - [OutputType([VMware.VCDRService.VmSummary[]])] - [CmdletBinding()] - Param( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem, - [Parameter( Mandatory = $false , HelpMessage = 'vCenter')] - [VMware.VimAutomation.Types.VIServer[]] $Vcenter , - [Parameter( Mandatory = $false, HelpMessage = 'Site ID')] - [String[]] $Site , - [Parameter( Mandatory = $false, HelpMessage = 'Protection Group ID')] - [VMware.VCDRService.ProtectionGroup[]] $ProtectionGroup , - [Parameter( Mandatory = $false, HelpMessage = 'Protection Group Snapshot ID')] - [VMware.VCDRService.ProtectionGroupSnapshot[]] $ProtectionGroupSnapshot - ) - Begin { - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.VmSummary[]]$Result = @() - - $VmsFilterSpec = New-Object -TypeName 'VMware.VCDRService.VmsFilterSpec' - $VmsFilterSpec.Site_ids = New-Object -TypeName System.Collections.Generic.List[String] - $VmsFilterSpec.Vcenter_ids = New-Object -TypeName System.Collections.Generic.List[String] - $VmsFilterSpec.Protection_group_snapshot_id = New-Object -TypeName System.Collections.Generic.List[String] - $VmsFilterSpec.Protection_group_ids = New-Object -TypeName System.Collections.Generic.List[String] - - if ($Site) { - foreach ($item in $Site) { - $VmsFilterSpec.Site_ids.Add($item) - } - } - if ($Vcenter) { - foreach ($item in $Vcenter) { - $VmsFilterSpec.Vcenter_ids.Add($item.InstanceUuid) - } - } else { - foreach ($vi in $global:DefaultVIServers) { - $protectionGroupsFilterSpec.Vcenter_ids.Add($vi.InstanceUuid) - } - } - if ($ProtectionGroup) { - foreach ($pg in $ProtectionGroup) { - $VmsFilterSpec.Protection_group_ids.Add($pg.id) - } - } - - if ($ProtectionGroupSnapshot) { - foreach ($pgs in $ProtectionGroupSnapshot) { - $VmsFilterSpec.Protection_group_snapshot_id.Add($pgs.Id) - } - } - } else { - throw $NotConnectedMsg - } - } - Process { - foreach ($Cfs in $CloudFileSystem) { - $Server = $CloudFileSystem.Server - [String] $Cursor = $Null - do { - $protectedVirtualMachines = $Server.GetProtectedVirtualMachines($Cfs, $PagingSize, $VmsFilterSpec, $Cursor) - if (!$protectedVirtualMachines) { break } - if (!$protectedVirtualMachines.Vms ) { break } - $Result += $protectedVirtualMachines.Vms - $Cursor = $protectedVirtualMachines.Cursor - } while ($Cursor -and $protectedVirtualMachines.Vms.Count -gt 0 ) - } - } - End { - return $Result - } -} - - - -<# - .SYNOPSIS - List of Recovery SDDCs - .DESCRIPTION - A Recovery SDDC is a VMware Cloud (VMC) software-defined datacenter (SDDC) where protected VMs are created, configured, and powered on during VMware Cloud DR failover. - .PARAMETER Region - Specifies the region on which you want to run the cmdlet. If no value is provided to this parameter, the command runs on the default region. - .PARAMETER Name - The name of the Sddc - .PARAMETER Id - The identifier of the Sddc. - .EXAMPLE - Get-VCDRRecoverySddc -Name "cloud-backup-SDDC" - - Description - ----------- - This example shows the information of the SDDC that matches the given name - - .EXAMPLE - Get-VCDRRecoverySddc - - Description - ----------- - This example shows the information of the any SDDC - .NOTES - FunctionName : Get-VCDRRecoverySddc - Created by : VMware - - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> -Function Get-VCDRRecoverySddc { - [OutputType([VMware.VCDRService.RecoverySddc[]])] - [CmdletBinding(DefaultParameterSetName = 'Default')] - Param( - [Parameter( Mandatory = $false)] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region, - [Parameter( Mandatory = $true, ParameterSetName = 'ByName', HelpMessage = 'The name of the Recovery SDDC ')] - [String] $Name , - [Parameter( Mandatory = $true, ParameterSetName = 'ById', HelpMessage = 'The identifier of the Recovery SDDC.')] - [String] $Id - ) - Begin { - if ($Script:DefaultVCDRService) { - $Server = $Script:DefaultVCDRService.SelectRegion($Region) - } else { - throw $NotConnectedMsg - } - [VMware.VCDRService.RecoverySddc[]] $Result = @() - } - Process { - $rSddcs = $Server.GetRecoverySddc() - if ($rSddcs.data) { - if ($name) { - $cf = $rSddcs.data | Where-Object { $_.Name -eq $Name } - if ($cf) { - $Result += $Server.GetRecoverySddcDetails($cf.id) - } - } elseif ($id) { - $cf = $rSddcs.data | Where-Object { $_.Id -eq $id } - if ($cf) { - $Result += $Server.GetRecoverySddcDetails($cf.id) - } - } else { - foreach ($cf in $rSddcs.data) { - $Result += $Server.GetRecoverySddcDetails($cf.Id) - } - } - } - return $Result - } - End { - } -} - - - -<# - .SYNOPSIS - This cmdlet convert virtual machine VCDR object to VimAutomation. - .DESCRIPTION - This cmdlet convert virtual machine VCDR object to VimAutomation. - .PARAMETER VM - The Virtual Machines object to convert - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $Vms=Get-VCDRProtectedVm -CloudFileSystem $cloudFileSystem - $VimVms = Get-VmFromVCDR -VM $Vms -errorAction Continue - Disconnect-VCDRService - - Description - ----------- - This example convert any VMs managed by the $cloudFileSystem to a standard Vim VM - - - .NOTES - FunctionName : Get-VmFromVCDR - Created by : VMware - - Modified by : VMware - Date Modified : 2023/04/10 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -function Get-VmFromVCDR { - [OutputType([VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]])] - [CmdletBinding(DefaultParameterSetName = 'ProtectionGroup')] - param ( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'VCDR Protected Vms', ParameterSetName = 'ProtectionGroup')][VMware.VCDRService.ProtectionGroup[]] $ProtectionGroup, - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'VCDR Protected Vms', ParameterSetName = 'Vm')] [VMware.VCDRService.VmSummary[]] $Vm - ) - Begin { - [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $Result = @() - $hash = @{} - } - Process { - if ($global:DefaultVIServers) { - if ($ProtectionGroup) { - foreach ($PrGroup in $ProtectionGroup) { - foreach ($Mspec in $PrGroup.Members_specs) { - foreach ($Folder in $Mspec.Vcenter_folder_paths) { - $FolderParts = $Folder.split('/') - $Parent = Get-Datacenter($FolderParts[0]) - for ($i = 2; $i -lt $FolderParts.Count ; $i++) { - $Parent = Get-Folder -Name $FolderParts[$i] -Location $Parent - } - $Result += Get-VM -Location $Parent -Server $Mspec.Vcenter_id - } - foreach ($vmname in $Mspec.Vcenter_vm_name_patterns) { - $Result += Get-VM -Server $Mspec.Vcenter_id -Name $vmname - } - - foreach ($vmTag in $Mspec.Vcenter_tags) { - $Tag = Get-Tag -Server $Mspec.Vcenter_id -Name $vmTag.Tag_name -Category $vmTag.Category_name - $Result += Get-VM -Server $Mspec.Vcenter_id -Tag $Tag - } - } - } - } - if ($Vm) { - foreach ($lvm in $Vm) { - $NotFound = $true - for ($i = 0; $i -lt $global:DefaultVIServers.Count ; $i++) { - - if ($global:DefaultVIServers[$i].InstanceUuid -eq $lvm.Id.Vcenter_id) { - $hash[$i] += @($lvm.Id.Id) - $NotFound = $false - break - } - } - if ($NotFound -and $ErrorActionPreference -ne 'Continue') { - throw "Please connect vCenter id:$($lvm.Id.Vcenter_id) using Connect-VIServer" - } - } - } - } else { - throw 'Please connect to vCenter using Connect-VIServer' - } - } - End { - if ($Vm) { - for ($i = 0; $i -lt $global:DefaultVIServers.Count ; $i++) { - $Result += Get-VM -Server $global:DefaultVIServers[$i] -Id $hash[$i] - } - } - return $Result - } -} - - - - -<# - .SYNOPSIS - This cmdlet check if a virtual machine has the HFS filter(LWD) - .DESCRIPTION - This cmdlet check if a virtual machine has the HFS filter(LWD). - .PARAMETER VM - The Virtual Machines object to check - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of HFS - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $Vm=Get-VM -name "test" - Get-HFSFilter -VM $VM - - Description - ----------- - This example return any HFS filter applied to the VM - - .NOTES - FunctionName : Get-HFSFilter - Created by : VMware - - Modified by : VMware - Date Modified : 2023/04/10 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -function Get-HFSFilter { - [OutputType([HFSFilter[]] )] - [CmdletBinding()] - param ( [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'VM')] - [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $VM, - [Parameter( Mandatory = $false, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem = @() - ) - Begin { - [HFSFilter[]] $Result = @() - } - Process { - foreach ( $VimVms in $(Get-VM -Name $VM)) { - foreach ($device in $VimVms.ExtensionData.COnfig.hardware.device) { - if ($device -is [VMware.Vim.VirtualDisk]) { - foreach ($Filter in $device.IndependentFilters) { - $Value = $Filter.FilterCapabilities.foreach{ ($_.key -eq 'vendorId')?$_.value:'' } - if ($Value) { - $Found = (!$CloudFileSystem) - foreach ($Cl in $CloudFileSystem) { - if ($Value[0].contains($Cl.Id)) { - $Found = $true - break - } - } - if ($Found) { - $Result += [HFSFilter]::new( $Value[0], $device.Backing.Uuid, $device.Backing.FileName) - } - } - break - } - - } - } - } - } - End { - return $Result - } -} - - -<# - .SYNOPSIS - This cmdlet removethe HFS filter from a virtual machine - .DESCRIPTION - This cmdlet removethe HFS filter from a virtual machine. - .PARAMETER VM - The Virtual Machines object to be reconfigured - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of HFS - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $Vm=Get-VM -name "test" - Remove-HFSFilter -VM $VM - - Description - ----------- - This example remove any HFS filter applied to the VM - - .NOTES - FunctionName : Remove-HFSFilter - Created by : VMware - - Modified by : VMware - Date Modified : 2023/04/10 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> - -function Remove-HFSFilter { - [OutputType([System.Void])] - [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] - param ( [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'VM')] - [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $VM, - [Parameter( Mandatory = $false, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem = @() - ) - Begin { - - } - Process { - foreach ( $VimVms in $(Get-VM -Name $VM)) { - [VMware.Vim.VirtualDeviceConfigSpec[]] $virtualDeviceSpecs = @() - foreach ($device in $VimVms.ExtensionData.COnfig.hardware.device) { - if ($device -is [VMware.Vim.VirtualDisk]) { - #$device || Format-Table -RepeatHeader - foreach ($Filter in $device.IndependentFilters) { - $Value = $Filter.FilterCapabilities.foreach{ ($_.key -eq 'vendorId')?$_.value:'' } - if ($Value) { - $Found = (!$CloudFileSystem) - foreach ($Cl in $CloudFileSystem) { - if ($Value[0].contains($Cl.Id)) { - $Found = $true - break - } - } - if ($Found) { - $deviceSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec - $deviceSpec.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit - $deviceSpec.Device = $device - $deviceSpec. FilterSpec = [VMware.Vim.VirtualMachineEmptyIndependentFilterSpec]::new() - $virtualDeviceSpecs += $deviceSpec - } - break - } - - } - } - } - if ($virtualDeviceSpecs -and $PSCmdlet.ShouldProcess($VimVms)) { - $vmConfigSpec = [VMware.Vim.VirtualMachineConfigSpec]::new() - $vmConfigSpec.DeviceChange = $virtualDeviceSpecs - $vimVms.extensionData.ReconfigVM($vmConfigSpec) - } - } - } - End { - - } -} - - -Set-Alias -Name Connect-VCDRServer -Value Connect-VCDRService -Set-Alias -Name Disconnect-VCDRServer -Value Disconnect-VCDRService -Export-ModuleMember -Function Connect-VCDRService -Alias Connect-VCDRServer -Export-ModuleMember -Function Disconnect-VCDRService -Alias Disconnect-VCDRServer -Export-ModuleMember -Function Get-VCDRInstance -Export-ModuleMember -Function Get-DefaultVCDRInstance -Export-ModuleMember -Function Set-DefaultVCDRInstance -Export-ModuleMember -Function Get-VCDRCloudFileSystem -Export-ModuleMember -Function Get-VCDRProtectedSite -Export-ModuleMember -Function Get-VCDRProtectionGroup -Export-ModuleMember -Function Get-VCDRSnapshot -Export-ModuleMember -Function Get-VCDRProtectedVm -Export-ModuleMember -Function Get-VCDRRecoverySddc -Export-ModuleMember -Function Connect-VCDRService -Export-ModuleMember -Function Disconnect-VCDRService -Export-ModuleMember -Function Get-VCDRInstance -Export-ModuleMember -Function Get-DefaultVCDRInstance -Export-ModuleMember -Function Set-DefaultVCDRInstance -Export-ModuleMember -Function Get-VCDRCloudFileSystem -Export-ModuleMember -Function Get-VCDRProtectedSite -Export-ModuleMember -Function Get-VCDRProtectionGroup -Export-ModuleMember -Function Get-VCDRSnapshot -Export-ModuleMember -Function Get-VCDRProtectedVm -Export-ModuleMember -Function Get-VCDRRecoverySddc -Export-ModuleMember -Function Get-VmFromVCDR -Export-ModuleMember -Function Remove-HFSFilter -Export-ModuleMember -Function Get-HFSFilter \ No newline at end of file diff --git a/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.dll b/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.dll deleted file mode 100644 index 8ccfb3e..0000000 Binary files a/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.dll and /dev/null differ diff --git a/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.psd1 b/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.psd1 deleted file mode 100644 index ae41597..0000000 --- a/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.psd1 +++ /dev/null @@ -1,121 +0,0 @@ -# -# Module manifest for module 'VMware.VCDRService' Core & Desktop -# -# Generated by: build.ps1 -# -# Generated on: 11/06/2023 16:07:08 -# -@{ - # Version number of this module. - ModuleVersion = '7.26.0' - - # Supported PSEditions - CompatiblePSEditions = 'Core' - - # Assemblies that must be loaded prior to importing this module - RequiredAssemblies = @("VMware.VCDRService.dll") - - # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '6.0.4' - # Script module or binary module file associated with this manifest. - RootModule = 'VMware.VCDRService.psm1' - - # ID used to uniquely identify this module - GUID = '151f6501-a080-4b44-851f-3626c97ea1a3' - - # Author of this module - Author = 'VMware' - - # Company or vendor of this module - CompanyName = 'VMware, Inc.' - - # Copyright statement for this module - Copyright = '2023(c) VMware Inc. All rights reserved.' - - # Description of the functionality provided by this module - Description = 'PowerCLI VMware Cloud Disaster Recovery module' - - # Processor architecture (None, X86, Amd64) required by this module - # ProcessorArchitecture = '' - - # Modules that must be imported into the global environment prior to importing this module - RequiredModules = @( - @{"ModuleName"="VMware.VimAutomation.Sdk";"ModuleVersion"="12.7.0.20067606"} - @{"ModuleName"="VMware.VimAutomation.Common";"ModuleVersion"="12.7.0.20067789"} - @{"ModuleName"="VMware.Vim";"ModuleVersion"="7.0.3.19601056"} - @{"ModuleName"="VMware.VimAutomation.Core";"ModuleVersion"="12.7.0.20091293"} - ) - - # Script files (.ps1) that are run in the caller's environment prior to importing this module. - # ScriptsToProcess = @() - - # Type files (.ps1xml) to be loaded when importing this module - #TypesToProcess = @("Types.ps1xml") - - # Format files (.ps1xml) to be loaded when importing this module - # FormatsToProcess = @() - - # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - # NestedModules = @() - - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - # FunctionsToExport = @() - - # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = @("Connect-VCDRService","Disconnect-VCDRService","Get-VCDRInstance","Get-DefaultVCDRInstance","Set-DefaultVCDRInstance", "Get-VCDRCloudFileSystem", "Get-VCDRProtectedSite", "Get-VCDRProtectionGroup", "Get-VCDRSnapshot", "Get-VCDRProtectedVm", "get-VCDRRecoverySddc","Get-VmFromVCDR","Remove-HFSFilter","Get-HFSFilter") - - # Variables to export from this module - VariablesToExport = '*' - - # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. - AliasesToExport = @("Connect-VCDRServer", "Disconnect-VCDRServer") - - # DSC resources to export from this module - # DscResourcesToExport = @() - - # List of all modules packaged with this module - # ModuleList = @() - - # List of all files packaged with this module - # FileList = @() - - # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. - PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() - - # A URL to the license for this module. - LicenseUri = 'https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery/blob/main/LICENSE' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery' - - # A URL to an icon representing this module. - IconUri = 'https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/1710f7ccbdd9fe9a3ab3f000e920fa6e8e042c63/resources/powercli-psgallery-icon.svg' - - # ReleaseNotes of this module - ReleaseNotes = 'VMware Cloud Disaster Recovery PowerShell CmdLets' - - # Prerelease string of this module - #Prerelease = 'Alpha' - - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = False - - # External dependent modules of this module - # ExternalModuleDependencies = @() - - } # End of PSData hashtable - - } # End of PrivateData hashtable - - # HelpInfo URI of this module - # HelpInfoURI = '' - - # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. - # DefaultCommandPrefix = '' - -} diff --git a/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.psm1 b/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.psm1 deleted file mode 100644 index eb4b065..0000000 --- a/publish/VMware.VCDRService/7.26.0/netcore/VMware.VCDRService.psm1 +++ /dev/null @@ -1,1114 +0,0 @@ -################################################################################# -# Copyright (C) 2022, VMware Inc -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -################################################################################# - -class AWSRegions : System.Management.Automation.IValidateSetValuesGenerator { - [String[]] GetValidValues() { - return $Script:AwsActiveRegion - } -} - -class HFSFilter { - [String ]$VendorId - [String ]$DiskUuid - [String ]$FileName - HFSFilter ( $VendorId, $DiskUuid, $FileName) { - $this.VendorId = $VendorId - $this.DiskUuid = $DiskUuid - $this.FileName = $FileName - } -} - -New-Variable -Scope Script -Name DefaultVCDRService -New-Variable -Scope Script -Option Constant -Name AWSRegions -Value @('us-east-2', 'us-east-1', 'us-west-1', 'us-west-2', 'af-south-1', 'ap-east-1', 'ap-southeast-3', 'ap-south-1', 'ap-northeast-3', 'ap-northeast-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'ca-central-1', 'eu-central-1', 'eu-west-1', 'eu-west-2', 'eu-south-1', 'eu-west-3', 'eu-north-1', 'me-south-1', 'sa-east-1', 'unknow') -New-Variable -Scope Script -Name AwsActiveRegion -Value $AWSRegions -New-Variable -Scope Script -Name PagingSize -Value 100 -New-Variable -Scope Script -Option Constant -Name NotConnectedMsg -Value 'You are not currently connected to any servers. Please connect first using a Connect cmdlet.' - -<# - .SYNOPSIS - This cmdlet establishes a connection to a VCDR Service. - .DESCRIPTION - This cmdlet establishes a connection to a VCDR Service. The cmdlet starts a new session or re-establishes - a previous session with a VCDR Server system using the specified parameters. - .PARAMETER Token - The tokne used to authenticate VMC - .PARAMETER Region - The Region set as default for any cmdlet operation - .PARAMETER Server - The Server set as default for any cmdlet operation (alternative connection) - .PARAMETER cspBaseUrl - Specifies the IP address or the DNS name of the VMware managed cloud service. If not specified, the cmdlet assumes that you are connecting to the public commercial instance and the default value of - `vmc.vmware.com` is used - .PARAMETER vcdrBackendUrl - Specifies the IP address or the DNS name of the VMware managed disaster recovery cloud service. If not specified, the cmdlet assumes that you are connecting to the public commercial instance and the default value of - `vdp.vmware.com` is used - .EXAMPLE - $token="" - - $VCDR=Connect-VCDRService -token $token - - Description - ----------- - This example connect to a VCDR Service using a VMC token - - - .NOTES - FunctionName : Connect-VCDRService - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -Function Connect-VCDRService { - [OutputType([VMware.VCDRService.VCDRService])] - [CmdletBinding(DefaultParameterSetName = 'Default')] - Param( - [Parameter( Mandatory = $true, ParameterSetName = 'Default')] - [Parameter( Mandatory = $true, ParameterSetName = 'Host')] - [String] $Token, - [Parameter( Mandatory = $false, ParameterSetName = 'Default')] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region, - - [Parameter( Mandatory = $false, ParameterSetName = 'Host')] - [Parameter( Mandatory = $false, ParameterSetName = 'Default')] - [String] $cspBaseUrl , - - [Parameter( Mandatory = $false, ParameterSetName = 'Default')] - [String] $vcdrBackendUrl, - - [Parameter( Mandatory = $true, ParameterSetName = 'Host')] - [String] $Server - ) - if ($Script:DefaultVCDRService) { - # if ($Script:DefaultVCDRService.CompareToken($Token)) - # { - # throw 'Already connected to Org:' + $Script:DefaultVCDRService.OrgId + ' . Use Disconnect-VCDRService to disconnect from this Org.' - # } - $Script:DefaultVCDRService.Disconnect - } - if ($Server) { - [System.Uri] $serverUri = [System.Uri]"https://$Server" - [VMware.VCDRService.VCDRService] $VCDRServiceClient = New-Object VMware.VCDRService.VCDRService($Token, $serverUri, $cspBaseUrl) - } else { - [VMware.VCDRService.VCDRService] $VCDRServiceClient = New-Object VMware.VCDRService.VCDRService($Token, $cspBaseUrl, $vcdrBackendUrl) - } - Set-Variable -Scope Script -Name DefaultVCDRService -Value $VCDRServiceClient - $Script:AwsActiveRegion = $VCDRServiceClient.GetActiveRegions() - return $VCDRServiceClient -} - -<# - .SYNOPSIS - This cmdlet closes the connection to a VCDR Service . - .DESCRIPTION - This cmdlet closes the connection to a VCDR Service . - - .EXAMPLE - $token="" - $VCDR=Connect-VCDRService -token $token - - Disconnect-VCDRService - - Description - ----------- - This example connect to a VCDR Server system using a VMC token.Then disconnects from the specified server. - - - .NOTES - FunctionName : Disconnect-VCDRService - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -Function Disconnect-VCDRService { - if ($Script:DefaultVCDRService) { - $Script:DefaultVCDRService.Disconnect() - Remove-Variable -Scope Script -Name DefaultVCDRService - Set-Variable -Scope Script -Name AwsActiveRegion -Value $AWSRegions - } -} - - - - -<# - .SYNOPSIS - This cmdlet return the list of VCDR instances available in the Org . - .DESCRIPTION - This cmdlet return each VCDR Server instance on each available region. - .PARAMETER Region - Return the VCDR server for this specific region - .EXAMPLE - $token="" - $VCDR=Connect-VCDRService -token $token - Get-VCDRInstance - - Disconnect-VCDRService - - Description - ----------- - This example connect to a VCDR Server system using a VMC token.Set the new default VCDR Server and then disconnects. - - - .NOTES - FunctionName : Get-VCDRInstance - Created by : VMware - - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> - -Function Get-VCDRInstance { - [OutputType([VMware.VCDRService.VcdrSummary[]])] - param( - [Parameter( Mandatory = $False)] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region - ) - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.VcdrSummary[]] $Result = @() - $Result = $Script:DefaultVCDRService.GetVcdrInstances($Region) - return $Result - } else { - throw $NotConnectedMsg - } - -} - - - - -<# - .SYNOPSIS - This cmdlet set the default VCDR Server in the Org . - .DESCRIPTION - This cmdlet set the defult server. - .PARAMETER Region - The Region set as default for any cmdlet operation - .EXAMPLE - $token="" - $VCDR=Connect-VCDRService -token $token - Set-DefaultVCDRInstance -Region eu-west-1 - - Disconnect-VCDRService - - Description - ----------- - This example connect to a VCDR Server system using a VMC token.Set the new default VCDR Server and then disconnects. - - - .NOTES - FunctionName : Set-DefaultVCDRInstance - Created by : VMware - - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> - -Function Set-DefaultVCDRInstance { - [OutputType([VMware.VCDRService.VcdrSummary])] - [CmdletBinding(DefaultParameterSetName = 'Default')] - param( - [Parameter( Mandatory = $True)] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region - ) - if ($Script:DefaultVCDRService) { - $Server = $Script:DefaultVCDRService.SelectRegion($Region) - $Result = New-Object -TypeName 'VMware.VCDRService.VcdrSummary' -ArgumentList $Server - return $Result - } else { - throw $NotConnectedMsg - } -} - - -<# - .SYNOPSIS - This cmdlet return the default VCDR Server in the Org . - .DESCRIPTION - This cmdlet return the defult server. - - .EXAMPLE - $token="" - $VCDR=Connect-VCDRService -token $token -region us-west-2 - Get-DefaultVCDRInstance - - Disconnect-VCDRService - - Description - ----------- - This example connect to a VCDR Server system using a VMC token.Return the default VCDR Server and then disconnects. - - - .NOTES - FunctionName : Get-DefaultVCDRInstance - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -Function Get-DefaultVCDRInstance { - [OutputType([VMware.VCDRService.VcdrSummary])] - $Server = $Script:DefaultVCDRService.ActiveVcdrInstance - if ($Script:DefaultVCDRService) { - $Result = New-Object -TypeName 'VMware.VCDRService.VcdrSummary' -ArgumentList $Server - return $Result - } else { - throw $NotConnectedMsg - } - -} - - - - - -<# - .SYNOPSIS - List of cloud file systems - .DESCRIPTION - Get a list of any deployed cloud file systems in your VMware Cloud DR organization with details. - .PARAMETER Region - Specifies the region on which you want to run the cmdlet. If no value is provided to this parameter, the command runs on the default region. - .PARAMETER Name - The name of the Cloud File System - .PARAMETER Id - The identifier of the cloud file system. - .EXAMPLE - Get-VCDRCloudFileSystem -Name "cloud-backup-1" - - Description - ----------- - This example shows recalling of any Cloud Files System that matches the given name - - .EXAMPLE - Get-VCDRCloudFileSystem -Region us-west-2 - - Description - ----------- - This example shows recalling of any Cloud Files System residing in us-west-2 region - - .EXAMPLE - Get-VCDRCloudFileSystem -Id "dbd913aa-6cbe-11ec-9871-0a3e56ef2005" - - Description - ----------- - This example shows recalling of any Cloud Files System that matches the given id - .NOTES - FunctionName : Get-VCDRCloudFileSystem - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -Function Get-VCDRCloudFileSystem { - [CmdletBinding(DefaultParameterSetName = 'Default')] - [OutputType([VMware.VCDRService.CloudFileSystem[]])] - Param( - [Parameter( Mandatory = $false)] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region, - [Parameter( Mandatory = $false, ParameterSetName = 'ByName', HelpMessage = 'The name of the Cloud File System ')] - [String] $Name , - [Parameter( Mandatory = $false, ParameterSetName = 'ById', HelpMessage = 'The identifier of the cloud file system.')] - [String] $Id - ) - Begin { - if ($Script:DefaultVCDRService) { - $Server = $Script:DefaultVCDRService.SelectRegion($Region) - } else { - throw $NotConnectedMsg - } - [VMware.VCDRService.CloudFileSystem[]] $Result = @() - } - Process { - $cfs = $Server.GetCloudFileSystems() - if ($cfs.Cloud_file_systems) { - if ($name) { - $cf = $cfs.Cloud_file_systems | Where-Object { $_.Name -eq $Name } - if ($cf) { - $Result += $Server.GetCloudFileSystemDetails($cf.id) - } - } elseif ($id) { - $cf = $cfs.Cloud_file_systems | Where-Object { $_.Id -eq $id } - if ($cf) { - $Result += $Server.GetCloudFileSystemDetails($cf.id) - } - } else { - foreach ($cf in $cfs.Cloud_file_systems) { - $Result += $Server.GetCloudFileSystemDetails($cf.Id) - } - } - } - } - End { - return $Result - } -} - - -<# - .SYNOPSIS - List of protected sites. - .DESCRIPTION - Get a list of all protected sites associated with an individual cloud file system with details. - A protected site is a logical grouping of vCenters with VMs that are "protected" by the DRaaS Connector using snapshot replication to a cloud file system. - A protected site is associated with a unique cloud file system. - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of all protected sites. - .PARAMETER Vcenter - Unique identifier(s) of one or more vCenter(s) - .PARAMETER ProtectionGroup - Unique identifier(s) of one or more Protection Group(s) - .EXAMPLE - $CloudFS=Get-VCDRProtectedSite -CloudFileSystem "dbd913aa-6cbe-11ec-9871-0a3e56ef2005" - Get-VCDRProtectedSite -CloudFileSystem $CloudFS - - Description - ----------- - This example shows list any protected site protected by the Cloud Files System dbd913aa-6cbe-11ec-9871-0a3e56ef2005 - - .NOTES - FunctionName : Get-VCDRProtectedSite - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> - -Function Get-VCDRProtectedSite { - [CmdletBinding(DefaultParameterSetName = 'Default')] - [OutputType([VMware.VCDRService.ProtectedSite[]])] - Param( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem, - [Parameter( Mandatory = $false , HelpMessage = 'vCenter')] - [VMware.VimAutomation.Types.VIServer[]] $Vcenter , - [Parameter( Mandatory = $false, HelpMessage = 'Protection Group')] - [VMware.VCDRService.ProtectionGroupDetails[]] $ProtectionGroup - - ) - Begin { - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.ProtectedSite[]] $Result = @() - - $protectedSitesFilterSpec = New-Object -TypeName 'VMware.VCDRService.ProtectedSitesFilterSpec' - $protectedSitesFilterSpec.Protection_group_ids = New-Object -TypeName System.Collections.Generic.List[String] - $protectedSitesFilterSpec.Vcenter_ids = New-Object -TypeName System.Collections.Generic.List[String] - - if ($ProtectionGroup) { - foreach ($item in $ProtectionGroup) { - $protectedSitesFilterSpec.Protection_group_ids.Add($item.Id) - } - } - if ($Vcenter) { - foreach ($item in $Vcenter) { - $protectedSitesFilterSpec.Vcenter_ids.Add($item.InstanceUuid) - } - } else { - foreach ($vi in $global:DefaultVIServers) { - $protectionGroupsFilterSpec.Vcenter_ids.Add($vi.InstanceUuid) - } - } - } else { - throw $NotConnectedMsg - } - } - Process { - foreach ($Cfs in $CloudFileSystem) { - $Server = $Cfs.Server - [String] $Cursor = $Null - [VMware.VCDRService.ProtectedSiteSummary[]]$protectedSites = @() - do { - $protectedSitesResponse = $Server.GetProtectedSites($Cfs, $PagingSize, $protectedSitesFilterSpec, $Cursor) - if (! $protectedSitesResponse) { - break - } - $protectedSites += $protectedSitesResponse.Protected_sites - $Cursor = $protectedSitesResponse.Cursor - } while ($Cursor -and $protectedSitesResponse.Protected_sites -gt 0 ) - - foreach ($ps in $protectedSites) { - $Result += $Server.GetProtectedSiteDetails($Cfs, $ps.Id) - } - } - } - End { - return $Result - } -} - - - -<# - .SYNOPSIS - List of any protection groups associated with an individual cloud file system. - .DESCRIPTION - Get a detailed list of all protection groups associated with an individual cloud file system - A protection group defines a collection of VMs on a protected site that are being snapshotted and replicated to a cloud file system. - A protection group is associated with exactly one protected site (and by extension, exactly one cloud file system). - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of all protected sites - .PARAMETER vCenter - List of vCenters ID to be used as filter - .PARAMETER Site - List of Sites ID to be used as filter - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $ProtectionGroups=Get-VCDRProtectionGroup -CloudFileSystem $cloudFileSystem - - Description - ----------- - This example shows any protecion groups associated with the cloud file system - - .NOTES - FunctionName : Get-VCDRProtectionGroup - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> -Function Get-VCDRProtectionGroup { - [OutputType([VMware.VCDRService.ProtectionGroup[]])] - [CmdletBinding()] - Param( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem, - [Parameter( Mandatory = $false , HelpMessage = 'vCenter')] - [VMware.VimAutomation.Types.VIServer[]] $Vcenter , - [Parameter( Mandatory = $false, HelpMessage = 'Site ID')] - [String[]] $Site - ) - Begin { - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.ProtectionGroup[]] $Result = @() - - $protectionGroupsFilterSpec = New-Object -TypeName 'VMware.VCDRService.ProtectionGroupsFilterSpec' - $protectionGroupsFilterSpec.Site_ids = New-Object -TypeName System.Collections.Generic.List[String] - $protectionGroupsFilterSpec.Vcenter_ids = New-Object -TypeName System.Collections.Generic.List[String] - if ($Site) { - foreach ($item in $Site) { - $protectionGroupsFilterSpec.Site_ids.Add($item) - } - } - if ($Vcenter) { - foreach ($item in $Vcenter) { - $protectionGroupsFilterSpec.Vcenter_ids.Add($item.InstanceUuid) - } - } else { - foreach ($vi in $global:DefaultVIServers) { - $protectionGroupsFilterSpec.Vcenter_ids.Add($vi.InstanceUuid) - } - } - } else { - throw $NotConnectedMsg - } - } - Process { - foreach ($Cfs in $CloudFileSystem) { - $Server = $CloudFileSystem.Server - [VMware.VCDRService.ProtectionGroupSummary[]] $protectedGroups = @() - [String] $Cursor = $Null - do { - $protectedGroupsResponse = $Server.GetProtectionGroups($Cfs, $PagingSize, $protectionGroupsFilterSpec, $Cursor) - if (!$protectedGroupsResponse.Protection_groups ) { break } - $protectedGroups += $protectedGroupsResponse.Protection_groups - $Cursor = $protectedGroupsResponse.Cursor - } while ($Cursor -and $protectedGroupsResponse.Protection_groups -gt 0 ) - - foreach ($ps in $protectedGroups) { - $Result += $Server.GetProtectionGroupDetails($Cfs, $ps.Id) - } - } - } - End { - return $Result - } -} - - -<# - .SYNOPSIS - List of any snpashots associated to a specific protection group. - .DESCRIPTION - Get a list of all snpashots in a specific protection group. - A protection group snapshot encodes the point-in-time state of all the VMs defined in a specific protection group. - Protection group snapshots are immutable but are deleted when they expire, or when the containing protection group is deleted. A protection group snapshot is associated with exactly one protection group.. - .PARAMETER ProtectionGroup - Unique identifier(s) of one or more Protection Group(s) - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $ProtectionGroups=Get-VCDRProtectionGroup -CloudFileSystem $cloudFileSystem - Get-VCDRSnapshot -ProtectionGroup $ProtectionGroups - - Description - ----------- - This example shows any snapshot in the protection group - - .NOTES - FunctionName : Get-VCDRSnapshot - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> -Function Get-VCDRSnapshot { - [OutputType([VMware.VCDRService.ProtectionGroupSnapshot[]])] - [CmdletBinding()] - Param( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Protection Groups')] - [VMware.VCDRService.ProtectionGroup[] ] $ProtectionGroups, - [Parameter( Mandatory = $false, HelpMessage = 'Snapshot Id')] - [String ] $SnapshotID - ) - Begin { - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.ProtectionGroupSnapshot[]]$Result = @() - } else { - throw $NotConnectedMsg - } - } - Process { - - if ( $SnapshotID ) { - foreach ($ProtectionGroup in $ProtectionGroups) { - $Server = $ProtectionGroup.Server - $Result += $Server.GetProtectionGroupSnapshotDetails($ProtectionGroup, $SnapshotID) - } - } else { - - foreach ($ProtectionGroup in $ProtectionGroups) { - $Server = $ProtectionGroup.Server - [String] $Cursor = $Null - $Snapshots = [VMware.VCDRService.GetProtectionGroupSnapshotsResponse[]]@() - do { - $protectionGroupSnapshotResponse = $Server.GetProtectionGroupSnapshots( $ProtectionGroup, $PagingSize, $Cursor) - if (!$protectionGroupSnapshotResponse) { break } - if (!$protectionGroupSnapshotResponse.Snapshots) { break } - $Cursor = $protectionGroupSnapshotResponse.Cursor - $Snapshots += $protectionGroupSnapshotResponse.Snapshots - } while ($Cursor -and $protectionGroupSnapshotResponse.Snaphsots -gt 0 ) - foreach ($ps in $Snapshots) { - $Result += $Server.GetProtectionGroupSnapshotDetails($ProtectionGroup, $ps.Id) - } - } - } - } - End { - return $Result - } -} - - - - - - -<# - .SYNOPSIS - List of VMs associated with an individual cloud file system - .DESCRIPTION - A "protected" VM is a VM that is contained in at least one protection group snapshot that has been replicated to a cloud file system. - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of all protected sites - .PARAMETER vCenter - List of vCenters ID to be used as filter - .PARAMETER Site - List of Sites ID to be used as filter - .PARAMETER ProtectionGroup - List of protection groups to be used as filter - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $Vms=Get-VCDRProtectedVm -CloudFileSystem $cloudFileSystem - - Description - ----------- - This example shows any protecion groups associated with the cloud file system - - .NOTES - FunctionName : Get-VCDRProtectedVm - Created by : VMware - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> -Function Get-VCDRProtectedVm { - [OutputType([VMware.VCDRService.VmSummary[]])] - [CmdletBinding()] - Param( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem, - [Parameter( Mandatory = $false , HelpMessage = 'vCenter')] - [VMware.VimAutomation.Types.VIServer[]] $Vcenter , - [Parameter( Mandatory = $false, HelpMessage = 'Site ID')] - [String[]] $Site , - [Parameter( Mandatory = $false, HelpMessage = 'Protection Group ID')] - [VMware.VCDRService.ProtectionGroup[]] $ProtectionGroup , - [Parameter( Mandatory = $false, HelpMessage = 'Protection Group Snapshot ID')] - [VMware.VCDRService.ProtectionGroupSnapshot[]] $ProtectionGroupSnapshot - ) - Begin { - if ($Script:DefaultVCDRService) { - [VMware.VCDRService.VmSummary[]]$Result = @() - - $VmsFilterSpec = New-Object -TypeName 'VMware.VCDRService.VmsFilterSpec' - $VmsFilterSpec.Site_ids = New-Object -TypeName System.Collections.Generic.List[String] - $VmsFilterSpec.Vcenter_ids = New-Object -TypeName System.Collections.Generic.List[String] - $VmsFilterSpec.Protection_group_snapshot_id = New-Object -TypeName System.Collections.Generic.List[String] - $VmsFilterSpec.Protection_group_ids = New-Object -TypeName System.Collections.Generic.List[String] - - if ($Site) { - foreach ($item in $Site) { - $VmsFilterSpec.Site_ids.Add($item) - } - } - if ($Vcenter) { - foreach ($item in $Vcenter) { - $VmsFilterSpec.Vcenter_ids.Add($item.InstanceUuid) - } - } else { - foreach ($vi in $global:DefaultVIServers) { - $protectionGroupsFilterSpec.Vcenter_ids.Add($vi.InstanceUuid) - } - } - if ($ProtectionGroup) { - foreach ($pg in $ProtectionGroup) { - $VmsFilterSpec.Protection_group_ids.Add($pg.id) - } - } - - if ($ProtectionGroupSnapshot) { - foreach ($pgs in $ProtectionGroupSnapshot) { - $VmsFilterSpec.Protection_group_snapshot_id.Add($pgs.Id) - } - } - } else { - throw $NotConnectedMsg - } - } - Process { - foreach ($Cfs in $CloudFileSystem) { - $Server = $CloudFileSystem.Server - [String] $Cursor = $Null - do { - $protectedVirtualMachines = $Server.GetProtectedVirtualMachines($Cfs, $PagingSize, $VmsFilterSpec, $Cursor) - if (!$protectedVirtualMachines) { break } - if (!$protectedVirtualMachines.Vms ) { break } - $Result += $protectedVirtualMachines.Vms - $Cursor = $protectedVirtualMachines.Cursor - } while ($Cursor -and $protectedVirtualMachines.Vms.Count -gt 0 ) - } - } - End { - return $Result - } -} - - - -<# - .SYNOPSIS - List of Recovery SDDCs - .DESCRIPTION - A Recovery SDDC is a VMware Cloud (VMC) software-defined datacenter (SDDC) where protected VMs are created, configured, and powered on during VMware Cloud DR failover. - .PARAMETER Region - Specifies the region on which you want to run the cmdlet. If no value is provided to this parameter, the command runs on the default region. - .PARAMETER Name - The name of the Sddc - .PARAMETER Id - The identifier of the Sddc. - .EXAMPLE - Get-VCDRRecoverySddc -Name "cloud-backup-SDDC" - - Description - ----------- - This example shows the information of the SDDC that matches the given name - - .EXAMPLE - Get-VCDRRecoverySddc - - Description - ----------- - This example shows the information of the any SDDC - .NOTES - FunctionName : Get-VCDRRecoverySddc - Created by : VMware - - Modified by : VMware - Date Modified : 2022/08/01 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - - #> -Function Get-VCDRRecoverySddc { - [OutputType([VMware.VCDRService.RecoverySddc[]])] - [CmdletBinding(DefaultParameterSetName = 'Default')] - Param( - [Parameter( Mandatory = $false)] - [ValidateSet([AWSRegions], ErrorMessage = "Value '{0}' is not a valid region. Try one of: {1}")] - [String] $Region, - [Parameter( Mandatory = $true, ParameterSetName = 'ByName', HelpMessage = 'The name of the Recovery SDDC ')] - [String] $Name , - [Parameter( Mandatory = $true, ParameterSetName = 'ById', HelpMessage = 'The identifier of the Recovery SDDC.')] - [String] $Id - ) - Begin { - if ($Script:DefaultVCDRService) { - $Server = $Script:DefaultVCDRService.SelectRegion($Region) - } else { - throw $NotConnectedMsg - } - [VMware.VCDRService.RecoverySddc[]] $Result = @() - } - Process { - $rSddcs = $Server.GetRecoverySddc() - if ($rSddcs.data) { - if ($name) { - $cf = $rSddcs.data | Where-Object { $_.Name -eq $Name } - if ($cf) { - $Result += $Server.GetRecoverySddcDetails($cf.id) - } - } elseif ($id) { - $cf = $rSddcs.data | Where-Object { $_.Id -eq $id } - if ($cf) { - $Result += $Server.GetRecoverySddcDetails($cf.id) - } - } else { - foreach ($cf in $rSddcs.data) { - $Result += $Server.GetRecoverySddcDetails($cf.Id) - } - } - } - return $Result - } - End { - } -} - - - -<# - .SYNOPSIS - This cmdlet convert virtual machine VCDR object to VimAutomation. - .DESCRIPTION - This cmdlet convert virtual machine VCDR object to VimAutomation. - .PARAMETER VM - The Virtual Machines object to convert - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $Vms=Get-VCDRProtectedVm -CloudFileSystem $cloudFileSystem - $VimVms = Get-VmFromVCDR -VM $Vms -errorAction Continue - Disconnect-VCDRService - - Description - ----------- - This example convert any VMs managed by the $cloudFileSystem to a standard Vim VM - - - .NOTES - FunctionName : Get-VmFromVCDR - Created by : VMware - - Modified by : VMware - Date Modified : 2023/04/10 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -function Get-VmFromVCDR { - [OutputType([VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]])] - [CmdletBinding(DefaultParameterSetName = 'ProtectionGroup')] - param ( - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'VCDR Protected Vms', ParameterSetName = 'ProtectionGroup')][VMware.VCDRService.ProtectionGroup[]] $ProtectionGroup, - [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'VCDR Protected Vms', ParameterSetName = 'Vm')] [VMware.VCDRService.VmSummary[]] $Vm - ) - Begin { - [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $Result = @() - $hash = @{} - } - Process { - if ($global:DefaultVIServers) { - if ($ProtectionGroup) { - foreach ($PrGroup in $ProtectionGroup) { - foreach ($Mspec in $PrGroup.Members_specs) { - foreach ($Folder in $Mspec.Vcenter_folder_paths) { - $FolderParts = $Folder.split('/') - $Parent = Get-Datacenter($FolderParts[0]) - for ($i = 2; $i -lt $FolderParts.Count ; $i++) { - $Parent = Get-Folder -Name $FolderParts[$i] -Location $Parent - } - $Result += Get-VM -Location $Parent -Server $Mspec.Vcenter_id - } - foreach ($vmname in $Mspec.Vcenter_vm_name_patterns) { - $Result += Get-VM -Server $Mspec.Vcenter_id -Name $vmname - } - - foreach ($vmTag in $Mspec.Vcenter_tags) { - $Tag = Get-Tag -Server $Mspec.Vcenter_id -Name $vmTag.Tag_name -Category $vmTag.Category_name - $Result += Get-VM -Server $Mspec.Vcenter_id -Tag $Tag - } - } - } - } - if ($Vm) { - foreach ($lvm in $Vm) { - $NotFound = $true - for ($i = 0; $i -lt $global:DefaultVIServers.Count ; $i++) { - - if ($global:DefaultVIServers[$i].InstanceUuid -eq $lvm.Id.Vcenter_id) { - $hash[$i] += @($lvm.Id.Id) - $NotFound = $false - break - } - } - if ($NotFound -and $ErrorActionPreference -ne 'Continue') { - throw "Please connect vCenter id:$($lvm.Id.Vcenter_id) using Connect-VIServer" - } - } - } - } else { - throw 'Please connect to vCenter using Connect-VIServer' - } - } - End { - if ($Vm) { - for ($i = 0; $i -lt $global:DefaultVIServers.Count ; $i++) { - $Result += Get-VM -Server $global:DefaultVIServers[$i] -Id $hash[$i] - } - - } - return $Result - } -} - - - - -<# - .SYNOPSIS - This cmdlet check if a virtual machine has the HFS filter(LWD) - .DESCRIPTION - This cmdlet check if a virtual machine has the HFS filter(LWD). - .PARAMETER VM - The Virtual Machines object to check - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of HFS - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $Vm=Get-VM -name "test" - Get-HFSFilter -VM $VM - - Description - ----------- - This example return any HFS filter applied to the VM - - .NOTES - FunctionName : Get-HFSFilter - Created by : VMware - - Modified by : VMware - Date Modified : 2023/04/10 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> -function Get-HFSFilter { - [OutputType([HFSFilter[]] )] - [CmdletBinding()] - param ( [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'VM')] - [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $VM, - [Parameter( Mandatory = $false, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem = @() - ) - Begin { - [HFSFilter[]] $Result = @() - } - Process { - foreach ( $VimVms in $(Get-VM -Name $VM)) { - foreach ($device in $VimVms.ExtensionData.COnfig.hardware.device) { - if ($device -is [VMware.Vim.VirtualDisk]) { - foreach ($Filter in $device.IndependentFilters) { - $Value = $Filter.FilterCapabilities.foreach{ ($_.key -eq 'vendorId')?$_.value:'' } - if ($Value) { - $Found = (!$CloudFileSystem) - foreach ($Cl in $CloudFileSystem) { - if ($Value[0].contains($Cl.Id)) { - $Found = $true - break - } - } - if ($Found) { - $Result += [HFSFilter]::new( $Value[0], $device.Backing.Uuid, $device.Backing.FileName) - } - } - break - } - - } - } - } - } - End { - return $Result - } -} - - -<# - .SYNOPSIS - This cmdlet removethe HFS filter from a virtual machine - .DESCRIPTION - This cmdlet removethe HFS filter from a virtual machine. - .PARAMETER VM - The Virtual Machines object to be reconfigured - .PARAMETER CloudFileSystem - Unique identifier of an individual cloud file system. Use the cloud file system ID of the cloud file system for which you want to get a list of HFS - .EXAMPLE - $cloudFileSystem=Get-VCDRCloudFileSystem -name "cloud-backup-1" - $Vm=Get-VM -name "test" - Remove-HFSFilter -VM $VM - - Description - ----------- - This example remove any HFS filter applied to the VM - - .NOTES - FunctionName : Remove-HFSFilter - Created by : VMware - - Modified by : VMware - Date Modified : 2023/04/10 - More info : https://github.com/vmware/vmware-powercli-for-vmware-cloud-disaster-recovery - .LINK - -#> - -function Remove-HFSFilter { - [OutputType([System.Void])] - [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] - param ( [Parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'VM')] - [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $VM, - [Parameter( Mandatory = $false, HelpMessage = 'Cloud FileSystem')] - [VMware.VCDRService.CloudFileSystem[]] $CloudFileSystem = @() - ) - Begin { - - } - Process { - foreach ( $VimVms in $(Get-VM -Name $VM)) { - [VMware.Vim.VirtualDeviceConfigSpec[]] $virtualDeviceSpecs = @() - foreach ($device in $VimVms.ExtensionData.COnfig.hardware.device) { - if ($device -is [VMware.Vim.VirtualDisk]) { - #$device || Format-Table -RepeatHeader - foreach ($Filter in $device.IndependentFilters) { - $Value = $Filter.FilterCapabilities.foreach{ ($_.key -eq 'vendorId')?$_.value:'' } - if ($Value) { - $Found = (!$CloudFileSystem) - foreach ($Cl in $CloudFileSystem) { - if ($Value[0].contains($Cl.Id)) { - $Found = $true - break - } - } - if ($Found) { - $deviceSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec - $deviceSpec.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit - $deviceSpec.Device = $device - $deviceSpec. FilterSpec = [VMware.Vim.VirtualMachineEmptyIndependentFilterSpec]::new() - $virtualDeviceSpecs += $deviceSpec - } - break - } - - } - } - } - if ($virtualDeviceSpecs -and $PSCmdlet.ShouldProcess($VimVms)) { - $vmConfigSpec = [VMware.Vim.VirtualMachineConfigSpec]::new() - $vmConfigSpec.DeviceChange = $virtualDeviceSpecs - $vimVms.extensionData.ReconfigVM($vmConfigSpec) - } - } - } - End { - - } -} - - -Set-Alias -Name Connect-VCDRServer -Value Connect-VCDRService -Set-Alias -Name Disconnect-VCDRServer -Value Disconnect-VCDRService -Export-ModuleMember -Function Connect-VCDRService -Alias Connect-VCDRServer -Export-ModuleMember -Function Disconnect-VCDRService -Alias Disconnect-VCDRServer -Export-ModuleMember -Function Get-VCDRInstance -Export-ModuleMember -Function Get-DefaultVCDRInstance -Export-ModuleMember -Function Set-DefaultVCDRInstance -Export-ModuleMember -Function Get-VCDRCloudFileSystem -Export-ModuleMember -Function Get-VCDRProtectedSite -Export-ModuleMember -Function Get-VCDRProtectionGroup -Export-ModuleMember -Function Get-VCDRSnapshot -Export-ModuleMember -Function Get-VCDRProtectedVm -Export-ModuleMember -Function Get-VCDRRecoverySddc -Export-ModuleMember -Function Connect-VCDRService -Export-ModuleMember -Function Disconnect-VCDRService -Export-ModuleMember -Function Get-VCDRInstance -Export-ModuleMember -Function Get-DefaultVCDRInstance -Export-ModuleMember -Function Set-DefaultVCDRInstance -Export-ModuleMember -Function Get-VCDRCloudFileSystem -Export-ModuleMember -Function Get-VCDRProtectedSite -Export-ModuleMember -Function Get-VCDRProtectionGroup -Export-ModuleMember -Function Get-VCDRSnapshot -Export-ModuleMember -Function Get-VCDRProtectedVm -Export-ModuleMember -Function Get-VCDRRecoverySddc -Export-ModuleMember -Function Get-VmFromVCDR -Export-ModuleMember -Function Remove-HFSFilter -Export-ModuleMember -Function Get-HFSFilter \ No newline at end of file diff --git a/publish/VMware.VCDRService/7.26.0/open_source_licenses.txt b/publish/VMware.VCDRService/7.26.0/open_source_licenses.txt deleted file mode 100644 index 9bcb005..0000000 --- a/publish/VMware.VCDRService/7.26.0/open_source_licenses.txt +++ /dev/null @@ -1,79 +0,0 @@ -open_source_licenses.txt - -VMware PowerCLI for VMware Cloud Disaster Recovery 7.23.0.0 Beta - -====================================================================== - -The following copyright statements and licenses apply to various open -source software packages (or portions thereof) that are included in -this VMware service. - -The VMware service may also include other VMware components, which may -contain additional open source software packages. One or more such -open_source_licenses.txt files may therefore accompany this VMware -service. - -The VMware service that includes this file does not necessarily use all the open -source software packages referred to below and may also only use portions of a -given package. - -==================== TABLE OF CONTENTS ==================== - -The following is a listing of the open source components detailed in -this document. This list is provided for your convenience; please read -further if you wish to review the copyright notice(s) and the full text -of the license associated with each component. - - -SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES - - >>> Newtonsoft.Json-12.0.3 - - - --------------------- SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES -------------------- - - >>> Newtonsoft.Json-12.0.3 - - The MIT License (MIT) - - Copyright (c) 2007 James Newton-King - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - the Software, and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - -====================================================================== - -To the extent any open source components are licensed under the GPL -and/or LGPL, or other similar licenses that require the source code -and/or modifications to source code to be made available (as would be -noted above), you may obtain a copy of the source code corresponding to -the binaries for such open source components and modifications thereto, -if any, (the "Source Files"), by downloading the Source Files from -VMware's website at http://www.vmware.com/download/open_source.html, or -by sending a request, with your name and address to: VMware, Inc., 3401 -Hillview Avenue, Palo Alto, CA 94304, United States of America. All such -requests should clearly specify: OPEN SOURCE FILES REQUEST, Attention -General Counsel. VMware shall mail a copy of the Source Files to you on -a CD or equivalent physical medium. This offer to obtain a copy of the -Source Files is valid for three years from the date you acquired this -Software product. Alternatively, the Source Files may accompany the -VMware service. - -[POWERCLIVCDR72300BSP042822] \ No newline at end of file diff --git a/test-VMsnaplist.ps1 b/test-VMsnaplist.ps1 index 1614a4f..4ff1738 100644 --- a/test-VMsnaplist.ps1 +++ b/test-VMsnaplist.ps1 @@ -72,8 +72,7 @@ Param( ) - -Set-StrictMode -Version 3 + $ErrorActionPreference = 'Stop' if ($Password -and $username) { $secureString = ConvertTo-SecureString -AsPlainText -Force -String $Password @@ -82,7 +81,7 @@ if ($Password -and $username) { $Credential = Get-Credential } -if ( ! $Connect) { +if (! $Connect) { $Version = Get-Content -Path .\VERSION Write-Host "VMware VCDR PowerCLI version $Version" # Import-Module ".\publish\VMware.VCDRService\$Version\VMware.VCDRService.psd1" @@ -97,28 +96,6 @@ if ( ! $Connect) { } } -$r = Get-VM 'Max*' -Get-HFSFilter -VM $r | Format-Table -Remove-HFSFilter -VM $r -WhatIf -$r = Get-VM -Name $r -Get-HFSFilter -VM $r | Format-Table -#$VimVms = Get-VM max-test-removeHFS -#$res = Get-HfsFilter -VM $VimVms - -#$res | Format-Table -RepeatHeader - -#Remove-HfsFilter -VM $VimVms - - -Get-VCDRInstance - -$RecoverySDDC = Get-VCDRRecoverySddc -if ($RecoverySDDC) { - Write-Host 'Recovery SDDCs:' -NoNewline - $RecoverySDDC | Format-Table -} else { - Write-Host 'No Recovery SDDCs configured' -} $cloudFileSystems = Get-VCDRCloudFileSystem if ($cloudFileSystems) { foreach ($cloudFileSystem in $cloudFileSystems) { @@ -158,30 +135,18 @@ if ($cloudFileSystems) { $Snapshots | Format-Table -RepeatHeader } else { Write-Host 'No Snapshots' - } + } + } else { + Write-Host 'No Protection Groups' } - } else { - Write-Host 'No Protection Groups' } - Write-Host 'Protected Sites:' -NoNewline - $ProtectedSites = Get-VCDRProtectedSite -CloudFileSystem $cloudFileSystem -Vcenter $global:DefaultVIServers[0] -ProtectionGroup $ProtectionGroups - $ProtectedSites | Format-Table - #[VMware.VCDRService.VmSummary[]] - $Vms = Get-VCDRProtectedVm -CloudFileSystem $cloudFileSystem - - [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $VimVms = $Vms | Get-VmFromVCDR -ErrorAction Continue - - if ($VimVms) { - $VimVms | Format-Table -RepeatHeader - Write-Host 'Virtual Machines:' -NoNewline - } else { - Write-Host 'No Virtual Machines on this Cloud File System' - } Write-Host "`n********************`n" +}else { + Write-Host 'No VCDR CFS available' } - + Disconnect-VCDRService Write-Host "Bye.`n"