?
Solved

need assistance modifying an exchange posh script

Posted on 2011-09-13
14
Medium Priority
?
719 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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 2000 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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
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…
Suggested Courses

762 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