Está en la página 1de 3

To set password for bulk user

$DGs = Get-Content D:\Deny\reset.txt


Foreach ($DG in $DGs) { Get-ADUser -Identity �$DG� | Set-ADAccountPassword -Reset
-NewPassword (ConvertTo-SecureString -AsPlainText 'pass1234$' -Force) }

For single user

Get-ADUser -Identity �d.loth� -Properties �LastLogonDate�

To Get user list


get-aduser -filter * -Properties * | select
cn,sn,displayname,Manager,title,Department,EmailAddress,PasswordLastSet,Enabled,cre
ated,UserPrincipalName,samaccountname,mail,lastlogondate | export-csv
d:\ad\mflusers.csv -NoTypeInformation

To get Computer List


get-adcomputer -filter * -Properties * | select
CN,LastLogonDate,OperatingSystem,OperatingSystemServicePack | export-csv
C:\Users\deny.job\Desktop\mflcomp.csv -NoTypeInformation

to change display name


import-csv 1234.csv | % {set-aduser -Identity $_.sam -DisplayName $_.displayname}

To find which group memberof


$DGs = Get-Content�C:\Users\ibm-win\Desktop\domain.txt�
get-aduser $DGs -Properties memberof | select -expand memberof | Export-csv
C:\Users\ptadmin\Desktop\groupdetails.txt

To get user details


Get-ADUser -identity ramya.shetty -properties *

Disabling AD account
Import-Csv C:\Deny\disable.csv | ForEach { Set-ADuser -Identity $_.sam -Enabled
$false}

Moving to Disable OU
Import-Csv C:\Deny\disable.csv | ForEach {get-aduser -Identity $_.sam | Move-
ADObject -TargetPath "OU=Disbled Accounts,DC=abnl,DC=com"}

Getting Group Policy details:


get-adgroupmember "Internet_PFRL_Design" | Sort -Property DisplayName | Select
DisplayName,Samaccountname | Export-CSV D:\output\Internet_Access_Design_Policy.csv
-NoTypeInformation

Creating IDs in bulk


Import-Csv "C:\Users\ramya.shetty-v\Desktop\Bulk_Domain_creation.csv" | foreach-
object { New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName
$_.userprincipalname -Name $_.Name -DisplayName $_.Name -GivenName $_.cn -Surname
$_.sn -sn $_.sn -Memberof -Path �OU=POS,OU=Rajajinagar
OU=Users,OU=F21,DC=abfrl,DC=com� -AccountPassword (ConvertTo-SecureString
�Ibm@madura� -AsPlainText -force) -Enabled $True -PassThru }

Setting AD attribute value to null

For single user


set-ADUser -Identity "masthan.shaik-v" -Clear "extensionAttribute4"
For Multiple Users
$DGs = Get-Content C:\Deny\domain.txt
Foreach ($DG in $DGs) { set-ADUser -Identity "$DG" -Clear "extensionAttribute4" }

Setting AD attribute value to some text


$DGs = Get-Content C:\Deny\domain.txt
Foreach ($DG in $DGs) { set-ADUser -Identity "$DG" -Add
@{extensionAttribute4="Internet_Access_ECommerce Team"} }

Additing Extensionattribute for MFL/PFRL


$DGs = Get-Aduser -properties * -filter * -SearchBase "DC=abnl,DC=Com"
foreach($dg in $dgs) {set-ADuser -Identity $dg.SamaccountName -ADD
@{extensionAttribute5="MFL"}}

To Restore Deleted single Id


Get-ADObject -Filter 'Mail -eq "mg.aglwarehouse@madura.adityabirla.com"
-IncludeDeletedObjects | Restore-ADObject

To Restore Deleted Multiple Id


import-Csv C:\Deny\disable.csv | ForEach { Get-ADObject -Filter -identity $.sam
-IncludeDeletedObjects | Restore-ADObject

To Display deleted AD accounts using date


[datetime]$StartTime = "9/3/2016" | [datetime]$EndTime = "9/8/2016" | Get-ADObject
-Filter {(isdeleted -eq $true) -and (name -ne "Deleted Objects")}
-includeDeletedObjects -property whenChanged | Where-Object {$_.whenChanged -ge
$StartTime -and $_.whenChanged -le $EndTime} | Export-Csv c:\deny\ramya55.csv |

To get Disabled AD account users


Search-ADAccount �AccountDisabled -UsersOnly | Select -Property
Name,SamAccountName,UserPrincipalName,Mail,DistinguishedName | Export-CSV
"C:Deny\dis.csv" -NoTypeInformation

To get group IDs


Get-ADGroup -filter * -properties * -searchbase "OU=Groups,DC=pantaloon,DC=Com"|
select SAMAccountName, DisplayName|Export-Csv
"C:\Users\ramya.shetty\Desktop\dms3.csv"

To enable Password Never expiry option


$DGs = Get-Content D:\Deny\reset.txt
Foreach ($DG in $DGs) { Set-ADUser -Identity "$DG" -PasswordNeverExpires $true }

To add Ad users to particular group


Get-ADUser -SearchBase �DC=pantaloon,DC=com� -Filter * | ForEach-object {Add-
ADGroupMember -Identity �DMS_Emp_Process� -Members $_ }

***********************************************************************************
****

PS C:\Windows\system32> get-aduser -identity "abhijeet.kumar-v" -properties *

***********************************************************************************
****

Get-DistributionGroup | Export-Csv
C:\Users\bhargav.g\Desktop\distribution_group.csv
Set-DistributionGroup "##PFRL-Space.planning" -EmailAddresses
SMTP:space.planning@abfrl.adityabirla.com,space.planning@pantaloons.adityabirla.com