Hello,
Using Powershell Studio to consolidate certain SQL functions I ran into an issue with the folder browse button function which worked perfectly until it hung when run on servers with a PowerShell v2 environment.
Pressing the folder browse button simply caused the entire application to hang.(The file browse button worked fine though)
The issue of the "browse folder button" is solved by staring the PowerShell in STA and then running the PS1 script.
When compiled into an EXE, I made sure to choose v2 and STA, the folder browse button worked perfectly but the application failed on the following:
Add-PSSnapin SqlServerCmdletSnapin100
and
Add-PSSnapin SqlServerProviderSnapin100
All seems to work fine if the GUI is started using the script instead of the EXE by starting "powershell -sta" first.
Any fix for this behavior?
Issues running in STA
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.
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.
Re: Issues running in STA
Thanks for that tip, but that will not work in this case.
I forgot to mention, the script checks the SQL version, if the SQL cluster is running a 2012 or newer, SQLPS is imported, but if the SQL is an older version then the pssnapins are added.
I forgot to mention, the script checks the SQL version, if the SQL cluster is running a 2012 or newer, SQLPS is imported, but if the SQL is an older version then the pssnapins are added.
Re: Issues running in STA
SQLPS as an imported module is only supported in SQL 2012 or newer.
In 2008R2 versions it cannot be imported as a module, it is only a host, hence the need to add the pssnapins for certain operations.
In 2008R2 versions it cannot be imported as a module, it is only a host, hence the need to add the pssnapins for certain operations.
Re: Issues running in STA
No - I have been using it on SQS2008 for years. You have to upgrade the SSMS. It works just fine.
SQLPS works in PS 2 but the SQLASCMDLETS module will not work without PS4.
You will have many issues with the snap-in and PS2. I recommend upgrading PowerShell to the latest version and then all things will work.
If you load the snap-in then you will have to use MTA.
One way around the issue is to create your own folder browser and use stock PowerShell CmdLets to retrieve folders.
SQLPS works in PS 2 but the SQLASCMDLETS module will not work without PS4.
You will have many issues with the snap-in and PS2. I recommend upgrading PowerShell to the latest version and then all things will work.
If you load the snap-in then you will have to use MTA.
One way around the issue is to create your own folder browser and use stock PowerShell CmdLets to retrieve folders.
Re: Issues running in STA
Upgrading the PowerShell on 100+ servers is not an option at this point in time since they are being migrated and phased out.
For those servers, the SQLPS cannot be imported as a module and the need for the snapins arises.
So I conclude from our discussion that either an upgrade or to continue using it as a PS1 run in "Powershell -STA".
The issue with the browse folder has been solved in STA mode.
The snapins work in STA mode as well.
The problem with the snapins only surfaces when compiled to an EXE.
Thank you for your attempts.
For those servers, the SQLPS cannot be imported as a module and the need for the snapins arises.
So I conclude from our discussion that either an upgrade or to continue using it as a PS1 run in "Powershell -STA".
The issue with the browse folder has been solved in STA mode.
The snapins work in STA mode as well.
The problem with the snapins only surfaces when compiled to an EXE.
Thank you for your attempts.
Re: Issues running in STA
I thought I did, attached a snapshot of the settings.
- Attachments
-
- STA.jpg (39.58 KiB) Viewed 3262 times