I think something like this should work: $mbxs = get-mailboxstatistics -database 'servername\storage group name\database name' | where-object {$_.LastLogonTime -lt '01/07/2009'} | sort-object LastLogonTime | select Displayname,LastLogonTime,Department
Foreach ($mbx in $mbxs){$mbx.department = $(get-user $mbx.distinguishedname).department} -----Original Message----- From: Rausch, Michael D [mailto:michael.rau...@nwa.com] Sent: Wednesday, January 14, 2009 3:57 PM To: MS-Exchange Admin Issues Subject: RE: Help with powershell syntax Ok, one more question. Get-mailboxstatistics only pulls specific mailbox information (duh). Is there any way I can get other information into the table I am creating (like Alias, Department, etc) or will that prove to be un-doable in this situation? If I add Alias to the "select Displayname,lastlogontime" section, it adds it as a header, but the field is left blank. I understand why it doesn't pull that information.. Just wondering if there is a way I could perhaps merge a get-mailbox cmdlet in there somehow.. :) -----Original Message----- From: Robinson, Chuck [mailto:chuck.robin...@emc.com] Sent: Wednesday, January 14, 2009 3:07 PM To: MS-Exchange Admin Issues Subject: RE: Help with powershell syntax I quite certain the ouput is an object, so you need to replace the | format table with a select statement. get-mailboxstatistics -database 'servername\storage group name\database name' | where-object {$_.LastLogonTime -lt '01/07/2009'} | sort-object LastLogonTime | select Displayname,LastLogonTime Chuck Robinson _______________ Solutions Architect MCSE: Messaging EMC Consulting Phone: 732-321-3644 | Mobile: 973-865-0394 chuck.robin...@emc.com www.emc.com/consulting Transforming Information Into Business Results -----Original Message----- From: John Cook [mailto:john.c...@pfsf.org] Sent: Wednesday, January 14, 2009 3:55 PM To: MS-Exchange Admin Issues Subject: Re: Help with powershell syntax You could pipe it to HTML, don't have access to it right now but Google is your friend. John W. Cook Systems Administrator Partnership For Strong Families Sent to you from my Blackberry in the Cloud ----- Original Message ----- From: Rausch, Michael D <michael.rau...@nwa.com> To: MS-Exchange Admin Issues <exchangelist@lyris.sunbelt-software.com> Sent: Wed Jan 14 15:56:33 2009 Subject: Help with powershell syntax Ok, I am trying to get a report on the number of users we have that have not logged into their mailbox in X amount of days. So in my experimentation I was going for all users on a specific database that had no logged in since Jan 7: get-mailboxstatistics -database 'servername\storage group name\database name' | where-object {$_.LastLogonTime -lt '01/07/2009'} | sort-object LastLogonTime | format-table Displayname,LastLogonTime And it works just fine. Now the part I am struggling with. How do I get this output outside of the shell? I tried adding "| export-csv d:\testoneweek.csv" to the end of it all, and it created testoneweek.csv, but inside was all garbled. Not useable at all. Any other commands I may be missing that might work? ~ Ninja Email Security with Cloudmark Spam Engine Gets Image Spam ~ ~ http://www.sunbeltsoftware.com/Ninja ~ CONFIDENTIALITY STATEMENT: The information transmitted, or contained or attached to or with this Notice is intended only for the person or entity to which it is addressed and may contain Protected Health Information (PHI), confidential and/or privileged material. Any review, transmission, dissemination, or other use of, and taking any action in reliance upon this information by persons or entities other than the intended recipient without the express written consent of the sender are prohibited. This information may be protected by the Health Insurance Portability and Accountability Act of 1996 (HIPAA), and other Federal and Florida laws. Improper or unauthorized use or disclosure of this information could result in civil and/or criminal penalties. Consider the environment. Please don't print this e-mail unless you really need to. ~ Ninja Email Security with Cloudmark Spam Engine Gets Image Spam ~ ~ http://www.sunbeltsoftware.com/Ninja ~ ~ Ninja Email Security with Cloudmark Spam Engine Gets Image Spam ~ ~ http://www.sunbeltsoftware.com/Ninja ~ ~ Ninja Email Security with Cloudmark Spam Engine Gets Image Spam ~ ~ http://www.sunbeltsoftware.com/Ninja ~ ************************************************************************************************** Note: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. ************************************************************************************************** ~ Ninja Email Security with Cloudmark Spam Engine Gets Image Spam ~ ~ http://www.sunbeltsoftware.com/Ninja ~