Active Directory, Organizational Unit and User

This commit is contained in:
2026-01-08 16:56:12 +01:00
parent 7e624a4f3f
commit 321dfd1f41
2 changed files with 97 additions and 1 deletions

View File

@@ -0,0 +1,94 @@
# Learn Powershell with Active Directory in Less than 2 Hours
## Windows Server
Windows Server is a Microsoft operating system designed to manage networks,
users, and applications in a business environment.
It provides services such as file sharing, security management,
and server hosting to support reliable and centralized IT operations.
## Active Directory
Active Directory (AD) is a directory service developed by Microsoft
that helps organizations manage and organize users, computers,
and other resources within a network.
It allows administrators to control access, enforce security policies,
and manage permissions from a central location.
## Import-Module
Before using active Directory with Powershell we have to imports the cmdlet
```powershell
Import-Module ActiveDirectory
Get-Command -Module ActiveDirectory
```
## Get-Help
To see all the options for one command
```powershell
Get-Help New-ADUser
```
## OU
An Organizational Unit (OU) is a container in Active Directory used
to organize users, computers, and groups within a domain.
It helps administrators manage resources more efficiently by grouping objects based on departments,
roles, or locations.
### New-ADOrganizationalUnit
```powershell
New-ADOrganizationalUnit -Name "ROCK" -Path "DC=mrsh,DC=org"
New-ADOrganizationalUnit -Name "Staff" -Path "OU=ROCK DC=mrsh,DC=org"
New-ADOrganizationalUnit -Name "Students" -Path "OU=ROCK DC=mrsh,DC=org"
New-ADOrganizationalUnit -Name "LedZep" -Path "OU=Students OU=ROCK DC=mrsh,DC=org"
New-ADOrganizationalUnit -Name "Cream" -Path "OU=Students OU=ROCK DC=mrsh,DC=org"
New-ADOrganizationalUnit -Name "Who" -Path "OU=Students OU=ROCK DC=mrsh,DC=org"
New-ADOrganizationalUnit -Name "Hendrix" -Path "OU=Students OU=ROCK DC=mrsh,DC=org"
```
## Users
In Active Directory, users are directory objects that represent individual
people or service accounts and are used to authenticate
and authorize access to network resources.
Each user account contains attributes such as a username, password, group memberships,
and profile information, which allow administrators to manage
identity, security, and permissions centrally.
Through Active Directory, users can log on to domain-joined computers,
access shared files, applications, and services, and inherit
permissions based on their group assignments, making user management more efficient,
secure, and scalable in enterprise environments.
### New-ADUser
For creating a new user
```powershell
New-ADUser -Name "Jimmy Page" -SamAccountName "jpage" -UserPrincipalName "jpage@mrsh.org"
`-Path "OU=Rock , OU=Students, OU=LedZep, DC=mrsh, DC=org" -AccountPassword (ConvertTo-SecureString "Music123" -AsPlainText -force) -Enabled $true
```
## Get-ADUser
For fetching informations about a user
```powershell
Get-ADUser -Identity "jpage"
Get-Aduser -Filter 'Enabld -eq $true'
#setting a varialbe to a user
$ADUser = Get-ADUser -Identity "jpage"
$ADUser.UserPrincipalName
# return
# jpage@mrsh.org
$ADUser = Get-Aduser -Identity "jpage" | Select-Object Name,SamAccountName,UserPrincipalName
```

View File

@@ -14,6 +14,8 @@ For learning automation
[Link to the video](https://youtu.be/ssS3dd6oQTU?si=UTU9WJakqvO-NpNY) [Link to the video](https://youtu.be/ssS3dd6oQTU?si=UTU9WJakqvO-NpNY)
3.Active Directory ## 3.Active Directory
For learning Active Directory
[Link to the video](https://youtu.be/9oiEOYFe6PI?si=RqI-VqDpS8DUUNPu) [Link to the video](https://youtu.be/9oiEOYFe6PI?si=RqI-VqDpS8DUUNPu)