Answered by:
how to get mailbox expiration date using cmdlets 2007 and 2010?

Question
-
i wants to know which cmdlets used to find the expiration date of mailbox in exchange server 2007 and exchange server 2010. I have a cmdlets that gives mailbox expiration date for exchange server 2013. Is there any equivalent cmdltes available for exchange server 2007 and exchange server 2010. cmdlets to get expiration date of mailbox for exchange server 2013 is as follow
Get-ADUser -Filter * –Properties Name, EmailAddress, AccountExpirationDate, GivenName | select Name, EmailAddress, AccountExpirationDate, GivenName | where {$_. AccountExpirationDate –ne $null}
- Edited by Harry_42 Thursday, June 5, 2014 5:17 AM
Thursday, June 5, 2014 5:16 AM
Answers
-
There IS no cmdlet provided with Exchange to do what you want. Accounts are Active Directory objects and while Exchange provides some support for the creation and management of accounts it isn't (and should not be) the tool you use for account management.
If you don't have a Windows Server 2008 R2 or 2012 on which to un the cmdlets provided in the ActiveDirectory module then you're going to have to resort to using either ADSI (which won't work (at least not easily) for COM objects) or something like this:
$searcher=New-Object DirectoryServices.DirectorySearcher
$searcher.Filter="(&(samaccountname=ACCOUNTNAME))"
$results=$searcher.findone()
[datetime]::fromfiletime($results.properties.accountexpires[0])--- Rich Matheisen MCSE&I, Exchange MVP
- Marked as answer by Simon_WuMicrosoft contingent staff, Moderator Monday, June 23, 2014 6:13 PM
Monday, June 9, 2014 3:16 AM
All replies
-
That is an AD module PowerShell command so it isn't tied to a particular Exchange version. If you don't have a 2008 DC to run this on you can get the same information with the Quest ARS PS tools (free download) command Get-QADUserThursday, June 5, 2014 7:03 AM
-
As noted above, this is an AD command trying to find when a user account expires. Given that the mailbox is tied to the account, the user wont have access to the mailbox when his account expires. So, both dates will be the same.
There isn't an out of the box way to temporarily stop access to a mailbox or "expire" a mailbox while the AD account is still active. You can disconnect the mailbox from the user account and that is pretty much it.
What is your end goal?
Thursday, June 5, 2014 8:08 AM -
Hi,
Check the Search-ADAccount cmdlet. It has a switch parameter specifically for finding expired accounts.
http://technet.microsoft.com/en-us/library/ee617247.aspx
e.g. Below example returns all users, computers and service accounts that are expired.
Search-ADAccount -AccountExpired | FT Name,ObjectClass -A
Regards,
Aaron.
- Proposed as answer by Aaron Carreras Thursday, June 5, 2014 8:31 AM
Thursday, June 5, 2014 8:31 AM -
Hi
Thanks to all of you for your valuable response
I just wants to know that, how can i find mailbox expiration date in exchange server 2007, and exchange server2010,using powershell commands. Is there any cmdlets available to do this
Thanks you
- Edited by Harry_42 Thursday, June 5, 2014 9:30 AM
Thursday, June 5, 2014 9:29 AM -
Mailboxes don't expire, it's AD Account that can set with expiration.
Blog | Get Your Exchange Powershell Tip of the Day from here
Friday, June 6, 2014 12:55 AM -
-
Hi Belinda
Thanks for your valuable replies
Please mention PS command to get the expiration date for AD accounts created for Exchange 2010 and Exchange 2007.
Thanks a lot
Friday, June 6, 2014 6:26 AM -
-
There IS no cmdlet provided with Exchange to do what you want. Accounts are Active Directory objects and while Exchange provides some support for the creation and management of accounts it isn't (and should not be) the tool you use for account management.
If you don't have a Windows Server 2008 R2 or 2012 on which to un the cmdlets provided in the ActiveDirectory module then you're going to have to resort to using either ADSI (which won't work (at least not easily) for COM objects) or something like this:
$searcher=New-Object DirectoryServices.DirectorySearcher
$searcher.Filter="(&(samaccountname=ACCOUNTNAME))"
$results=$searcher.findone()
[datetime]::fromfiletime($results.properties.accountexpires[0])--- Rich Matheisen MCSE&I, Exchange MVP
- Marked as answer by Simon_WuMicrosoft contingent staff, Moderator Monday, June 23, 2014 6:13 PM
Monday, June 9, 2014 3:16 AM