Avatar of McLovin
McLovin
 asked on

Need help with powershell to set sendon behalf on mailboxes from a csv

I am needing help with setting send of behalf on a group of users the csv I have has in one column the managers which each on needs send on the behalf of the other column which is named analysts.
here is what I have so far... but not for sure how to format the add statement as to not to remove any existing users that have send aon behalf rights  
$UserList = import-CSV c:\rm\sendas.csv
ForEach ($User in $UserList)
{
Set-Mailbox $user.analyst-GrantSendOnBehalfTo @{add=$user.manager}  
}
ExchangePowershell

Avatar of undefined
Last Comment
McLovin

8/22/2022 - Mon
Jason Crawford

foreach ($user in (Import-Csv c:\rm\sendas.csv)) {
  Set-Mailbox $user.analyst -GrantSendOnBehalfTo @{add=$($user.manager)} -WhatIf
}

Open in new window

McLovin

ASKER
this is what I get when I run
Cannot process argument transformation on parameter 'GrantSendOnBehalfTo'. Cannot convert value
"System.Collections.Hashtable" to type
"Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]". Error:
"MultiValuedProperty collections cannot contain null values.
Parameter name: item"
    + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox
    + PSComputerName        :
Jason Crawford

How did you populate the Manager column of the .csv file?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
McLovin

ASKER
attached csv
McLovin

ASKER
OK I figured out one issue but now when I run it gets to the empty columns under managers and errors out.  any ideas?

cannot process argument transformation on parameter 'GrantSendOnBehalfTo'. Cannot convert value
System.Collections.Hashtable" to type
Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]". Error:
Failed to convert  from System.String to Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter. Error:
arameter values of type Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter can't be empty. Specify a value
nd try again.
arameter name: identity"
   + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
ASKER CERTIFIED SOLUTION
McLovin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
McLovin

ASKER
self closed
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.