Showing posts with label organizational unit. Show all posts
Showing posts with label organizational unit. Show all posts

Thursday, August 2, 2012

Powershell and Active Directory: Maintains the Leavers of your Company using powershell GUI based Application.


HI,

Like every IT Administrator we have to create user accounts when someone joined the company and also delete and reset the account when someone leaves.
From past few days i was trying to write a GUI Application based on powershell.
My Main objective was.
    • Reset Leaving Users Password.
    • Remove him from all groups.
    • Move his user account to particular OU
You can download the script form this link : http://gallery.technet.microsoft.com/scriptcenter/Manage-Leavers-accounts-in-b98d0df2

Before running this script please change this variable as per your need:  $ArchiveOu = 'OU=Archived,DC=localDC,DC=com'

Let me explain about the script.
This script is based on ActiveDirectory Module , so before running the script make sure that you have installed RSAT tools.

When you run the script first it ask for username  and password, Please provide your Domain Admin username and password.
02-08-2012 12-06-23

After you provide the credentials a GUI will open.
On the Number 1 , it is showing that if script is able to detect and imported the ActiveDirectory Module.
Our first task to to find the Users SAMAccount Name.

So provide the users First and last name (2,3) and click on Find (4)
when you click on Find .. It search for user in all AD for matching user.
in number 5 this will show the users SAMAccount Name
in Number 6 Provide a new password for user.
Now on number 7 click on Starts
When you click on start it do .
  • Reset User password
  • remove it from all Groups
  • Move it to a particular OU
02-08-2012 12-04-54

Download Link : http://gallery.technet.microsoft.com/scriptcenter/Manage-Leavers-accounts-in-b98d0df2
Thanks for reading.
Thanks!
Aman Dhally
Buy-More-Twitter-Followers 4fb29548b6adc  linkedin
00488d3a

Friday, June 15, 2012

Powershell and Active Directory: Find Active Directory users in a particular Organizational Unit whose Script Path is not set or blank using Powershell.

 

Hi,

If we are using "Active Directory" then one this is sure that 98% we are using some login scripts. Sometime while creating users we forget to mentioned to specify the login script in account.

15-06-2012 12-43-37

My task of today is to find all users accounts those have no login script defined in their accounts.

Let's Start.

 Make sure you have "RSAT" installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 

..

ok, Module is imported,

...

I want to search a particular organizational unit for users. I am not so good in LDAP so i always do a trick to find full path of OU.

Find OU.

I know a user name "Will smith" in located in that Organizational unit on whom i want to search users those have blank LOGIN SCRIPT field.

I run Get-ADUser cmdlet against Will.smith and i choose to show me of DistinguishedName the user. That DistinguishedName name contain full path of that OU

(Get-ADUser will.smith).DistinguishedName

Copy all fields expect CN and saved it to a variable.

15-06-2012 12-44-57 

$ou = "OU=testing,DC=localDC,DC=com"

15-06-2012 12-55-32

We are using  Get-ADUser cmdlet , to the information about active Directory users, in -SearchBase we are telling it to search our  predefined Organizational Unit in $ou variable,   then -Filter * to search for all users , and then -Properties * to show all the properties of the user account , then we are piping the command to  where cmdlet and we are choosing to choose only those users whose SCRIPTPATH is equal to null or blank and after that we are selecting only names using select cmdlet.

Get-ADUser -SearchBase $ou -Filter * -Properties * | where { $_.ScriptPath -eq $null } | select Name

15-06-2012 12-59-34

All Done...Job is secured | once again ...

Thanks!

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

dance_goofy

Tuesday, June 12, 2012

Powershell and Active Directory: Find all organizational unit containers [OU] in Active Directory using Powershell.

 

Hi,

These days i think i am only and only working with Active Directory.  My Manager give me the task to show him the all Organizational Unit Container , so that we can re-arrange them and remove the OU those are not required any longer.

Seriously i don't know any way to do this. I never heard about it and never tried it before. Why ? my manager needs it ? that the first thought came in my mind, but buddy manager is a manager ;o) , i have to do it what he said.

The again i decide lets explore some Active Directory cmdlets and see if it have something.

In first attempt i found a single cmdlet which is able to do this. That is  Get-ADOrganizationalUnit

Let's Start.

 Make sure you have "RSAT" installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 

..

ok, Module is imported,

...

First run the to view all OUs run the single cmdlet with -Filter * parameters

Get-ADOrganizationalUnit -Filter *

It is showing us the details of all OUs.

New Delhi Powershell User Group

But i am still not satisfy with the result. let it filter more ,,

Get-ADOrganizationalUnit -Filter * | Select Name

I tried to select Name but the output is not so good. Because we can see Name but for example in below screenshot i have multiple OU container named as Users

12-06-2012 11-35-36

ok...still not happy.

let run another command

Get-ADOrganizationalUnit -Filter *  -properties * | Select CanonicalName

This command will show is a full path of our OUs.

12-06-2012 11-38-05

All Done :)

My Target of the day i achieved. Now can do facebook ;o) ;o)

Thanks for reading

Thanks!

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

simba