Powershell

 New AD account creation:

$password=ConvertTo-SecureString "Bescom@123" -AsPlainText -Force

ForEach-Object {New-ADUser -DisplayName $_.DisplayName -Name $_.DisplayName -GivenName $_.DisplayName -SamAccountName $_.LogOnName -EmailAddress $_.EmailID -Office $_.Location  -Title $_.Designation -OfficePhone $_.MobileNO -AccountPassword $password -Enabled $true -UserPrincipalName $_.UPN}


...........................................


User requirement Details Provide


Get-ADUser -Filter *  -Properties * | Select-Object DisplayName, SamAccountName, Description, Title, Department, physicalDeliveryOfficeName, Office, Company, UserPrincipalName, EmailAddress, LastLogonDate, DistinguishedName,CanonicalName, Created, Enabled | Export-Csv ADUsers.csv


.......................................................................................................


Password String:


$password=ConvertTo-SecureString "Cesc@123" -AsPlainText -Force


............................................................................


Password change /new password set:


Import-Csv User.csv | ForEach-Object {Set-ADAccountPassword -Identity $_.user -NewPassword $password}


................................................................................



Password change on nextLogOn


Import-Csv .\Users.csv | ForEach-Object {Set-ADUser -Identity $_.User -ChangePasswordAtLogon $false/True }


...........................................


OU Move:


 # Import AD Module

Import-Module ActiveDirectory

 

# Import the data from CSV file and assign it to variable

$Import_csv = Import-Csv -Path "C:\Users\mahesh_win\Desktop\VPNUsers.csv"


# Specify target OU where the users will be moved to

$TargetOU = "OU=BESCOM-CCC,DC=kescom,DC=org"

 

$Import_csv | ForEach-Object {


    # Retrieve DN of User

    $UserDN = (Get-ADUser -Identity $_.LogOnName).distinguishedName


    Write-Host "Moving Accounts....."


    # Move user to target OU. Remove the -WhatIf parameter after you tested.

    Move-ADObject -Identity $UserDN -TargetPath $TargetOU


Write-Host "Completed move"

Import-Csv "CSV File location" | Foreach {

$NewPassword = ConvertTo-SecureString -AsPlainText $_.NewPassword(hedding name As per CSV File) -Force

Set-ADAccountPassword -Identity $_.sAMAccountName(hedding name As per CSV File) -NewPassword $NewPassword -Reset -PassThru | Set-ADUser -ChangePasswordAtLogon $false

}


Import-Csv C:\Users\Vakkapatla_Sivanagar\Pictures\User.csv | Foreach {

$NewPassword = ConvertTo-SecureString -AsPlainText $_.Password -Force

Set-ADAccountPassword -Identity $_.User -NewPassword $NewPassword -Reset | Set-ADUser -ChangePasswordAtLogon $false

}

......................................................

Comments

Popular posts from this blog

41. Configuring Preferences using Item-level targeting

V-Center , cluster, DRS, HA, vMotion

Windows Services