AD_user scripts

This commit is contained in:
2026-03-04 13:52:31 +01:00
parent ac1123c989
commit 0c7d172552
4 changed files with 239 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
<#
.SYNOPSIS
Reszletes informaciokat kerdez le egy AD felhasznalorol (Allgemein, Adresse, Organisation fulek).
#>
param (
[Parameter(Mandatory=$true, HelpMessage="Add meg a felhasznalo nevet (sAMAccountName)")]
[string]$UserName
)
# Ellenorizzuk, hogy az Active Directory modul elerheto-e
if (!(Get-Module -ListAvailable ActiveDirectory)) {
Write-Error "Az 'ActiveDirectory' modul nem talalhato. Kerlek telepitsd az RSAT eszközt!"
return
}
# Importaljuk a modult, ha meg nincs betoltve
if (!(Get-Module ActiveDirectory)) {
Import-Module ActiveDirectory
}
try {
# Az osszes tulajdonsag lekerese
$user = Get-ADUser -Identity $UserName -Properties * -ErrorAction Stop
Write-Host "`n========================================================" -ForegroundColor Cyan
Write-Host " AD FELHASZNALOI ADATOK: $($user.DisplayName) " -ForegroundColor Cyan
Write-Host "========================================================`n" -ForegroundColor Cyan
# --- ALLGEMEIN (Altalanos) ---
Write-Host "[ Allgemein / Altalanos ]" -ForegroundColor Yellow
$allgemein = [PSCustomObject]@{
"Vorname (Keresztnev)" = $user.GivenName
"Nachname (Vezeteknev)" = $user.Surname
"Anzeigename" = $user.DisplayName
"Beschreibung" = $user.Description
"Buero (Iroda)" = $user.Office
"Telefon" = $user.TelephoneNumber
"E-Mail" = $user.EmailAddress
"Webseite" = $user.wWWHomePage
}
$allgemein | Format-List
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
# --- ADRESSE (Cim) ---
Write-Host "[ Adresse / Cim ]" -ForegroundColor Yellow
$adresse = [PSCustomObject]@{
"Strasse" = $user.StreetAddress
"Postfach" = $user.PostOfficeBox
"PLZ (Iranyitoszam)" = $user.PostalCode
"Stadt (Varos)" = $user.L
"Bundesland (Megye)" = $user.St
"Land" = $user.CO
}
$adresse | Format-List
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
# --- ORGANISATION (Szervezet) ---
Write-Host "[ Organisation / Szervezet ]" -ForegroundColor Yellow
# Manager nevenek feloldasa DN-bol
$managerName = "Nincs megadva"
if ($user.Manager) {
try {
$managerName = (Get-ADUser -Identity $user.Manager).Name
} catch {
$managerName = $user.Manager # Ha nem sikerul feloldani, marad a DN
}
}
$org = [PSCustomObject]@{
"Titel (Beosztas)" = $user.Title
"Abteilung (Osztaly)" = $user.Department
"Firma (Ceg)" = $user.Company
"Vorgesetzter (Fonok)" = $managerName
}
$org | Format-List
Write-Host "--------------------------------------------------------" -ForegroundColor Gray
# --- CSOPORTOK LISTAJA ---
$groups = Get-ADPrincipalGroupMembership -Identity $UserName | Select-Object -ExpandProperty Name | Sort-Object
Write-Host "[ Gruppen / Csoporttagsagok ($($groups.Count) db) ]" -ForegroundColor Yellow
if ($groups) {
foreach ($group in $groups) {
Write-Host "- $group"
}
} else {
Write-Host "Csak a Domain Users tagja."
}
} catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException] {
Write-Host "HIBA: A(z) '$UserName' nevu felhasznalo nem talalhato!" -ForegroundColor Red
} catch {
Write-Host "Varatlan hiba tortent: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "`n========================================================`n" -ForegroundColor Cyan