Powershell Add-PSSnapin slow in RES Automation Manager

When I tried to schedule an simple PowerShell script [See script below], as a module in RES Automation Manager 2012 on a Windows 2008R2 machine, the task took a very long time to finish (+/- 2 min.)

Note: Script disables the logon to a XenApp server.

When I opened a PowerShell console on the Windows 2008R2 machine and ran the script, I found that the delay was caused by the “Add-PSSnapin” cmd-let. It appears that during this command the Snap-ins has to verify the certificate of the Snap-In online. The User in the security context of the task didn’t has access to the internet and because of this the check times-out and caused the delay.

Solution to this behavior is disabling the certificate check against the Certificate Revocation List. A way to do this is changing the value “State” at [HKCU:SoftwareMicrosoftWindowsCurrentVersion WinTrustTrust ProvidersSoftware Publishing] to “146944” (decimal).

I made an other PowerShel task, with the same user in the security context, to modify the above setting in the profile of this user.

After this modification of the duration of the task was reduced from +/- 2 min. to 2 a 3 sec.

Update: 030613:  RES Support made an article about this.