• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 734
  • Last Modified:

need assistance modifying an exchange posh script

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
siber1
Asked:
siber1
  • 7
  • 7
1 Solution
 
Neil RussellTechnical Development LeadCommented:
Set one of the CustomAttributes in each record you want to exclude and then use:-

$MailBoxes = get-mailbox | where {$_.CustomAttribute5 -ne "VIP"} -database.......
0
 
Neil RussellTechnical Development LeadCommented:
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
 
siber1Author Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Neil RussellTechnical Development LeadCommented:
Can you post your whole script as modified please.
0
 
Neil RussellTechnical Development LeadCommented:
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
 
siber1Author Commented:
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
 
siber1Author Commented:
also, i have added the "VIP" field in custom attribute. still it hits those accounts and doesnt exclude.
0
 
siber1Author Commented:
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
 
Neil RussellTechnical Development LeadCommented:
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
 
siber1Author Commented:
I just used the word "ArchiveQuota" as the value .. rather than "VIP" ..  it shouldn't matter right?
0
 
Neil RussellTechnical Development LeadCommented:
ok thats fine. And of course you have set the attribute to that value on the users?
0
 
siber1Author Commented:
yes
0
 
Neil RussellTechnical Development LeadCommented:
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
 
siber1Author Commented:
thx again! just re-tested and it works perfectly.
0

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now