This topic contains 13 replies, has 6 voices, and was last updated by
May 31, 2018 at 3:38 am #101470
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 #101482ParticipantPoints: 190Rank: Participant
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 12:20 pm #101490ParticipantPoints: 241Rank: Participant
Doesn't this work for you: Connect to Exchange servers using remote PowerShell?
May 31, 2018 at 3:10 pm #101514
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
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 #101529ParticipantPoints: 265Rank: Contributor
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 #101536
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 #101541
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 #101542
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 #101545
Ok, Jon, can I work arround this?
May 31, 2018 at 4:43 pm #101548
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 #101550
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 #101557
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 #101959
How to run/execute a PS script on remote servers ??
i just used like UCN path of the script,
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 #101986ParticipantPoints: 190Rank: Participant
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:
The topic ‘Powershell remoting to exchange’ is closed to new replies.