Powershell

Remote Active Directory /Exchange Administration with Windows PowerShell

Windows Server automatically installs the Active Directory Module for Windows PowerShell and Active Directory Administrative Center when you add the Active Directory Domain Services (AD DS) or Active Directory Lightweight Directory Services (AD LDS) role.

But if you like me you want to manage Active Directory from another computer at a remote location, and you can do so with the Active Directory Module and ADAC, as long as you are running Windows 7 on the remote computer.

My post about how can remote Active Directory /Exchange Administration with Windows PowerShell non-domain windows 7 pc ,and over Windows powershell ISE;

1)- Remote Exchange Administration with Windows PowerShell

To remote connection to exchange;

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

Or you can run below powershell script ;

Write-Host "Enter exchange server name : " -ForegroundColor Yellow -NoNewline
$exchurl = Read-Host
Write-Host "$exchurl sunucusundaki powershell session kuruluyor" -ForegroundColor Cyan
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$exchurl/PowerShell/ -Authentication Kerberos -Credential $UserCredential
Import-PSSession $Session

2)- RemoteActive Directory Administration with Windows PowerShell

To remote connection to Active Directory;

By default one can not import Active Directory module in Powershell in Windows 7. You need to do either of the below:

Download “Active Directory Management Gateway Service” on 2003 or 2008 server http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=2852
Download “Remote Server Administration Tools” on Win 7 KB958830: http://www.microsoft.com/download/en/details.aspx?id=7887

3)- In your Domain controller you have to run below command to command prompt;

winrm set winrm/config/client @{TrustedHosts=”ip adress “}

winrm set winrm/config/client @{TrustedHosts="ip adress your client machine wich install ise"}

after you can start below powershell script;

Write-Host "Enter domain controler server name : " -ForegroundColor Yellow -NoNewline
$dc = Read-Host
Write-Host "$dc sunucusu ile baglanti kuruluyor" -ForegroundColor Cyan
$s = New-PSSession -ComputerName $dc -Name AD -ConfigurationName microsoft.powershell -Authentication Kerberos -Credential (Get-Credential)
Enter-PSSession $s 
Write-Host "Please write " -ForegroundColor RED  -NoNewline
Write-Host "Import-Module activedirectory" -ForegroundColor cyan  -NoNewline
Write-Host " to load module " -ForegroundColor RED  -NoNewline

Not: after you connect please dont forget to install activedirectory module;

Import-Module activedirectory

Hi, I’m Savaş Saygılı