Remote Exchange Shell Credentials

The following works when run from dos prompt  on the local machine.

PowerShell.exe -PSConsoleFile C:\Progra~1\Microsoft\Exchan~1\V15\Bin\exshell.psc1 -Command ". New-MailboxExportRequest -Mailbox gina_testuser -FilePath \\deo-netapp01\userarchive$\gina_testuser_RC.pst"

But when I attempt to run it remotely, I get Access Denied. How can I send my credentials along with the command?
Dallas SmetterSolution EngineerAsked:
Who is Participating?
 
Simon Butler (Sembee)ConsultantCommented:
Same instructions should apply - if you have multiple servers connect to a CAS role holder in the above command line.

All Exchange 2013 EMS sessions are remote, even ones that are on the server itself.

Simon.
0
 
Dallas SmetterSolution EngineerAuthor Commented:
This too works, but it prompts for a password

$ExchangeServer = "deo-ex1301.mrpm.sd42.ca"
$Cred = Get-Credential MRPM\s-idauto
$SessionParams =
@{
   ConfigurationName = 'Microsoft.Exchange'
   ConnectionURI     = "http://$ExchangeServer/powershell/"
   Authentication    = 'Kerberos'
   Credential = $Cred
}

$Session = New-PSSession @SessionParams

Invoke-command -ScriptBlock {New-MailboxExportRequest -Mailbox gina_testuser -FilePath \\deo-netapp01\userarchive$\aaa_gina_testuser_RC.pst} -Session $Session

Remove-PSSession $Session

How can I include the password ?
0
 
Simon Butler (Sembee)ConsultantCommented:
Version of Exchange would help here.
If Exchange 2010, then start PowerShell, not a command prompt.
Enter this command:

$UserCredential = Get-Credential

You will then get a prompt for a username and password. Remember to enter username as domain\username.

Then run this command:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://servername/PowerShell/ -Authentication Kerberos -Credential $UserCredential

That will connect you to the server with the credentials originally entered.

Finally connect to a session thus:
Import-PSSession $Session

You can then run whatever commands that you want.

With that particular command, remember to grant the account using the relevant permission. It isn't set by default to anyone.

Simon.
Import-PSSession $Session
0
 
Dallas SmetterSolution EngineerAuthor Commented:
Hi Simon this is Exchange 2013
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.