Set-RemoteMailbox

Roger Roger 5,446 Reputation points
2023-04-26T18:59:12.0266667+00:00

Hi All

i am using exchange 2016 hybrid envrionment. we create users in onprem and migrate to online.I want to hide few mailboxes. i have the mailboxes in csv file. I am using the below syntax in onprem i am getting the error.


users
user1@contoso.com
user2@contoso.com

$users=import-csv C:/temp/list.csv
foreach($user in $users){Set-RemoteMailbox $user.Name -HiddenFromAddressListsEnabled $true}

Creating a new session for implicit remoting of "Set-RemoteMailbox" command...
Cannot bind argument to parameter 'Identity' because it is null.
    + CategoryInfo          : InvalidData: (:) [Set-RemoteMailbox], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Set-RemoteMailbox

Microsoft Exchange Online
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,386 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,503 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,999 questions
{count} votes

Accepted answer
  1. Kael Yao-MSFT 37,676 Reputation points Microsoft Vendor
    2023-04-27T01:18:40.19+00:00

    Hi @Roger Roger,

    From the error message Cannot bind argument to parameter 'Identity' because it is null, there is no value passed to the Set-RemoteMailbox cmdlet.

    Since the data format in your csv file is:

    users

    user1@contoso.com

    user2@contoso.com

    You should modify this row from

    foreach($user in $users){Set-RemoteMailbox $user.Name -HiddenFromAddressListsEnabled $true}
    

    to

    foreach($user in $users){Set-RemoteMailbox $user.users -HiddenFromAddressListsEnabled $true}
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Roger Roger 5,446 Reputation points
    2023-04-27T03:20:57.2566667+00:00

    i have tried that as well i am getting same error.


  2. Konstantinos Passadis 17,456 Reputation points MVP
    2023-04-29T19:26:24.07+00:00

    Hello @Roger Roger !

    The error message indicates that the $user.Name parameter is null, which means that the Name column from the CSV file is not being read properly.

    Make sure that the header name of the CSV file is "Name" and that there are no extra spaces or characters before or after the header name.

    You can also modify your code to explicitly reference the "Name" column in the CSV file using the following syntax:

    $users = Import-Csv C:/temp/list.csv

    foreach ($user in $users) {

    **Set-RemoteMailbox -Identity $user.Name -HiddenFromAddressListsEnabled $true**
    

    }

    This should ensure that the Name column is properly read and used to set the Identity parameter for the Set-RemoteMailbox cmdlet.

    i hope this helps , if it did helped kindly mark it as Accepted , otherwise send us some feedback !

    Regards

    0 comments No comments