How to disable PS Studio from automatically adding commands

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

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 8 years and 5 months 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.
User avatar
PROSIT
Posts: 8
Last visit: Fri Aug 06, 2021 6:20 am

How to disable PS Studio from automatically adding commands

Post by PROSIT »

I'm running PowerShell Studio 2015 version 4.2.95.0

I have an issue where Studio "thinks" it should add commands to the top of my scripts and keeps breaking my scripts by doing so.

I used to have a module on my PC called Remote-Exchange that I would use for remotely connecting to Exchange Servers. I deleted that module ~ 1 year ago, but some how Studio will sometimes put that at the top of my script. Today I just lost ~ 2 hours of work due to the script crashing. When I looked up the error things pointed to a .Net 4.5 update that cannot run Exchange commands. I thought it had something to do with the Windows Updates that were pushed out last night and ran in circles for a while, testing with multiple machines, until finding the Studio added "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010" to the top of the Main Form.

How can I make Studio stop doing this and driving me crazy? If I need something like that there; I will add it.

Thanks,
User avatar
SAPIEN Support Forums
Posts: 945
Last visit: Thu Oct 22, 2015 1:10 pm

How to disable PS Studio from automatically adding commands

Post by SAPIEN Support Forums »

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

Thank you for posting, PROSIT.

Did you remember to include the following?
  • 1. Product, version and build (e.g. Product: PowerShell Studio 2014, Version & Build: 4.1.71. Version and build information can be found in the product's About box accessed by clicking the blue icon with the 'i' in the upper right hand corner of the ribbon.)
    2. Specify if you are running a 32 or 64 bit version
    3. Specify your operating system and if it is 32 or 64 bit.
    4. Attach a screenshot if your issue can be seen on the screen
    5. Attach a zip file if you have multiple files (crash reports, log entries, etc.) related to your issue.
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 ***
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: How to disable PS Studio from automatically adding comma

Post by davidc »

You can disable the auto-insert of import commands in Options->Editor:
Auto-insert import commands.png
Auto-insert import commands.png (43.27 KiB) Viewed 2365 times
David
David
SAPIEN Technologies, Inc.
User avatar
PROSIT
Posts: 8
Last visit: Fri Aug 06, 2021 6:20 am

Re: How to disable PS Studio from automatically adding comma

Post by PROSIT »

Right on!

Product: PowerShell Studio 2015
Version: 4.2.95
Build: When I visit "product's About box" there is not anything listed for "Build"

The product is 64-bit

My OS is Windows 8.1 Enterprise 64-bit
I do not add the "Add-PSSnapin ..." or the "Import-Module ActiveDirectory" commands here.  Studio is doing this on it's own.  I do not need them here as other parts of the script handle these things.
I do not add the "Add-PSSnapin ..." or the "Import-Module ActiveDirectory" commands here. Studio is doing this on it's own. I do not need them here as other parts of the script handle these things.
ScreenShot1.jpg (93.99 KiB) Viewed 2365 times
I have code that spins up a remote pssession to an Exchange server.  You can see this is executed and the connection successfully made.  Then the "Add-PSSnapin ..." command that Studio added to the top of the MainForm, ends up causing this error and crashes PowerShell.  Once I found the "Add-PSSnapin ..." command and removed it, the problem went away.
I have code that spins up a remote pssession to an Exchange server. You can see this is executed and the connection successfully made. Then the "Add-PSSnapin ..." command that Studio added to the top of the MainForm, ends up causing this error and crashes PowerShell. Once I found the "Add-PSSnapin ..." command and removed it, the problem went away.
ScreenShot2.jpg (189.27 KiB) Viewed 2365 times
User avatar
PROSIT
Posts: 8
Last visit: Fri Aug 06, 2021 6:20 am

Re: How to disable PS Studio from automatically adding comma

Post by PROSIT »

I unchecked "Auto-insert import commands for used modules" in the Options.

Thank you much davidc!
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: How to disable PS Studio from automatically adding comma

Post by davidc »

You're welcome.

Here is where the build number is show in the about box:
About Box version.png
About Box version.png (42.88 KiB) Viewed 2364 times
David
David
SAPIEN Technologies, Inc.
This topic is 8 years and 5 months 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.