Create Active Directory User Objects using Powershell Without a Password.

Поделиться
HTML-код
  • Опубликовано: 5 окт 2024
  • This is the script to create the AD object. Please remember the Group, OU and Domain Controller needs to be changed accordingly.
    ---------------------------------------------------------------------------
    Import the Active Directory module
    Import-Module ActiveDirectory
    Define the properties for the new user
    $UserName = "JohnDoe"
    $GivenName = "John"
    $Surname = "Doe"
    $OU = "OU=Admins,DC=Galaxy,DC=com" #Must create an OU called Admins or change this to yours.
    $Group = "Administrators" #Change to the Domain admin user or user with proper privileges.
    Create the new user without a password and set the account as disabled
    New-ADUser -Name $UserName `
    -GivenName $GivenName `
    -Surname $Surname `
    -SamAccountName $UserName `
    -UserPrincipalName "$UserName@Galaxy.com" ` #Change
    -Path $OU `
    -Enabled $false # Account is disabled until password is set
    Add the user to the Administrators group
    Add-ADGroupMember -Identity $Group -Members $UserName
    Verify the user is added to the group
    Get-ADGroupMember -Identity $Group | Where-Object { $_.SamAccountName -eq $UserName }

Комментарии •