Solved

adding a powershell snappin asynchronously

Posted on 2013-12-16
5
482 Views
Last Modified: 2014-01-06
I am writing a powershell based application using winforms which is intended to deploy servers using SCCM. One of the functions the application provides is the creation of virtual machines using the VMware PowerCLI pssnapin. The problem is that the when the app is run, the add-pssnapin takes around 50 secs to complete, during which time it looks like the app has hung.
I've tried using start-job to add the snapin, but it doesn't seem to work - any calls to the powercli cmdlets fail.
0
Comment
Question by:aferr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 39721701
Would really surprise me if anyone came up with something. You need the imported cmdlets, so how should that work? Remember - the snap-in changes your PS environment ...
0
 

Author Comment

by:aferr
ID: 39723550
I'm aware of the fact that the snapin changes the environment, what I'm trying to do is find a way to load it without having the application/script take a massive pause as it loads.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39723779
Didn't try, but maybe it works if you create a new session with start-job, importing the PowerCLI snap-in, and then Import-PsSession as soon as the job is ready again. Importing a session should work much faster than importing a module (the first time).

Another way is to start the whole application with a correct PowerCLI session configuration. You will have the delay when starting the application, though.
0
 

Author Comment

by:aferr
ID: 39734746
Tried your suggestion but ironically it took longer to import the session than it did to add the snappin
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39734771
Sad. I was afraid of that. Importing a session involves creating proxy calls, which puts more workload on it overall.
Are you able to use the session configuration from start, as PowerCLI does? What I refer to is something along:
powershell.exe -psc "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\""

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring Remote Assistance for use with SCCM
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
This video shows you how to use a vSphere client to connect to your ESX host as the root user. Demonstrates the basic connection of bypassing certification set up. Demonstrates how to access the traditional view to begin managing your virtual mac…
This video shows you how easy it is to boot from ISO images for virtual machines with the ISO images stored on a local datastore on the ESXi host.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question