18 lines
632 B
PowerShell
18 lines
632 B
PowerShell
# Returns JSON with information about the environment and AD module availability
|
|
Try {
|
|
$actor = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
|
} Catch {
|
|
$actor = $null
|
|
}
|
|
|
|
# Does the ActiveDirectory module exist?
|
|
$module = Get-Module -ListAvailable -Name ActiveDirectory -ErrorAction SilentlyContinue
|
|
$hasModule = $module -ne $null
|
|
|
|
# Is New-ADUser available?
|
|
$canNewAdUser = (Get-Command New-ADUser -ErrorAction SilentlyContinue) -ne $null
|
|
|
|
$output = @{ success = $true; actor = $actor; module_installed = $hasModule; can_new_aduser = $canNewAdUser }
|
|
Write-Output ($output | ConvertTo-Json -Compress)
|
|
exit 0
|