Showing posts with label Get-ADUser. Show all posts
Showing posts with label Get-ADUser. Show all posts

Wednesday, December 17, 2014

PowerShell and Active Directory : Get the list of Active Directory Users created of a Specific Date.

 

If you are an I.T or System Administrator, then you must doing one thing for sure, getting the list of Active Directory users. Getting list of Active Directory users is very easy with PowerShell.

You just need to have “Active Directory PowerShell Module” and just shoot the Get-Aduser cmdlet. Simple!

A IT guy from Egypt ( Ahmad),  email me and ask me if he can get a list of Active Directory user that is created on a specific date? I said Yes, and then I think about to write this PowerShell Script function.

The usage of PowerShell function is very easy. Type the function name and in –Date parameter provide the Date on which you want to see if you have created any Active Directory user.

For example:

If you run the below code. It will give you list of all Active Directory User account those are created with-in 24 Hours of 17th December 2014.

 

Get-ADUserCreated -Date 12/17/2014 

 

1

Video : Video of the script usage and running.

Video of the script usage and running.

Script Download Link : https://gallery.technet.microsoft.com/Get-Active-Directory-Users-e720f7e5

Thanks for your time and reading the blog.

Regards.
Aman Dhally
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.

Murky_ana

Tuesday, January 15, 2013

Powershell and Active Directory: Finding User whose password is Expired.

Hi,

Yesterday i have got a call from my remote user, she is  saying that she is not able to login to the Intranet System and Outlook, I asked her if she has got any notifications about password failed (Setting using Group Policies). and she denied.

i said “OK”..

Somehow i feel this is related to her password, i thought let’s see if her password is expired or not.

The best way to check this is using “Powershell”

I opened my Powershell Console.

I imported my ActiveDirectory Module ( Import-Module ActiveDirectory )

and i shoot the command line.

Get-ADUser UserName -Properties *

14-01-2013 13-00-55

and when i scrolled down and i  seen “PasswordExpired : True

14-01-2013 13-00-19

and i call that lady over the phone and  told her to change her password.

You can also use this command line to find all users those password are expired.

Get-ADUser -Filter 'PasswordExpired -eq $true'

All Sorted… and i live “happily ever after” (till the second problem hit me Winking smile)

I love Powershell.

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005 clip_image007

Monday, October 29, 2012

Script to send HTML Formatted email of Newly Created Active Directory Users and Groups using Powershell.

Hi,

Sometime i love to run scripts manually and sometime  i like to schedule them.

 In our company we have lots of new joiners every week, and we also creates and use AD groups. In our IT team not everyone known about which users has just joined the company recently.

To ensure everyone in IT team knows about a new joiner in the company i have written a Tiny-Miny powershell script which is scheduled to run on every monday.

This script send a HTML formatted email containing the list of New AD Users and New AD groups those are created within a 7 days,.

You can download the script from this link : http://gallery.technet.microsoft.com/scriptcenter/Find-Active-Directory-26b71b73

Screenshot of the Output Email:
29-10-2012 16-54-31
You can download the script from this link : http://gallery.technet.microsoft.com/scriptcenter/Find-Active-Directory-26b71b73

Thanks
Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter

Tuesday, August 21, 2012

Powershell &Active Directory : Active Directory Reports in Excel.

Hi,

Active Directory reporting, some time we thinks what should a Active Directory reports contains, should i need a tool to do that reporting job? or should i purchase a active Directory tool to do this task.

One of my friend want an Active Directory Reporting tool and he was planning to buy it, i asked what are your requirements, he told me that, I want a tool which can export a data in to the Excel, and i have a list of disabled Computer accounts, User Account so that i can delete them,

I told this that that can be done easily with powershell and for him i wrote a little powershell script. this script is based on RSAT , Active Directory module. Make sure you have RSAT tools installed before running the script.

when you run the script , that will Import Active Directory Module First and then open an Excel workbook. In excel you can find 4 sheets for now. they are contains
  1. List of inactive Users Accounts
  2. List of inactive Computer Accounts
  3. Users Accounts created within a period of week.
  4. List of Users with password never expires enabled.
Script Download link : http://gallery.technet.microsoft.com/scriptcenter/Active-Directory-Reports-bb8c1cc7

21-08-2012 13-19-01
and this excel file will be saved on users Desktop.

Script Download link : http://gallery.technet.microsoft.com/scriptcenter/Active-Directory-Reports-bb8c1cc7

Thanks
Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter

Thursday, August 9, 2012

Powershell & Active Directory : “Find all users Email ID’s in Active Directory Using Powershell”.

Hi,

My todays task was to create a list of our all of our “Active Directory” users email Id’s. Normally you can do this easily using download your global address list of exchange server and export in to the file.

But remember Powershell is all about automation. Now imagine, your manager told you that every fortnightly he want’s a list of all users email id so that he can use it for sending some company wise “News”. I know you don’t want to so this manually after every 15 days. So why not to automate is and save some manual task, so that we can steal some time to spend on “Facebook”  ;o).

Okies, lets start , before running any cmdlets make sure you have RSAT tools installed.

The task is simple we can use Get-Aduser and and use –Filter * to find all users, and in –Properties choose Email Address to show and then pipe output to Select-Object cmdlet and choose to display Name and Email Address in the output.

Get-ADUser -Filter *  -Properties EmailAddress  | Select Name,EmailAddress 

Okies, we got what we want,,,,But wait,,, there are few users who don’t have any Email Address and i don’t want them in to my output file, let’s filter it more.


09-08-2012 19-30-52


I have added a one more cmdlet to the command , which is Where-Object , before Selecting the object we choose to show only those users whose Email Address files in not null.

Get-ADUser -Filter *  -Properties EmailAddress  | where { $_.EmailAddress -ne  $null }  | sort  | Select Name,EmailAddress

Now we can add Export-CSV cmdlet in to the End so that we have a output stored in to a .CSV file.

Get-ADUser -Filter *  -Properties EmailAddress  | where { $_.EmailAddress -ne  $null }  | sort  | Select Name,EmailAddress | Export-Csv D:\email_ID.txt

and the output file should be look perfect like this.


09-08-2012 19-38-59


Task finished….


and have a nice day and


Happy Janmashtami Everyone :o)


krishna_animated


Thanks


Aman Dhally


join aman on facebook Join aman on Linkedin follow aman on Twitter

Tuesday, August 7, 2012

powershell & Active Directory: Find all users who have “Password Never Expires” enabled using Powershell.

Hi,

In domain controller environment we all have some password policies set. In some organizations the users password is expired in 60 days in some 90 or in 180 Days.

User’s password must expired in the defined period, changing password often is a good security policy.

But when we create a user account some time by mistakes we select  “Password Never Expires”.

if  the “Password never expires” checked users password never expired.

07-08-2012 13-28-44

which is not good for user’s account security.

My todays task is to find all users , who have “Password Never Expire” checked. To archive this task we are going to use “Active Directory” module and “Get-Aduser” cmdlet with Filters Smile

Get-ADUser -Filter  'PasswordNeverExpires -eq $true'  -Server localDC | select name


 07-08-2012 13-29-42


After Get-ADuser cmdlet we are using –Filter to show all those account whose “Password Never Expires value is equal to True” which means enabled,and in –server parameter i am defining my domain controller, and  we are piping the output to “Select-Object” cmdlet and selecting to show “Name” property of the output to show.


and the output is below Smile 


07-08-2012 13-29-20


Now I can show that list to my manager so that we can fix them later Smile ..


Thanks for reading.


Thanks!


Aman Dhally


Buy-More-Twitter-Followers 4fb29548b6adc linkedin

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