Link to home
Start Free TrialLog in
Avatar of mjm21
mjm21Flag for United States of America

asked on

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
Avatar of Jason Watkins
Jason Watkins
Flag of United States of America image

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 }
Avatar of mjm21

ASKER

I will test now....how about if user is disabled or enabled?
Should work either way if the user is disabled or not.
Avatar of mjm21

ASKER

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?
The list of users is so you don't bombard your DCs with a huge query. How many people are we talking about?
Avatar of mjm21

ASKER

2K
Avatar of mjm21

ASKER

Is this script pulling sam account names?
Avatar of mjm21

ASKER

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.
Get-ADUser -LastLogon
Avatar of mjm21

ASKER

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.
Are you leaving a space between Get-ADUser and -LastLogon?

make sure you run "Import-Module ActiveDirectory" otherwise it wont recognize AD cmdlets
ASKER CERTIFIED SOLUTION
Avatar of mjm21
mjm21
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mjm21

ASKER

The script that I put together did the job as good as I need it.