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-CdsIsAdmin; } process { $instance = Get-CdsInstance -Name $InstanceDomainName; $runtimeState = "Enabled"; switch ($state) { "Normal" { $runtimeState = "Enabled" } "AdminOnly" { $runtimeState = "AdminMode" } } Set-AdminPowerAppEnvironmentRuntimeState -EnvironmentName $instance.EnvironmentName -RuntimeState $runtimeState -WaitUntilFinished; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Set-CdsInstanceMode -Alias *; |