Skip to main content

AD user Export

Mit diesem Script können Sie vorhandene Accounts/Mitarbeiter aus dem existierenden AD exportieren.

Script

$account_type_name = "Verwaltung AD" #Name of account type in nubeto
# Create an empty list to store the objects
$employeeList = @()

$ad_users = Get-ADUser -Filter * -Properties *

Foreach ($ad_user in $ad_users) {
  $employee = [PSCustomObject]@{
      "salutation" = $null #Default, change later 
      "titel" = $ad_user.personalTitle
      "firstname" = $ad_user.givenname
      "lastname" = $ad_user.surname
      "personnel_number" = $ad_user.employeeNumber
      "datev_id" = $null 
      "birthdate" = $null
      "start_of_contract" = $null
      "end_of_contract" = $null
      "status" = "Aktiv"
      "job_title" = $ad_user.title
      "phone_mobile" = $ad_user.mobile
      "phone" = $ad_user.telephoneNumber
      "primary_organizational_unit" = $null
      "primary_role" = $null
      "global_roles" = $null
      "additional_roles" = $null
      "accounts" = "$($ad_user.userprincipalname):$account_type_name"
  }
  $employeeList += $employee
}

# Export the list as a CSV file
$employeeList | Export-Csv -Path "C:\output.csv" -NoTypeInformation -Encoding utf8