Author Posts

March 2, 2017 at 1:01 am

Greetings,
Users running a utility I wrote have RSAT installed on their Windows 7 machines.
This was to access Windows 2003 domain controllers.
We are finally upgrading to Server 2012 R2 DCs and I wanted my utility to have access to all the new cmdlets.
So I tried putting this in my code:

		$Global:ActiveSiteDC = (Get-ADDomainController -Discover -MinimumDirectoryServiceVersion Windows2008).name
		$s2012 = New-PSSession -ComputerName $Global:ActiveSiteDC -ea stop
		Import-Module ActiveDirectory -PSSession $s2012 -force -Verbose:$false -ea stop

I have found since I have done this that the import-module fails about 10% of the time for an unknown reason.
The other problem is that I had been using PSDefaultParameterValues to set some defaults for all AD cmdlets. I understand this does not work when importing modules remotely.
So my questions are:
How can I give my users full access to all Server 2012 cmdlets and also apply default parameter values to them please?
Thanks
David Z

March 2, 2017 at 3:19 pm

It's a little hard to tell you why it fails 10% of the time with the information you've provided; you'd need to troubleshoot that by looking through (for example) the Remoting logs on both machines.

The default parameter thing is what it is. It doesn't work for imported commands.

Alternately, you can just have people use Enter-PSSession to remote into the DC, and then run the commands "there" rather than trying to run them via implicit remoting. Or, and this would be the best, use the JEA toolkit to set up a Remoting endpoint that contains the commands you want. You could have that endpoint run a startup script that applies your default values. That would all exist remotely and you'd use Enter-PSSession to access the toolkit.

March 2, 2017 at 8:33 pm

Thanks.
It's a Powershell studio application (exe).
I could use the JEA toolkit but the number of commands is quite large and I am adding new ones regularly so that would be too hard to maintain.
Enter-PSSession is too complicated for the help desk people.
At this stage I've decided to use Invoke-command pointing to a DC when I need to use a cmdlet that RSAT doesnt have.
Cheers
David Z