Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

adding a powershell snappin asynchronously

Posted on 2013-12-16
5
Medium Priority
?
485 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 71

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 71

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 71

Accepted Solution

by:
Qlemo earned 1500 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
August and September have been big months for VMware—from VMworld last month to our new Course of the Month in VMware Professional - Data Center Virtualization. We reached out to Andrew Hancock, resident VMware vExpert, to have a more in-depth discu…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

609 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