none
Passing a GUID object ID as a Parameter ie in Exchange 2013 RRS feed

  • Question

  • So I've been looking at the command logging in Exchange 2013 Admin center and would like to start incorpating the creation of mailboxes in my New User Script that we use for creating Active Directory Users.

    I see in the logging it's Passing GUID id's as paramater to say Enable-UMMailbox.

    Yet when I do this in the script It fails.

    Here's my code.

    $UserGUID = Get-ADUser $SamAccountName -properties ObjectGUID | select ObjectGUID
    
    Enable-Mailbox -Identity $UserGUID -Alias $UPN -Database $MBSelection

    when I do this I get an error,  powershell complains that it cannot convert type GUID to type

    Cannot process argument transformation on parameter 'UMMailboxPolicy'. Cannot convert the 
    "b1376bbd-cefa-4cce-98b9-114128fbdeb0" value of type "System.Guid" to type 
    "Microsoft.Exchange.Configuration.Tasks.MailboxPolicyIdParameter".
        + CategoryInfo          : InvalidData: (:) [Enable-UMMailbox], ParameterBindin...mationException
        + FullyQualifiedErrorId : ParameterArgumentTransformationError,Enable-UMMailbox
    Is there a special switch I need to pass or do a string conversion or a sort or set the type?

    Cheers.

    Edit:

    Additionally I will add that this process works if I don't use the GUID,  If I just pass the SamAccountName instead as the identity it works.   I'd like to pass the GUID,  from what I read it's a great way to avoid collison and this makes the Boss feel warm and fuzzy.



    Tuesday, March 1, 2016 2:57 AM

Answers

  • Ok so I figured this out on my own, I must need  a break because this was easier than I thought.

    I welcome anyone to add if you have a better way but this is what I did.  

    [string]$UserGUID = Get-ADUser $SamAccountName -properties ObjectGUID | select -expand ObjectGUID
    
    Get-Recipient -Identity $UserGUID
    
    

    • Marked as answer by Pinnacle Paul Tuesday, March 1, 2016 3:14 AM
    Tuesday, March 1, 2016 3:14 AM