Answered by:
Grantsendonbehalfto permission

Question
-
Hello All,
I have a requirement where I have to add the GrantSendOnBehalfTo permissions to loads of mailboxes for multiple users.
Input CSV
Name,GrantSendOnBehalfTo
ABC, "Lastname, Firstname;Lastname, Firstname;Lastname, firstname"
Script
$csv = Import-Csv C:\Temp\mailboxes.csv
$csv | ForEach-Object -Process{
$users = $_.name
$Grants = $_.GrantSendOnBehalfTo
##$Grant = $_.GrantSendonBehalfTo -split ';' | % {
##$grant = @{Add = $Grants ; Expression = {$_.GrantSendOnBehalfTo -split ';'}}
$grant = $Grants -split ';' | %{
Set-Mailbox $users -GrantSendOnBehalfTo $Grant
}
}Tried all the option but it doesn't work please can anyone help.
Thank you,
Ali
Ali Hussaini
Saturday, December 2, 2017 1:15 AM
Answers
-
Hi Ali,
I agree with jrv. In this case, I recommend identify mailboxes by name like the following screenshot:
And then you may have a try with the following script to see if it works, for your reference:
Import-Csv -Path C:\Temp\mailboxes.csv | ForEach-Object {Set-Mailbox -Identity $_.Name -GrantSendOnBehalfTo $_.GrantSendOnBehalfTo.Split(';')}
If you need further help, please feel free to let us know.
Best Regards,
Albert LingPlease remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com- Marked as answer by DemoPower Monday, December 4, 2017 6:00 PM
Monday, December 4, 2017 4:32 AM
All replies
-
YOur input is not a CSV. A firstname and lastname do not identify a maibox.
\_(ツ)_/
Saturday, December 2, 2017 1:35 AM -
Hi Ali,
I agree with jrv. In this case, I recommend identify mailboxes by name like the following screenshot:
And then you may have a try with the following script to see if it works, for your reference:
Import-Csv -Path C:\Temp\mailboxes.csv | ForEach-Object {Set-Mailbox -Identity $_.Name -GrantSendOnBehalfTo $_.GrantSendOnBehalfTo.Split(';')}
If you need further help, please feel free to let us know.
Best Regards,
Albert LingPlease remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com- Marked as answer by DemoPower Monday, December 4, 2017 6:00 PM
Monday, December 4, 2017 4:32 AM -
Hi Albert,
I have tried this script but I am getting the below error message
You cannot call a method on a null-valued expression.
At C:\Temp\GrantSendOnBehalfToBulk.ps1:1 char:60
+ ... ach-Object {Set-Mailbox -Identity $_.Name -GrantSendOnBehalfTo $_.Gra ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNullThank you,
Ali
Ali Hussaini
Monday, December 4, 2017 3:27 PM -
check the Import-CSV output and verify the output is in the way you are expecting.
Regards kvprasoon
- Proposed as answer by PRASOON KARUNAN V Tuesday, December 5, 2017 3:43 AM
Monday, December 4, 2017 4:39 PM -
Sorry Guys it was me again being silly. Input file had missing TO from the the heading. So the above solution did worked thank you so much for all your support.
Many Thanks
Ali
Ali Hussaini
Monday, December 4, 2017 6:00 PM