Dallas Smetter
asked on
Remote Exchange Shell Credentials
The following works when run from dos prompt on the local machine.
PowerShell.exe -PSConsoleFile C:\Progra~1\Microsoft\Exch an~1\V15\B in\exshell .psc1 -Command ". New-MailboxExportRequest -Mailbox gina_testuser -FilePath \\deo-netapp01\userarchive $\gina_tes tuser_RC.p st"
But when I attempt to run it remotely, I get Access Denied. How can I send my credentials along with the command?
PowerShell.exe -PSConsoleFile C:\Progra~1\Microsoft\Exch
But when I attempt to run it remotely, I get Access Denied. How can I send my credentials along with the command?
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
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
ASKER
Hi Simon this is Exchange 2013
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$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
Remove-PSSession $Session
How can I include the password ?