Minor fail analyzing scripts

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 6 years and 10 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
wartech
Posts: 52
Last visit: Wed Jan 03, 2024 9:09 am

Minor fail analyzing scripts

Post by wartech »

Product, version and build:
PowerShell Studio 2017 v5.4.139 64bit

Operating system:
Windows 7 SP1 64bit

PowerShell Version:
5.1.14409.1005

Whenever my scripts get analyzed in PowerShell Studio I get a message, in the debug panel, similar to the following:

>> Analyzing Script (Fix-BadShortcuts.ps1) ...
AuthorizationManager check failed.
>> Analyzing Script Completed (0 items: 0 Errors, 0 Warnings, 0 Information)

Scripts still function perfectly well.
Where should I be looking to find the cause?
Thanks.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Minor fail analyzing scripts

Post by DevinL »

A couple follow-up questions to help diagnose what's going on here:
  1. Where are your scripts located? Are they on your local machine or are you accessing a file server of sorts?
  2. Does this happen in a regular PowerShell console or just within PowerShell Studio?
  3. What're your settings for your execution policy?
Since the script executes normally, I'm led to believe it's something slightly off with the script you're executing or your particular install of PSScriptAnalyzer. Here are two similar issues on GitHub that may help to point you in the correct direction as well:
https://github.com/Microsoft/vsts-tasks ... -166344407
https://github.com/davidfowl/nugetpowertools/issues/8
DevinL
SAPIEN Technologies, Inc.
User avatar
wartech
Posts: 52
Last visit: Wed Jan 03, 2024 9:09 am

Re: Minor fail analyzing scripts

Post by wartech »

Hi,
Sorry for the delay (big Exchange migration happening).

In fact it was while trying to figure out what was up with the new Exchange Management Shell, that I realized it was the execution policy that was causing all of my problems.
It was set (via group policy for the domain) to AllSigned.

I guess I'm going to have to either:
Filter the policy (apply to non-IT users only)
or
Find all of the unsigned scripts and modules on Exchange Servers and IT dept. PCs, and sign them.

Does that sound about right?

Many thanks.
P.S. I realize now that this is a PowerShell problem, not a PowerShell Studio problem.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Minor fail analyzing scripts

Post by davidc »

It is considered a best practice to sign your scripts.

I recommend enabling the Automatically sign .ps1 scripts when saving option, under Options->PowerShell:
Auto Sign Scripts.png
Auto Sign Scripts.png (29.74 KiB) Viewed 4196 times
This way you don't have to manually sign the scripts.
David
SAPIEN Technologies, Inc.
User avatar
wartech
Posts: 52
Last visit: Wed Jan 03, 2024 9:09 am

Re: Minor fail analyzing scripts

Post by wartech »

Hi,
Sorry - what I meant was that it's all the scripts from external sources that seem to need signing,
e.g. scripts from NuGet, scripts that came with Microsoft Exchange management tools etc.
I guess I should write a script to hunt them all down & sign them.

All of the scripts & executables I create with PowerShell Studio are already auto-signed - :) otherwise they wouldn't survive the AllSigned execution policy.
User avatar
wartech
Posts: 52
Last visit: Wed Jan 03, 2024 9:09 am

Re: Minor fail analyzing scripts

Post by wartech »

Ah - just checked a bunch of MS scripts and they are signed with a Microsoft cert.
Maybe I need to figure out why aren't being trusted by my PC.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Minor fail analyzing scripts

Post by davidc »

Depending on how the scripts are downloaded, you might have to "Unblock" the files in order for them to run.
David
SAPIEN Technologies, Inc.
This topic is 6 years and 10 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.