Functions/Administration/Set-CdsInstanceMode.ps1
<#
.SYNOPSIS Enable or disable admin mode on given instance #> function Set-CdsInstanceMode { [CmdletBinding()] param ( [Parameter(Mandatory, ValueFromPipeline)] [String] $InstanceDomainName, [Parameter(Mandatory=$true)] [ValidateSet("Normal", "AdminOnly")] [string] $Mode ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); Assert-CdsAdminConnected; } process { $instance = Get-CdsInstance -Name $InstanceDomainName; $runtimeState = "Enabled"; switch ($Mode) { "Normal" { $runtimeState = "Enabled" } "AdminOnly" { $runtimeState = "AdminMode" } } $response = Set-AdminPowerAppEnvironmentRuntimeState -EnvironmentName $instance.Id -RuntimeState $runtimeState -WaitUntilFinished $true; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Set-CdsInstanceMode -Alias *; |