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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.