0% found this document useful (0 votes)
4 views

user_handling_in_ad

The document contains PowerShell commands for managing Active Directory, including counting computers and users, creating new users with specific attributes, and importing user data from a CSV file to create multiple users. It also includes a loop to display names from an array. The commands demonstrate various functionalities related to Active Directory management and user creation.

Uploaded by

hatikrishnakanta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

user_handling_in_ad

The document contains PowerShell commands for managing Active Directory, including counting computers and users, creating new users with specific attributes, and importing user data from a CSV file to create multiple users. It also includes a loop to display names from an array. The commands demonstrate various functionalities related to Active Directory management and user creation.

Uploaded by

hatikrishnakanta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Get-ADComputer -Filter * | measure |select count

Get-ADComputer -Filter {operatingsystem -like '*windows*'} -Property *|select


operatingsystem,name| measure| select count

Get-ADUser -Filter * |measure|select count

Get-ADComputer -Filter * -SearchBase "ou=salescomputerou,dc=test,dc=local"|select


name
Get-Command -Module GroupPolicy
Get-GPO -All |select displayname,CreationTime|ft

Get-GPO -All|ft
=====================================================
$pass =(Read-Host -AsSecureString 'AccountPassword')

New-ADUser -Name "kkh" -AccountPassword $pass -SamAccountName "kk" -


UserPrincipalName "[email protected]" -DisplayName "kris" -Enabled $true -
PasswordNeverExpires $true -CannotChangePassword $true

New-ADUser -Name "suprio" -AccountPassword $pass -SamAccountName "suprio" -


UserPrincipalName "[email protected]" -DisplayName "kris" -Enabled $true -
PasswordNeverExpires $true -CannotChangePassword $true -Path
"ou=salesou,dc=test,dc=local"

====================================================
$users=Import-Csv -Path "C:\USER1.csv"

foreach($user in $users)
{
$displayname = $user.firstname +" " + $user.lastname
$SAM =$user.sam
$ou= $user.ou
$upn= $user.firstname +"@"+$user.domain
$passwd =$user.password
New-ADUser -Name $displayname -SamAccountName $SAM -AccountPassword(ConvertTo-
SecureString $passwd -AsPlainText -Force) -Enabled $true -Path $ou -
UserPrincipalName $upn
}

====================================================
$array1="ram","shyam","jadu","madhu"
cls
foreach($suprio in $array1)
{
Write-Host "you name is---->" $suprio
}

You might also like