Skip to content

PS1 scripts

To setup ADDS on Windows Server

#ps1
# Install ADDS feature
Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools

# Import ADDS Deployment module
Import-Module ADDSDeployment

# Create new forest and promote to Domain Controller
Install-ADDSForest `
    -DomainName "example.com" `
    -DomainNetbiosName "EXAMPLE" `
    -ForestMode "WinThreshold" `
    -DomainMode "WinThreshold" `
    -InstallDNS:$true `
    -CreateDnsDelegation:$false `
    -DatabasePath "C:\Windows\NTDS" `
    -LogPath "C:\Windows\NTDS" `
    -SysvolPath "C:\Windows\SYSVOL" `
    -Force:$true `
    -SafeModeAdministratorPassword (ConvertTo-SecureString "P@$$w0rd" -AsPlainText -Force)

To add users to AD

# Create a user in a specific OU, with no password expiration and no forced change at first login

New-ADUser `
    -Name "John Doe" `
    -GivenName "John" `
    -Surname "Doe" `
    -SamAccountName "jdoe" `
    -UserPrincipalName "[email protected]" `
    -Path "OU=Employees,DC=example,DC=local" `
    -AccountPassword (ConvertTo-SecureString "P@ssword123" -AsPlainText -Force) `
    -Enabled $true `
    -PasswordNeverExpires $true `
    -ChangePasswordAtLogon $false

To know the drive letter with label

$drive = Get-Volume | Where-Object { $_.FileSystemLabel -match "config-2" }
$filePath = $drive.DriveLetter + ":\openstack\latest\"