Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2013-11-07
13
1,076 Views
Last Modified: 2013-11-13
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
0
Comment
Question by:mjm21
  • 8
  • 3
  • 2
13 Comments
 
LVL 27

Expert Comment

by:Jason Watkins
ID: 39630487
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
 

Author Comment

by:mjm21
ID: 39630876
I will test now....how about if user is disabled or enabled?
0
 
LVL 27

Expert Comment

by:Jason Watkins
ID: 39630886
Should work either way if the user is disabled or not.
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:mjm21
ID: 39631238
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
 
LVL 27

Expert Comment

by:Jason Watkins
ID: 39631248
The list of users is so you don't bombard your DCs with a huge query. How many people are we talking about?
0
 

Author Comment

by:mjm21
ID: 39631261
2K
0
 

Author Comment

by:mjm21
ID: 39631333
Is this script pulling sam account names?
0
 

Author Comment

by:mjm21
ID: 39631411
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
 
LVL 1

Expert Comment

by:elchermans
ID: 39631623
Get-ADUser -LastLogon
0
 

Author Comment

by:mjm21
ID: 39631791
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
 
LVL 1

Expert Comment

by:elchermans
ID: 39631849
Are you leaving a space between Get-ADUser and -LastLogon?

make sure you run "Import-Module ActiveDirectory" otherwise it wont recognize AD cmdlets
0
 

Accepted Solution

by:
mjm21 earned 0 total points
ID: 39631887
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
 

Author Closing Comment

by:mjm21
ID: 39644053
The script that I put together did the job as good as I need it.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This video discusses moving either the default database or any database to a new volume.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question