Skip to content
October 13, 2026
  • Bluesky
  • Facebook
  • Linkedin
  • Mastodon
  • RSS
  • Twitter
  • Youtube

Daily CyberSecurity

Zero-hour alerts. Unmatched analysis.

Primary Menu
  • Home
  • CVE Data
    • CVE Watchtower
    • Top Exploited CVEs
    • CVE Stats by Vendor
    • Q2 2026 Report
    • CVE Alerts
    • CVE Alert Settings
    • Pricing
  • Cyber Criminals
  • Data Leak
  • Free Tools
    • CVSS 3.1 Calculator
    • Certificate Viewer
    • DNS Lookup
    • Encoder & Hash Generator
    • IP / Subnet Calculator
    • Whois Lookup
  • Linux
  • Malware
  • Vulnerability
  • Submit Press Release
  • Weekly Recap
Light/Dark Button
  • Home
  • Technique
  • Use powershell to manage domain users
  • Technique

Use powershell to manage domain users

Do Son June 2, 2017 4 minutes read

In the domain environment, often need to use the command line management domain users, then you can use the Active Directory command line tools Dsquery.exe, or CSVE, and Ldifde, in fact, the use of Windows Powershell to manage the operation is quite convenient.

The following to create a user example: Create a domain user The most basic Windows Powershell script looks like this:

$objOU=[ADSI]”LDAP://OU=People,DC=contoso,DC=com”

$objUser=$objU.Create(“user”,”CN=Mary North”)
$odjUser.Put=(“sAMAccountName”,”mary.north”)
$objUser.SetInfo()

The above code lists the four basic steps for creating a user using Active Directory using Windows Powershell.
The details will be described below.

Connect to the Active Directory container

To create an object like this, it is actually going to create an object for the object’s container. So the first need for the container, the implementation of a certain operation, that is, “method.” The first step is to connect to the container, and Windows Powershell can use the Active Directory service interface type adapter to cut into the Active Directory object. To connect to an Active Directory object, you must submit an LDAP query string, that is, the LDAP: // protocol identifier followed by the object’s DN. So the first line of code should look like this:

$objOU=[ADSI]"LDAP://OU=People,DC=contoso,DC=com"

Windows Powershell needs to use the ADSI type adapter to create objects that represent the People OU and assign it to the component. A variable named objOU reflects the identification of a variable type, starting with obj just a programming standard, but the actual variable can use any name.

Call the Create method

At this point, the variable $ objOU can represent the People OU. You can then use the container’s create method to let the container create the object. The Create method needs to provide two parameters: the object class and the object RDN. The object’s RDN refers to the name of the object under the parent container, and most object classes use the “CN = object name” format as its own RDN. However, the RDN of the OU is in the format “OU = organizational unit name”, and the domain’s RDN is “DN = domain name”. So the following code can use the “CN = Mary North” RDN to create user objects:

$objUser=$objU.Create("user","CN=Mary North")

The resulting object result is assigned to the variable $objUser and uses the variable to represent the object to be created for subsequent operations.

Fill in the user attributes

It is important to note that a new object and its changes are not saved until the changes are merged, and the changes can not be successfully merged before filling in all the necessary attributes. User object must be comfortable including windows 2000 before the login name. The LDAP name of the attribute is sAMAccountName, so the next line of code needs to assign sAMAccountName to the object, and you need to use the Put method. Put is the standard method for writing properties to an object, and Get is the standard method for retrieving object properties. The code here should look like this:

$odjUser.Put=("sAMAccountName","Mary North")

For user objects, there are other mandatory attributes, including the object’s security identifier (SID), but these objects will be automatically created when Active Directory is created when the new user is submitted to the directory.

Using the SetInfo method to merge changes

To merge changes, use the SetInfo method of the Active Directory object. The code here should look like this:

$objUser.SetInfo()

Fill in other user attributes

The above command creates a user that only contains the mandatory sAMAccountName attribute. When creating a user object, you also need to fill in other user attributes. Previously, the use of the user object Put method to write attributes, so here only need to repeatedly call the method, specify the need to add each attribute can be:

$odjUser.Put=(“sAMAccountName”, ”$samAccountName”)

$odjUser.Put=(“displayName”, ”$displayname”)
$odjUser.Put=(“sn”, “$sn”)
$objUser.SetInfo()

What is the user’s password? You can not set the user password using the Put method. Instead, you should use the SetPassword method, for example:

$objUser.SetPassword("passwd")

However, the SetPassword method can only be used after creating a user and calling the SetInfo () method, which means that in fact, we are the preferred to create a good account and then set a password for it. This is not a Windows Powershell bug or limitation, but the actual requirements for Kerberos and LDAP. However, security is not compromised because the account created is disabled.
So the status of the account is actually a flag (flag), can not be directly used Put command settings. The following commands are required:

$objUser.psbase.InvokeSet(“AccountDisabled”,$false)

$objUser.SetInfo()

 

SHARE
Share on FacebookShare on XShare on LinkedInShare on TelegramShare on BlueskyShare on Mastodon
Tags: powershell

Search

Translation

CVE ALERTS
📈

EPSS Spike Alerts
Catch risk spikes before they make headlines.

🎯

Custom EPSS/CVSS
Set score thresholds to effectively filter noise.

🛡️

Exploit Intel
Real-world exploit signals beyond the KEV catalog.

🐙

GitHub Issues
Auto-create alert tickets without duplication.

📬

Weekly Digest
Clean summaries, eliminating email spam.

🏷️

Watchlist Groups
Tag vulnerabilities by team (Infra/AppSec/SOC).

🔀

Smart Routing
Route chat channels based on severity levels.

🚨

RBP Tracker
Early warning detection and tracking system.

Subscribe – $7/mo or try free for 14 days →

🚨 Active Exploits in the Wild

  • CVE-2026-102255CVSS 10.0
    A Pre-authentication SSRF vulnerability exists in the SMA1000 Appliance Work Place interface due to an unintended alternate access...
    Admin intel📅 Updated: Oct 9, 2026
  • CVE-2026-105133CVSS 6.9
    A vulnerability was detected in Ahsay AhsayCBS up to 10.3.2. This affects the function checkSysPwd of the file...
    Admin intel📅 Updated: Oct 9, 2026
  • CVE-2023-22894CVSS 4.9
    Strapi through 4.5.5 allows attackers (with access to the admin panel) to discover sensitive user details by exploiting...
    CISA KEV📅 Added to KEV: Oct 8, 2026
  • CVE-2016-3081CVSS 8.1
    Apache Struts 2.3.19 to 2.3.20.2, 2.3.21 to 2.3.24.1, and 2.3.25 to 2.3.28, when Dynamic Method Invocation is enabled,...
    CISA KEV📅 Added to KEV: Oct 8, 2026
  • CVE-2015-3306CVSS 10.0
    The mod_copy module in ProFTPD 1.3.5 allows remote attackers to read and write to arbitrary files via the...
    CISA KEV📅 Added to KEV: Oct 8, 2026
  • CVE-2015-5477CVSS 7.5
    named in ISC BIND 9.x before 9.9.7-P2 and 9.10.x before 9.10.2-P3 allows remote attackers to cause a denial...
    CISA KEV📅 Added to KEV: Oct 8, 2026
  • CVE-2021-3199CVSS 9.8
    Directory traversal with remote code execution can occur in /upload in ONLYOFFICE Document Server before 5.6.3, when JWT...
    CISA KEV📅 Added to KEV: Oct 8, 2026
  • CVE-2026-94504CVSS 7.2
    Ninja Forms 3.15.3 stores an anonymous non-RTE textarea value and renders it without safe HTML encoding in the...
    Admin intel📅 Updated: Oct 7, 2026
Powered by CVE Watchtower

Critical Vulnerabilities

  • CVE-2025-50398CVSS 9.8
    Mercury D196G d196gv1-cn-up_2020-01-09_11.21.44 is vulnerable to Buffer Overflow in the function sub_404CAEDC via the parameter fac_password.
    📅 Updated: Oct 13, 2026
  • CVE-2025-50401CVSS 9.8
    Mercury D196G d196gv1-cn-up_2020-01-09_11.21.44 is vulnerable to Buffer Overflow in the function sub_404CAEDC via the parameter password.
    📅 Updated: Oct 13, 2026
  • CVE-2025-62863CVSS 9.8
    Ampere AmpereOne AC03 devices before 3.5.9.3, AmpereOne AC04 devices before 4.4.5.2, and AmpereOne M devices before 5.4.5.1 allow...
    📅 Updated: Oct 13, 2026
  • CVE-2025-62864CVSS 9.8
    Ampere AmpereOne AC03 devices before 3.5.9.3, AmpereOne AC04 devices before 4.4.5.2, and AmpereOne M devices before 5.4.5.1 allow...
    📅 Updated: Oct 13, 2026
  • CVE-2025-65834CVSS 9.8
    Meltytech Shotcut 25.10.31 is vulnerable to Buffer Overflow. A memory access violation occurs when processing MLT project files...
    📅 Updated: Oct 13, 2026
  • CVE-2025-67164CVSS 9.9
    An authenticated arbitrary file upload vulnerability in the /storage/poc.php component of Pagekit CMS v1.0.18 allows attackers to execute...
    📅 Updated: Oct 13, 2026
  • CVE-2025-67165CVSS 9.8
    An Insecure Direct Object Reference (IDOR) in Pagekit CMS v1.0.18 allows attackers to escalate privileges.
    📅 Updated: Oct 13, 2026
  • CVE-2025-67073CVSS 9.8
    A Buffer overflow vulnerability in function fromAdvSetMacMtuWan of bin httpd in Tenda AC10V4.0 V16.03.10.20 allows remote attackers to...
    📅 Updated: Oct 13, 2026
Powered by CVE Watchtower

Daily CyberSecurity

  • About SecurityOnline.info
  • Advertise with us
  • Announcement
  • Contact
  • Contributor Register
  • Login
  • Disclaimer
  • DCMA
  • Privacy Policy
  • About SecurityOnline.info
  • Advertise on SecurityOnline.info
  • Contact Us

When you purchase through links on our site, we may earn an affiliate commission. Here’s how it works

  • CVE Watchtower
  • CVE Statistics by Vendor 2026
  • Q3 2026 Report
  • Top Exploited CVEs
  • Bluesky
  • Facebook
  • Linkedin
  • Mastodon
  • RSS
  • Twitter
  • Youtube
© 2017 - 2026 Daily CyberSecurity. All Rights Reserved.