Public/Copy-P1Environment.ps1
function Copy-P1Environment { <# .Synopsis Copy environments between two tenants .Description Copy all environments from one tenant to another. .Parameter InTenant The tenant name to copy from. .Parameter OutTenant The tenant name to copy to. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $InTenant, [Parameter(Mandatory=$true)] [string] $OutTenant ) Process { if (!(Test-Tenant $InTenant)) { Write-Warning "Tenant $InTenant does not exist." return } if (!(Test-Tenant $OutTenant)) { Write-Warning "Tenant $OutTenant does not exist." return } Write-Section "Copying environments..." $sourceDir = Get-EnvironmentsPathFromTenant $InTenant $sourcePath = $sourceDir + "\*" $targetPath = Get-EnvironmentsPathFromTenant $OutTenant Write-Verbose "Copying from $sourcePath to $targetPath" Copy-Item -Recurse $sourcePath $targetPath -Force Write-Section "Copy finished" } } |