Running Progressbar while adding a PSSnapin

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 9 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Luke_F
Posts: 7
Last visit: Mon May 15, 2017 2:26 am

Running Progressbar while adding a PSSnapin

Post by Luke_F »

Hi Guys,

I´m just trying to finish a ProwerShell GUI application for Microsoft SharePoint 2010 administration.
However a PSSnapin for SharePoint (Microsoft.SharePoint.PowerShell) is strongly required to rum SharePoint cmdlets.

Since I run SharePoint cmdlets at several stages on my application, I have to add the PSSnapin at the main form of my script.
To improve the usability I´d like to run a ProgressBarOverlay with Marquee style.
But while the PSSNapin is loading, the progressbar freeze.

Any ideas how to make this progressbar running without adding the PSSnapin in a job which adds the PSSnapn only in the job thread?

Thanks in advance for your help!
User avatar
SAPIEN Support Forums
Posts: 945
Last visit: Thu Oct 22, 2015 1:10 pm

Running Progressbar while adding a PSSnapin

Post by SAPIEN Support Forums »

This is an automated post. A real person will respond soon.

Thank you for posting, Luke_F.

Here are some hints to help you get an accurate and complete answer to your question.

Ask in the best forum: If you asked in the wrong forum, just copy your question to the right forum.

Anticipate follow-up questions!

Did you remember to include the following?
  • 1. Product, version and build
    2. 32 or 64 bit product
    3. Operating system, e.g. Windows 7 64 bit.
    4. Attach a screenshot, if applicable
    5. Attach logs, crash reports, etc., in a ZIP file
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Running Progressbar while adding a PSSnapin

Post by jvierra »

You cannot use a progress bar during the loading of a snapin. Since the application is single threaded you are frozen until theload is complete.
YOu cancreate a custimm console withteh snapin preloaded. Then use the console to launch you app. That is how Sharepoint does it. The consle still takes timmeot load.
YOu can skip the snap-in and use the Sharepointlibray directly. It does not take time to load.
User avatar
Luke_F
Posts: 7
Last visit: Mon May 15, 2017 2:26 am

Re: Running Progressbar while adding a PSSnapin

Post by Luke_F »

Thanks a lot for you reply.
Could you please let me know how to skip the snap-in and use the Sharepointlibray directly?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Running Progressbar while adding a PSSnapin

Post by jvierra »

Luke_F wrote:Thanks a lot for you reply.
Could you please let me know how to skip the snap-in and use the Sharepointlibray directly?
Not is a few sentences. Search for powershell and sharepoint. YOu should find manuy examples.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Running Progressbar while adding a PSSnapin

Post by jvierra »

Here is a teaser:
PowerShell Code
Double-click the code block to select all.
[System.Reflection.Assembly]::LoadWithPartialName ("Microsoft.SharePoint")
 $sitecollection = New-Object Microsoft.SharePoint.SPSite
("http://sharepoint/blog")
$web = $sitecollection.AllWebs["blog"]
$web.Title
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Running Progressbar while adding a PSSnapin

Post by dan.potter »

does the default progress bar run when adding a snappin on form load? I know the AD module does.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Running Progressbar while adding a PSSnapin

Post by jvierra »

No but it loads in about 1 second.
Add-PSSnapin Microsoft.SharePoint.PowerShell
This topic is 9 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked