Cannot bind argument to parameter 'User' because it is null
G'day! I'm trying to import a list of users which i exported using the following command: Get-MailboxPermission "mailboxname" | select user > export.csv. This results in a list of users like: DOMAINA\username I've changed the contents of some users from DOMAINA to DOMAINB because DOMAINA contains linked mailboxes, and DOMAINB contains the actual useraccounts (this is a temporary situation). I want to give this list of users rights to the mailbox I exported them from. When I add a single user, the cmdlet looks like this: add-mailboxpermission -identity "mailbox" -user DOMAINB\user -accessrights fullaccess which works fine. To import the list of DOMAINB\user's I came up with this line: import-csv import.csv | foreach {add-mailboxpermission -identity "mailbox" -user $_.user -accessrights fullaccess} This results in the following error: Cannot bind argument to parameter 'User' because it is null Can anyone help me out here. Google is full of questions, but the anwsers aren't what I'm looking for. Thanks in advance!
April 20th, 2010 10:14am

Hi, Do u have any empty lines in your csv file? plz check. Also you can put a check on $null to avoid it like: import-csv import.csv | foreach { if($_.user -ne $null) { add-mailboxpermission -identity "mailbox" -user $_.user -accessrights fullaccess } } Regards,Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2010 10:38am

Hi Laeeq! Thanks for your quick reply! I checked the csv for empty lines, and even though I removed the first blank line and the remark USER ===== lines, I found blank spaces behind the usernames. So I removed them. I ran the cmdlet and it still returned the error. So I added your if($_.user -ne $null) . The cmdlet seemed to work because it returned no error (nothing actually). After checking the mailbox I noticed that no users were added. So I added quotation marks in front of and behind the usernames, and again there was no error given. But still no rights added. I removed if($_.user -ne $null), but now it returns the Cannot bind argument again. The contents of the csv look like this: "DOMAINB\user1" "DOMAINB\user2" "DOMAINB\user3" and so on. No spaces, no lines. Should I put $_.user between quotation marks? And should I use " or ' ? Thanks!
April 20th, 2010 11:09am

The cmdlet seemed to work because it returned no error (nothing actually). After checking the mailbox I noticed that no users were added. So I added quotation marks in front of and behind the usernames, and again there was no error given. But still no rights added. Should I put $_.user between quotation marks? And should I use " or ' ? Thanks! Hi, How are u verifying the permssion on the mailbox? are u verifying it using get-mailboxpermission commandlet? Also mailbox permission application takes some time, normally 2 hours, and if you restart the Information store service on MBX server then it applies immediately. Hope that it help u. Regards,Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2010 11:46am

I used Get-MailboxPermission "mailboxname" | select user > export.csv. It has been quite a while now since I entered the script, and normally everything entered in PS is effective almost immediately. I never had to wait more than ten minutes.
April 20th, 2010 12:00pm

Hi, Yes from command it shud show the result immediately. The Delay i mentioned is for utilizing that permission in outlook etc. Regards,Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2010 12:14pm

Hi, Plz assign this permission to some DOMAINA user like "DOMAINA\user1" and then see what happens. I doubt that DOMAINB users are having problems only. Regards,Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
April 20th, 2010 12:17pm

You're right. I tried a username and an alias, none of them were added. No error displayed.
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2010 12:30pm

Check your headings on your .csv. Is there any leading or trailing whitespace before or after the "User" heading? If there is, it will become part of the property name when you do the import-csv, and $_.user will reference a non-existent property.
April 20th, 2010 2:21pm

You're right. I tried a username and an alias, none of them were added. No error displayed. Hi, mjolinor as from prevoius reply of the O.P it is confirmed that he didnt have probelm with the csv, infact he ran the command on a DOMAINB user and it also didnt apply permission, though command ran successfully. Regards, Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2010 2:26pm

Maybe I misread, but if this was part of the script if($_.user -ne $null) and there is whitespace in the "user" header, then $_.user will always be null. The script will run without errors, but the script block of the IF statement will never run.
April 20th, 2010 2:35pm

It was a combination of syntax and csv. Remove all spaces and lines, and the --------- under User. The syntaxes i missed were foreach-object and -Process. This one works! import-csv import.csv | foreach-object -Process {Add-MailboxPermission -identity "mailbox" -user "$($_.User)" -accessRights FullAccess, DeleteItem, ReadPermission, ChangePermission ChangeOwner} Thanks for your time!
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2010 3:19pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics