Functions/Administration/Add-CdsInstance.ps1
<#
.SYNOPSIS Create new CDS instance. #> function Add-CdsInstance { [CmdletBinding()] param ( [Parameter(Mandatory)] [String] $InstanceDisplayName, [Parameter(Mandatory)] [String] $InstanceDomainName, [Parameter(Mandatory=$true)] [ArgumentCompleter( { Get-CdsRegions })] [String] $Location, [Parameter(Mandatory=$true)] [ValidateSet("Sandbox", "Production")] [String] $Sku, [Parameter(Mandatory=$true)] [String] $CurrencyCodeName, [Parameter(Mandatory=$true)] [int] $Lcid ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); Assert-CdsIsAdmin; } process { $response = New-AdminPowerAppEnvironment -DisplayName $InstanceDisplayName -DomainName $InstanceDomainName -Location $Location -EnvironmentSku $Sku -CurrencyName $CurrencyCodeName -LanguageName $Lcid -ProvisionDatabase -WaitUntilFinished $true; if($response.Code) { throw $response.Error; } $response; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Add-CdsInstance -Alias *; |