Powershell / Quest cmdlet script that will output the following: sam, displayname, ("Status" disabled / or enabled), (has mailbox / or does not have mailbox), 90 days since lastlogon, parentcontainer

Powershell / Quest cmdlet script that will output the following:

sam, displayname, ("Status" disabled / or enabled), (has mailbox / or does not have mailbox), 90 days since lastlogon,  parentcontainer
mjm21Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mjm21Connect With a Mentor Author Commented:
The script was not working.  Thanks anyway.

Used this one:  get-qaduser –sizelimit 10 IncludeAllProperties | select samaccountname,displayname,accountisdisabled,lastlogon,dn,parentcontainerdn,homemdb,msexchhomeservername | export-csv c:\test\userinfo1.csv -notype
0
 
Jason WatkinsIT Project LeaderCommented:
Sorry, but what is the question? This should get you started...

Import-Module ActiveDirectory
Get-Content -Path \\Path\to\FileOfUsers.txt | foreach-object { Get-ADUser -Identity $_ | Select Name, SamAccountName | Get-Mailbox | Get-ADUserLastLogon }
0
 
mjm21Author Commented:
I will test now....how about if user is disabled or enabled?
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
Jason WatkinsIT Project LeaderCommented:
Should work either way if the user is disabled or not.
0
 
mjm21Author Commented:
Looks like I have to provide a list of users for this to work correct?  Why cant it just check all of AD and output the results to a CSV file?
0
 
Jason WatkinsIT Project LeaderCommented:
The list of users is so you don't bombard your DCs with a huge query. How many people are we talking about?
0
 
mjm21Author Commented:
2K
0
 
mjm21Author Commented:
Is this script pulling sam account names?
0
 
mjm21Author Commented:
The term 'Get-ADUserLastLogon' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try a
gain.
0
 
elchermansCommented:
Get-ADUser -LastLogon
0
 
mjm21Author Commented:
The term 'Get-ADUser-LastLogon' is not recognized as the name of a cmdlet, function, script f
ile, or operable program. Check the spelling of the name, or if a path was included, verify t
hat the path is correct and try again.
0
 
elchermansCommented:
Are you leaving a space between Get-ADUser and -LastLogon?

make sure you run "Import-Module ActiveDirectory" otherwise it wont recognize AD cmdlets
0
 
mjm21Author Commented:
The script that I put together did the job as good as I need it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.