Jeevan Bobba infrastructure blog logo: an abstract teal J with connected layers

vmwareenterprise

AI Infrastructure Solutions, Hybrid Cloud, and Automation

  • Blog
  • VMware
  • Azure
  • Windows
  • YouTube ↗
  • General
  • PowerShell
  • About Me
  • Contact Me
  • Privacy Policy

Creating and Removing domain accounts in each domain in a forest

April 6, 2022 General, Powershell, Windows 0

Created domain account in each domain add it to domain admin group

$domains = (get-adforest).domains
foreach($domain in $domains){
$accountname = ‘s-coe-‘+($domain -split “.”)[0]+’-DA’
$accountpass = Read-Host -Prompt ‘Enter a unique password for this account’ -AsSecureString
Write-Output “Working on $domain – DA is $accountname”
New-ADUser -name $accountname -SamAccountName $accountname -AccountPassword $accountpass -Enabled $true -Server $domain
start-sleep -Seconds 5
Add-ADGroupMember -Identity “Domain Admins” -Members $accountname -Server $domain
}

Remove domain account in each domain

$domains = (get-adforest).domains
foreach($domain in $domains){
$accountname = ‘s-coe-‘+($domain -split “.”)[0]+’-DA’
get-aduser $accountname -Server $domain | Remove-ADUser -Server $domain -Verbose -Confirm:$false
}

  • Citrix Xen Desktop
  • Citrix Xenapp
  • creating account powershell
  • domain account
  • get-aduser
  • new-aduser
  • Powershell
  • remove-aduser
Previous

Created ISO image using PowerShell

Next

Get DC replication time response

Recent Posts

  • Convert a PowerShell .PS1 File to EXE: A Practical PS2EXE Guide
  • The Remote Computer requires network-level authentication
  • Git Command Cheat Sheet for Beginners
  • Mastering Credential Management in PowerShell: A Comprehensive Guide
  • Discovering SMB Share Permissions on Windows Servers with PowerShell

Recent Comments

No comments to show.

Archives

  • October 2026
  • August 2026
  • July 2025
  • February 2025
  • April 2024
  • August 2022
  • June 2022
  • April 2022
  • March 2022
  • August 2021
  • January 2021
  • December 2020
  • June 2020
  • May 2020
  • April 2019
  • January 2019
  • August 2018
  • July 2018
  • May 2018
  • February 2018
  • January 2018
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • April 2017
  • January 2017
  • December 2016
  • November 2016
  • August 2016
  • July 2016
  • May 2016
  • April 2016
  • March 2016
  • October 2015

Categories

  • Azure
  • Citrix
  • General
  • Git
  • Linux
  • Powershell
  • Uncategorized
  • Vmware
  • Windows

Copyright © 2026 VMWare Enterprise. All Rights Reserved.