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 SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
wartech
Posts: 48
Joined: Sun Jan 13, 2008 8:30 pm

Minor fail analyzing scripts

Post by wartech » Fri Apr 28, 2017 9:22 am

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
Site Admin
Posts: 1098
Joined: Mon Aug 17, 2015 2:25 pm

Re: Minor fail analyzing scripts

Post by DevinL » Fri Apr 28, 2017 9:36 am

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: 48
Joined: Sun Jan 13, 2008 8:30 pm

Re: Minor fail analyzing scripts

Post by wartech » Wed May 03, 2017 8:26 am

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
Joined: Thu Aug 18, 2011 4:56 am

Re: Minor fail analyzing scripts

Post by davidc » Wed May 03, 2017 8:45 am

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 1807 times
This way you don't have to manually sign the scripts.
David
SAPIEN Technologies, Inc.

User avatar
wartech
Posts: 48
Joined: Sun Jan 13, 2008 8:30 pm

Re: Minor fail analyzing scripts

Post by wartech » Wed May 03, 2017 9:51 am

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: 48
Joined: Sun Jan 13, 2008 8:30 pm

Re: Minor fail analyzing scripts

Post by wartech » Wed May 03, 2017 9:54 am

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
Joined: Thu Aug 18, 2011 4:56 am

Re: Minor fail analyzing scripts

Post by davidc » Wed May 03, 2017 11:18 am

Depending on how the scripts are downloaded, you might have to "Unblock" the files in order for them to run.
David
SAPIEN Technologies, Inc.