AnsweredAssumed Answered

Powershell Add-PSSnapin slow in PAM

Question asked by Poyato on Mar 23, 2015
Latest reply on Oct 2, 2015 by rob.mccoy

When I tried to schedule an PowerShell script in PAM, the task took a very long time to finish (2 min ~ 4 min)

 

if(-not (Get-PSSnapin VMware.VimAutomation.Core))
{
Add-PSSnapin VMware*
}

Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -DefaultVIServerMode multiple -InvalidCertificateAction Ignore -Scope Session -ProxyPolicy NoProxy -Confirm:$false | Out-Null  

[void](Get-PSSnapin VMWare.VimAutomation.Core -ErrorVariable getVmwareSnapinErr 2> $null)
if ($getVmwareSnapinErr.Count -gt 0) {    Add-PSSnapin VMware.VimAutomation.Core }

Connect-VIServer 10.8.8.8 -User john -Password gandalf
Set-VM -VM myhostvm -Description "test for annottation" -Confirm:$false;
Set-Annotation -Entity laapdi62 -CustomAttribute "Contact" -Value Poyato

 

When I opened a PowerShell (PowerCli) console on the PAM Server (Windows 2008R2 machine) and run the script the process take +-1min in the first execution and <30sec in the second execution (The second time, the PSSnapin variables already in memory and just run the last two commands ).

 

Does anyone know of any solution to run a ps1 script but quickly, or even keep PSSnapin variables in PAM Server memory?

Outcomes