New to Powershell and AD scripting need some help.

rated by 0 users
This post has 3 Replies | 2 Followers

Not Ranked
Posts 2
halfscot Posted: 08-31-2010 9:54 AM

I need to take an input file that has emails of users format like this of course victor.laskoskie@nomail.com

the query using dsquery or powershell AD to get the following and export or import to an excel spreadsheet.

 

meaning

Create a PS script to read it , pick up from AD  the Full Name /  EmpID and Active/Disabled status for the output file with the email.

is this possible?

Top 100 Contributor
Posts 8

Indeed, it is possible...

1. group all your email addresses into a file, eg. emailadd.txt

   Email

   victor.laskoskie@noemail.com

   power.shell@noemail.com

 

2. create this PowerShell script, eg. myPSscript.ps1

$cont = import-csv C:\emailadd.txt

foreach ($rec in $cont)

{
$i1 = $rec.Email.split(".,@")
$fname = $i1[0]
$lname = $i1[1]

dsquery .....
}

 

You can test the output by substituting the dsquery line with "write-output $fname $lname"

There may be better methods of doing this, but this is my version.

 

--samuel

 

 

Not Ranked
Posts 2

 

Thanks Samuel I will try it I was asked to do this two days ago after someone was let go,
never wrote a script in my life.
 
PS nice name my 4 year old is Samuel.
Top 100 Contributor
Posts 8

Glad to assist...

I would suggest that you invest some time in downloading and installing the free ActiveRoles Management Shell for Active Directory from Quest - http://www.quest.com/powershell/activeroles-server.aspx

The CMDLets contained herin, will provide much quicker access to information that you require from AD. I use it and it is great fun!

For Example;

ActiveRoles provide a get-QADuser cmdlet that can be used to solve your problem -

get-qaduser -Firstname $fname -LastName $lname | select-property Disabled

If the test returns true, then you can output all the parameters that were declared out to a file to produce your report.

 

Let me know if you need any further assistance.

 

 

 

 

 

 

Page 1 of 1 (4 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.