Solved

need assistance modifying an exchange posh script

Posted on 2011-09-13
14
693 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
  • 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
 
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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now