PHP_AdminTool_Projekt/scripts/powershell/check_environment.ps1
blaerf 9f0e534e20 develop (#28)
Co-authored-by: tg95 <tg95@noreply.localhost>
Co-authored-by: Taarly <lownslow.music@gmail.com>
Co-authored-by: taarly <lownslow.music@gmail.com>
Co-authored-by: ViperioN1339 <stezel1989@outlook.de>
Co-authored-by: MuchenTuchen31 <yasin.mine31@gmail.com>
Reviewed-on: https://git.eckertplayground.de/taarly/PHP_AdminTool_Projekt/pulls/28
Co-authored-by: blaerf <blaerf@gmx.de>
Co-committed-by: blaerf <blaerf@gmx.de>
2025-12-17 14:28:04 +00:00

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