header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
How can I retrieve a customattribute and pass it to a set-mailbox command?
Last Post 21 Jul 2010 06:07 PM by Hilcheyman. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
HilcheymanUser is Offline
New Member
New Member
Posts:2
Avatar

--
21 Jul 2010 01:37 PM
    I am attempting to set different mailbox quota's based on a users departmental "cost center" within our business.  The cost center members are scattered around our 10+ Storage Groups on our Exchange 2007 server, and each department has different mailbox quota standards, so I can't use a Storage Group setting to manage this.  A users "Cost center" number is a value set in CustomAttribute5, so the standard quota's are pretty easy to script with a get-mailbox -filter command.  The problem are users that need an exception to policy.  The plan is to put a users IssueWarningQuota and ProhibitSendQuota values into CustomAttribute13 and CustomAttribute14.  My question is how to use those two values from the get-mailbox command in the set-mailbox command.

    Right now I have one line similar to the following for each cost center:

    get-mailbox -filter {(customattribute5 -eq "costcenter1") -and (customattribute13 -eq $null)} |set-mailbox -issuwarningquota 300mb -prohibitsendquota 500mb 

    And that will set the standard quota sizes for each costcenter1 member to the departmental standard.  The following command will produce a list of mailboxes in costcenter1 that should have non-standard quota's set:

    get-mailbox -filter {(customattribute5 -eq "costcenter1") -and (customattribute13 -ne $null)}
     
    But I'm not sure how to get customattribute13 and 14 to be set as a value that can be used in the piped set-mailbox command.

    I'm not a scripting guy, but I'm trying to learn.  Thanks for any help.
    Karl MitschkeUser is Offline
    Basic Member
    Basic Member
    Posts:451
    Avatar

    --
    21 Jul 2010 02:17 PM
    This UNTESTED one-liner might work:

    Get-Mailbox -Filter {(customattribute5 -eq "costcenter1") -and (customattribute13 -ne $null)} |ForEach-Object {Set-Mailbox -Identity $_.alias, -IssueWarningQuota $_.customattribute10 -ProhibitSendQuota $_.customattribute13 -WhatIf}

    NOTE the -WhatIf - with that there, it will only tell you what it WOULD do - remove it to actually modify mailboxes.

    Karl
    http://unlockpowershell.wordpress.com
    Co-Author, Windows PowerShell 2.0 Bible
    -join("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
    HilcheymanUser is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    21 Jul 2010 06:07 PM
    No joy. Here's the error:

    Set-Mailbox : Cannot convert 'System.Object[]' to the type 'Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter' required by parameter 'Identity'. Specified method is not supported.

    I tried using $_.name instead of $_.alias just in case, but it had the same error.

    I haven't looked up the error yet.
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer