Author Posts

May 31, 2018 at 3:38 am

Is there a way to do remoting to an exchange server and be in the same configuration with no limitation as the exchange shell is providing.

May 31, 2018 at 11:56 am

Is there anything missing from using Implicit Remoting to Exchange?
Should only be your RBAC that decide what you can do or not, as far as I know.

May 31, 2018 at 3:10 pm

This is what I am using

$ServerName = $env:COMPUTERNAME
$Credential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$ServerName/PowerShell/ -Authentication kerberos -Credential $Credential
Import-PSSession $Session

Then, if I try to run a script from microsoft for public folder migration,
Export-PublicFolderStatistics.ps1 -ExportFile FolderToSizeMap.csv -PublicFolderServer $servername
I get an error : Get-PublicFolderStatistics : Missing an argument for parameter 'Server'. Specify a parameter of type 'System.Object' and try again.
At line:1 char:59
+ @(Get-PublicFolderStatistics -ResultSize:Unlimited -Server <<<< ) + CategoryInfo : InvalidArgument: (:) [Get-PublicFolderStatistics], ParameterBindingException + FullyQualifiedErrorId : MissingArgument,Get-PublicFolderStatistics But if I ran the same command from exchange management shell it work well. This is a specific example easy to reproduce. I got plenty of this. seam to be related to serialization, deserialization, pipeline. I am really trying to use remoting on all my server, I manage more than 250. I want to avoid the need to connect in RDP, than run the exchange shell everytime. Anybody know why? The server is an Exchange 2010 in this example. A solution to this will be very appreciated. So far it doesnt seem to be possible to just load the snapin either.

May 31, 2018 at 3:27 pm

Looks like it was written to expect a -Server parameter in the script.

If you've got the session already, you may be able to remove the parameter from the script and run it.

May 31, 2018 at 3:50 pm

The question, why is there so much difference in running the script in exchange shell and via a remoting session.

Can we make adjustement to have the powershell behave like exchange shell?

May 31, 2018 at 4:29 pm

This doesn't make sense to me. Presumably you are running this code from a remote machine, otherwise you wouldn't need to to do anything with importing a session. Why are you setting $servername to your local computer name?

$ServerName = $env:COMPUTERNAME
$Credential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$ServerName/PowerShell/ -Authentication kerberos -Credential $Credential
Import-PSSession $Session

Have you tried this?

$Credentials = Get-Credential
$ExSession = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri 'http://ExServer1.contoso.com/PowerShell/?SerializationLevel=Full' -Credential $Credentials –Authentication Kerberos
Import-PSSession $ExSession

May 31, 2018 at 4:35 pm

Also look at the specific error message "Specify a parameter of type 'System.Object' and try again"

PS C:\> $pc = $env:COMPUTERNAME

PS C:\> $pc | get-member


   TypeName: System.String

May 31, 2018 at 4:36 pm

Ok, Jon, can I work arround this?

May 31, 2018 at 4:43 pm

Per this it looks like you have to run the export-publicfolderstatistics from the machine.

Export-PublicFolderStatistics.ps1 This script creates the folder name-to-folder size mapping file. You'll run this script on the legacy Exchange server.

Export-PublicFolderStatistics.psd1 This support file is used by the Export-PublicFolderStatistics.ps1 script and should be downloaded to the same location.

What happens if you change $env:computername to the actual hostname of the exchange server holding the publicfolders?

May 31, 2018 at 5:09 pm

Samething.

Export-publicfolderstatistics.ps1 might pipe to get-publicfolderstatistics at a certain point and because we are in a remote session the return might be deserialized and this is where it fail

I have so many place where command run on exchange shell but fail in implicit remoting. It drive me crazy.

Can we have the session behave exactly as the exchange shell?

May 31, 2018 at 6:43 pm

I'm not sure how you could pipe a powershell script to a cmdlet.

As I said in a previous discussion with you, I have never seen where the session behaves differently than the exchange shell. If you think it's different, I would recommend opening a ticket with Microsoft.

Did you try the "serialization=full" option I posted earlier?

June 6, 2018 at 7:42 pm

hi jon,

How to run/execute a PS script on remote servers ??
i just used like UCN path of the script,
\\server-name\d$\Program-Files\script.ps1

But it didn't worked !

please help me,
1) If i wanted to include remote server path on the script, what changes to be done?
2) if i want to execute it directly using the path, what changes do be done ?
i am very new to PS.
And we need to set any server name and password ?
Thanks in advance.

June 7, 2018 at 7:51 am

Pradeep, it's better if you start a seperate topic and not hijacking another.
But as a quick answer you could use the powershell command "Invoke-Command".
Just running a script from a UNC path on your local machine will run it on your machine.

There are plenty of examples on how to use invoke-command here:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-6