Functions/Administration/Assert-CdsIsAdmin.ps1
<#
.SYNOPSIS Check if current user has D365 / CDS admin role. #> function Assert-CdsIsAdmin { [CmdletBinding()] param ( ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { # TODO : Handle admin connection with context info # if(-not $Global:CdsContext.IsAdmin) # { # throw "You are not CDS/D365 Admin"; # } } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Assert-CdsIsAdmin -Alias *; |