Solved

need assistance modifying an exchange posh script

Posted on 2011-09-13
14
712 Views
Last Modified: 2012-05-12
we run the attached script daily to go through and enable the online archive for any e2010 accounts that currently do not have the archive enabled. however, we have a few high priority VP's and executives that require a different quota setting. is there a way to add in an "-exclude" line to this script to exclude specific users from being impacted by this?

many thanks!

S.
$Mailboxes = Get-Mailbox -Database "Mailbox Database Server-Mailbox01" -OrganizationalUnit "OU=Newcorp,OU=Users,,DC=Mydomain,DC=com" | Where-Object { -Not $_.Archive }
$Mailboxes | ForEach-Object {
  $_ | Enable-Mailbox -Archive -ArchiveDatabase "Archive Database DC1-ARCHIVE"
  $_ | Set-Mailbox -ArchiveQuota 10GB -ArchiveWarningQuota 9096MB
}

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
  • 7
  • 7
14 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 36535878
Set one of the CustomAttributes in each record you want to exclude and then use:-

$MailBoxes = get-mailbox | where {$_.CustomAttribute5 -ne "VIP"} -database.......
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 36535917
By way of an explination....

The above of course assumes that all your "VIP's" Have the CustomAttribute5 field set to the string "VIP"
0
 

Author Comment

by:siber1
ID: 36537519
Hi Neilsr, when i run this in the lab i get the following error:

Cannot bind argument to parameter 'Identity' because it is null.
    + CategoryInfo          : InvalidData: (:) [Enable-Mailbox], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Enable-Mailbox

Cannot bind argument to parameter 'Identity' because it is null.
    + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Set-Mailbox

Where-Object : A parameter cannot be found that matches parameter name 'Database'.
At C:\scripts\en-employeeArchive.ps1:15 char:85
+ $Mailboxes = Get-Mailbox | where {$_.CustomAttribute15 -ne "ArchiveQuota"} -Database <<<<  "Mailbox Database XX-MDB0
3" -OrganizationalUnit "OU=temp,DC=domain,DC=com" | Where-Object { -Not $_.Archive }
    + CategoryInfo          : InvalidArgument: (:) [Where-Object], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.WhereObjectCommand
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 37

Expert Comment

by:Neil Russell
ID: 36537737
Can you post your whole script as modified please.
0
 
LVL 37

Accepted Solution

by:
Neil Russell earned 500 total points
ID: 36537751
Ah my bad, i see. I was not thinking well enough.....


$Mailboxes = Get-Mailbox -Database "Mailbox Database Server-Mailbox01" -OrganizationalUnit "OU=Newcorp,OU=Users,,DC=Mydomain,DC=com" | where {$_.CustomAttribute5 -ne "VIP"} | Where-Object { -Not $_.Archive }  

I think!

I dont have access to exchange right now but I think thats right.....
0
 

Author Comment

by:siber1
ID: 36538009
Hi Neilsr, i just re-tested in the Lab and that cleared the error, however the script still hits all VP accounts even though we specified "where {$_.CustomAttribute5 -ne "VIP"} " in the script.

and reverts them back to to policy settings.

full script is attached.

thx
$Mailboxes = Get-Mailbox -Database "Mailbox Database xx-MDB01" -OrganizationalUnit "OU=temp,DC=mydomain,DC=com" | where {$_.CustomAttribute15 -ne "ArchiveQuota"} | Where-Object { -Not $_.Archive }
$Mailboxes | ForEach-Object {
  $_ | Enable-Mailbox -Archive -ArchiveDatabase "Archive Database xx-ARCHIVEDB"
  $_ | Set-Mailbox -ArchiveQuota 8GB -ArchiveWarningQuota 7096MB
}

Open in new window

0
 

Author Comment

by:siber1
ID: 36538013
also, i have added the "VIP" field in custom attribute. still it hits those accounts and doesnt exclude.
0
 

Author Comment

by:siber1
ID: 36540342
Hi Neilsr, do you have any update on this? when i run what you suggested the script still doesnt exclude the VP accounts?
any suggestions would be much appreciated!!

S.
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 36541971
Your script says......

 $Mailboxes = Get-Mailbox -Database "Mailbox Database xx-MDB01" -OrganizationalUnit "OU=temp,DC=mydomain,DC=com" | where {$_.CustomAttribute15 -ne "ArchiveQuota"} | Where-Object { -Not $_.Archive }
$Mailboxes | ForEach-Object {
  $_ | Enable-Mailbox -Archive -ArchiveDatabase "Archive Database xx-ARCHIVEDB"
  $_ | Set-Mailbox -ArchiveQuota 8GB -ArchiveWarningQuota 7096MB
}

and NOT what i suguested

0
 

Author Comment

by:siber1
ID: 36544903
I just used the word "ArchiveQuota" as the value .. rather than "VIP" ..  it shouldn't matter right?
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 36544996
ok thats fine. And of course you have set the attribute to that value on the users?
0
 

Author Comment

by:siber1
ID: 36545973
yes
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 36546167
Is the output from

Get-Mailbox -Database "Mailbox Database xx-MDB01" -OrganizationalUnit "OU=temp,DC=mydomain,DC=com" | where {$_.CustomAttribute15 -ne "ArchiveQuota"} | Where-Object { -Not $_.Archive }

The list you would expect? The syntax is correct, i just ran exactly that on my lab server and it does exactly what is expected.

0
 

Author Closing Comment

by:siber1
ID: 36546272
thx again! just re-tested and it works perfectly.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

738 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