Need Powershell command pull .csv assigning O365 perms

I need a Powershell command to assign O365 permissions to users pulling from a .csv and export result to a .csv. I'm currently using the following command :

Get-Mailbox -ResultSize unlimited | Add-MailboxPermission -User -AccessRights FullAccess -InheritanceType all

- this is producing an error (used to work) i don't want to discuss/waste time talking to MS about. Everything i've seen online tells me to call MS - don't wanna call MS.

- if i can pull a list from .csv (please explain formatting) and export result to .csv i can pickup where the error leaves off and eventually finish perms. this is time-sensitive and don't want to do back and forth tryin resolutions. hope you understand.

Please lemme know :)
Jody DavisSystems EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
Might help if you specify what error you are running into. In general, you can use something like this:

Import-CSV blabla.csv | % { Add-MailboxPermission $.PrimarySmtpAddress -User -AccessRights FullAccess -Automapping $false }

Open in new window

where the file blabla.csv has a column PrimarySmtpAddress containing all the relevant mailbox addresses
Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
csv format:
PrimarySmtpAddress, UsertoReceiveFullAccess,

$inputfile = "D:\inputs\inputs.csv"

Import-Csv  $inputfile | % { 
   $result= Add-MailboxPermission $_.PrimarySmtpAddress -User $_.UsertoReceiveFullAccess -AccessRights FullAccess
   $results+= New-Object psobject -property @{'result'=$result; PrimarySmtpAddress = $_.PrimarySmtpAddress; UsertoReceiveFullAccess= $_.UsertoReceiveFullAccess}
$results | Convertto-csv -notypeinformation $outputfile

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jody DavisSystems EngineerAuthor Commented:
Jose - please explain the csv formatting a little more - i'm not clear as to what's needed. sorry. and thanks ahead of time.
Jody DavisSystems EngineerAuthor Commented:
Vasil - here is the error i'm receiving. The command below used to work all the way through our users. now it stops somewhere between the letter "B" and "D" every time.

Get-Mailbox -ResultSize unlimited | Add-MailboxPermission -User -AccessRights FullAccess -InheritanceType all

Processing data for a remote command failed with the following error message:
The request for the Windows Remote Shell with ShellId
1A94C38B-0F7B-4313-A89F-238D018AD2DC failed because the shell was not found on
the server. Possible causes are: the specified ShellId is incorrect or the
shell no longer exists on the server. Provide the correct ShellId or create a
new shell and retry the operation. For more information, see the
about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OperationStopped: ( [], PS
    + FullyQualifiedErrorId : JobFailure
    + PSComputerName        :
Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
A CSV it's a Comma Separated Values
So the 1st row of the Text file would be the "Name FIELDS"
I have selected 2 fields: PrimarySmtpAddress, UsertoReceiveFullAccess (these names are arbitrary).
And are the ones I use on the Powershell script  on line 6

1$result= Add-MailboxPermission $_.PrimarySmtpAddress -User $_.UsertoReceiveFullAccess -AccessRights FullAccess

From row 2, 1 user for each line.,

Means that you are going to give full permissions to the "" account into the "" mailbox.

if you run this, it would take the systems mailboxes so I'd modify it like this, to filter all the admin accounts, (you can also use the "b*"  or "c*"
get-mailbox -ResultSize unlimited | where{ $_.alias -notlike "admin*"} | %{
Write-host "Working with $_.alias"
Add-MailboxPermission $_.PrimarySmtpAddress[/b]  -User -AccessRights FullAccess -InheritanceType all

I modified the pipe for a foreach because you do need to know which one is the one giving you issues and added the notlike so you can filter :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.