Purpose
List AD users with the most important properties and then work with them in Excel.
Steps
Run te script:
# Importar el módulo de Active Directory
Import-Module ActiveDirectory
# Obtener todos los usuarios y seleccionar los campos deseados
Get-ADUser -Filter * -Property
SamAccountName, DisplayName, CN, Enabled, LockedOut,
AccountExpirationDate, EmailAddress, WhenCreated, LastLogonDate,
PasswordLastSet, LogonWorkstations, PasswordNeverExpires,
PasswordNotRequired,
DistinguishedName, Description
Select-Object SamAccountName,
DisplayName,
CN,
Enabled,
LockedOut,
AccountExpirationDate,
EmailAddress,
WhenCreated,
LastLogonDate,
PasswordLastSet,
LogonWorkstations,
@{Name="La cuenta expira";Expression={$_.AccountExpirationDate}},
@{Name="la contraseña nunca expira";Expression={$_.PasswordNeverExpires}},
@{Name="no requiere contraseña";Expression={$_.PasswordNotRequired}},
DistinguishedName,
Description |
Export-Csv -Path "C:\tmp\Usuarios30012025.csv" -NoTypeInformation -Encoding UTF8 -Delimiter "#"
We will be left with an output like this
By GoN | Published: Jan 2025 | Last Updated: