次の方法で共有


Add-ExchangeAdministrator and setting the scope to multiple servers with powershell

So you want to add a new Exchange administrator and set the scope to multiple servers, but the management shell won't allow you to do this?

Here is what happens.

Add-ExchangeAdministrator -identity <user> -role ServerAdmin -scope "server1","server2"

Error: Add-ExchangeAdministrator : cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Scope'. Specified method is not supported.

Here's the solution.

First, you need to build an array that contains the servers in question.

[PS] C:\>$ExServers = "Server1","Server2","Server3"

[PS] C:\> foreach ($server in $exservers) { Add-ExchangeAdministrator -identity <user> -role ServerAdmin -scope $server }

Now the result is a success, and you will see the appropriate message indicating that the user has been added, and that to fully administer the Exchange server, you should add the user to the local admins group on the server.

Running Get-ExchangeAdministrator will also now show this user in the list with a separate entry for each server.

Now, one more note here.  Remember that arrays are only maintained for your specific powershell session.  As soon as you close Powershell, you will lose any defined arrays (or variables) unless you have taken actions (for example, modified your powershell profile) to include them.