Monday, 23 June 2014

Remote Powershell

Use remote powershell if you dont have installed Exchange Management tool.

Use the below script to log in through remote powershell

$username = 'domain\username'
$password = '**************'
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

$session = New-PSSession -Authentication basic -Credential $cred -ConnectionUri https://*****.******.com/PowerShell -ConfigurationName Microsoft.Exchange
Import-PSSession $session

If you want to login to the different machine through remote use the below code

$session = New-PSSession -Credential $cred -ComputerName <remote machine>
Enter-PSSession $sessio

To exit the remote session

Remove-PSSession $session

Powershell Execution policy

if the powershell scripts to be allowed to run the scripts on your computer, Use the below execution policy cmdlets

Set-ExecutionPolicy RemoteSigned

Then use the below cmdlet to check the execution policy