You’ve updated to the RTM version of Windows 10 only to learn that the remote server administration tools aren’t available as of yet:

Get-ADUser -Identity mikefrobbins 1 Get-ADUser -Identity mikefrobbins

Let’s say for example the Active Directory PowerShell module is something that you use on a daily basis and it’s necessary to perform your day to day responsibilities. Well, you’re out of luck because the RSAT tools aren’t available yet, but before you consider using RDP or the GUI to perform your duties, let’s take a look at a viable solution in PowerShell.

Create a PSSession to one of your domain controllers, specifying alternate credentials if necessary:

$session = New-PSSession -ComputerName vmhost -Credential (Get-Credential) 1 $session = New-PSSession -ComputerName vmhost -Credential ( Get-Credential )

If the specified domain controller is running PowerShell version 2, you’ll need to import the Active Directory module, but if it’s running PowerShell version 3 or higher, you can skip this step:

Invoke-Command -Session $session {Import-Module -Name ActiveDirectory} 1 Invoke-Command -Session $session { Import-Module -Name ActiveDirectory }

Import the PSSession and specify the Active Directory module:

Import-PSSession -Session $session -Module ActiveDirectory 1 Import-PSSession -Session $session -Module ActiveDirectory

What we’ve done is to use implicit remoting to create shortcuts of the Active Directory cmdlets on the local computer from the domain controller that was previously specified. When the active directory cmdlets are executed, they run on the domain controller through the PSSession that was created but it will seem as if they exist locally. The problem though is this has to be recreated each time PowerShell is restarted. Or does it? Wouldn’t it be awesome to be able to make these shortcuts to the Active Directory cmdlets persistent so they exist each time PowerShell is opened on your local computer?

All that’s required to accomplish this is a pinch of pixie dust that can be retrieved from a Leprechaun at the end of the rainbow. Although it does seem like magic, all we really need to do to accomplish this is to simply use the Export-PSSession cmdlet to save the module:

Export-PSSession -Session $session -Module ActiveDirectory -OutputModule "$env:ProgramFiles\WindowsPowerShell\Modules\ActiveDirectory" -FormatTypeName * -AllowClobber 1 Export-PSSession -Session $session -Module ActiveDirectory -OutputModule "$env:ProgramFiles\WindowsPowerShell\Modules\ActiveDirectory" -FormatTypeName * -AllowClobber

I’ve now closed my PowerShell console and reopened it. Now when I try to use one of the cmdlets that’s part of the Active Directory module, the PSSession is automatically recreated without having to jump through the hoops of setting up implicit remoting again:

Get-ADUser -Identity mikefrobbins 1 Get-ADUser -Identity mikefrobbins

When the RSAT tools become available, I’ll remove the local Active Directory module that was created with the Export-PSSession cmdlet, but until then, this works like a charm.

Note: PowerShell remoting must be enabled on the domain controller that you’re attempting to use with implicit remoting as shown in this blog article, but if it’s running Windows Server 2012 or higher, PowerShell remoting is already enabled by default.

µ

Share this: Twitter

Reddit

LinkedIn

Facebook

Pocket

Print

