Solved

need assistance with a powershell script

Posted on 2011-09-08
6
400 Views
Last Modified: 2012-05-12
hello, i'm looking for a script that i can schedule to run nightly that will check all accounts in an OU and if it encounters an e2010 mailbox that does not have an "online archive" enabled, to go ahead and enable the online archive and set the limits on it.
I have a Quest commandlets script that I run to enable archive by security group, can someone provide a way to target only accounts in a particular OU that do not have an archive enabled.

i've included part of the Quest script that i use to enabled the online archive.

i belive i would need to start with something like:
get-qaduser -OU "OU=Users,DC=domain,DC=com" -filter {Archive Enabled -ne $True} then pipe these results to the snippet below.

thx in advance.

S.



Enable-Mailbox $displayname -Archive -ArchiveDatabase $ArchiveDatabaseName
Set-Mailbox –identity $displayname  –ArchiveQuota 8GB –ArchiveWarningQuota 7096MB

Open in new window

0
Comment
Question by:siber1
[X]
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
  • 3
  • 3
6 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 36506029
I'd have thought something like this (but it'll need a bit of testing).
Get-Mailbox | Where-Object { -Not $_.Archive } | ForEach-Object {
  Enable-Mailbox $displayname -Archive -ArchiveDatabase $ArchiveDatabaseName
  Set-Mailbox –identity $displayname  –ArchiveQuota 8GB –ArchiveWarningQuota 7096MB
}

Open in new window

You might be able to make more efficient filters using just Get-Mailbox (rather than Where-Object), but I don't have Exchange 2010 to test that theory against.

To check and see what you can use to find things that aren't enabled, start with:
Get-Mailbox "Someone Who Is Not" | Format-List *

Open in new window

And / Or:
Get-Mailbox "Someone Who Is" | Format-List *

Open in new window

Chris
0
 

Author Comment

by:siber1
ID: 36506178
thx Chris, we have multiple databases, if i wanted to target only e2010 users could i use this format
Get-Mailbox -Server "MailboxServer1"  then pipe it to where-object ...
would that work?

its just that we have a mixed 2003/2010 environment so if i target an OU i would also be hitting e2003 mailbox enabled accounts.

0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 36506212
Yeah, that would work. You can mix in as many as you wish, so if you wanted those on a specific server and in an OU there's no harm in doing:

Get-Mailbox -Server "MailboxServer" -OrganizationalUnit "OU=somewhere,DC=domain,DC=com"

But I imagine you already knew that :)

Chris
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:siber1
ID: 36506661
Hi Chris, just tried running that in the lab and here is the error:

Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
    + CategoryInfo          : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [],
   PSInvalidOperationException
    + FullyQualifiedErrorId : RemotePipelineExecutionFailed
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 36506710
Oh damn, I forgot about that. The changes they made to the Exchange CmdLets... not helpful at all. We can work-around the problem:
$Mailboxes = Get-Mailbox -Server "MailboxServer1" | Where-Object { -Not $_.Archive }
$Mailboxes | ForEach-Object {
  $_ | Enable-Mailbox -Archive -ArchiveDatabase $ArchiveDatabaseName
  $_ | Set-Mailbox -ArchiveQuota 8GB -ArchiveWarningQuota 7096MB
}

Open in new window

It "should" work, but not something I can test entirely.

Chris
0
 

Author Closing Comment

by:siber1
ID: 36506961
thx Chris. that did the trick! appreciate your assistance!

S.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Suggested Courses

636 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