DifferentialProfile/DifferentialProfile.psm1
Import-Module -Name @(Join-Path $PSScriptRoot .. | Join-Path -ChildPath Util | Join-Path -ChildPath Util) function New-RMDifferentialProfile { param( [string] $Name, [System.Object] $ScheduledAt, [string] $OrganizationId, [string] $ApplianceId, [string] $MigrationId, [bool] $ShutdownSource, [bool] $ShutdownTarget, [bool] $RemoveTargetAgent, [System.Object] $MigrationInstructions, [System.Object] $TargetProperties, [bool] $IgnoreValidationErrors, [string] $SourceUsername, [string] $SourcePrivateKey, [string] $SourcePassword, [string] $SourceDomain, [string] $SourceHost, [string] $TargetUsername, [string] $TargetPrivateKey, [string] $TargetPassword, [string] $TargetDomain, [string] $TargetHost, [string] $TargetIPAddress, [string] $SourceId, [System.Object] $TransferMethod, [string] $TransferTechnology, [string] $TransferMode ) if ([string]::IsNullOrEmpty($ScheduledAt)) { # To run "now", FE requires that the $ScheduledAt to be empty array $ScheduledAt = @() } else { $ScheduledAt = @($ScheduledAt) } $DifferentialProfiles = @{ "name" = $Name "organization_id" = $OrganizationId "description" = $null "appliance_id" = $ApplianceId "schedule" = $ScheduledAt "transfer_mode" = $TransferMode "differential_configs" = @( @{ "migration" = $MigrationId "source_id" = $SourceId "target" = @{ "credentials" = @{ "domain" = $TargetDomain "password" = $TargetPassword "private_key" = $TargetPrivateKey "storage" = 'local' "username" = $TargetUsername } "host" = $TargetHost } "source" = @{ "credentials" = @{ "domain" = $SourceDomain "password" = $SourcePassword "private_key" = $SourcePrivateKey "storage" = 'local' "username" = $SourceUsername } "host" = $SourceHost } "shutdown_source" = $ShutdownSource "shutdown_target" = $ShutdownTarget "transfer_type" = $TransferMethod "remove_target_agent" = $RemoveTargetAgent "transfer_technology" = "bbt" "target_properties" = $TargetProperties "migration_instructions" = $MigrationInstructions "target_ip" = $TargetIPAddress "ignore_validation_errors" = $IgnoreValidationErrors } ) } | ConvertTo-Json -Depth 100 $RMLoginResult = Get-Variable -Name "RMContext-UserLogin" -ValueOnly $Uri = Get-Variable -Name "RMContext-ReactorURI" -ValueOnly $Headers = @{ Accept = "application/rm+json" "X-Auth-Token" = $RMLoginResult.token } $Params = @{ Method = "Post" Uri = $Uri + "/differentialprofiles" Body = $DifferentialProfiles ContentType = "application/json" Headers = $Headers } Invoke-RMRestMethod -Params $Params } function Get-RMDifferentialProfileById { param( [string] $DifferentialProfileId ) $RMLoginResult = Get-Variable -Name "RMContext-UserLogin" $Uri = Get-Variable -Name "RMContext-ReactorURI" $Headers = @{ Accept = "application/rm+json" "X-Auth-Token" = $RMLoginResult.Value.token } $Params = @{ Method = "Get" Uri = $Uri.Value + "/differentialprofiles/" + $DifferentialProfileId Headers = $Headers } return Invoke-RMRestMethod -Params $Params } |