Page 1 of 1

Minor fail analyzing scripts

Posted: Fri Apr 28, 2017 9:22 am
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.

Re: Minor fail analyzing scripts

Posted: Fri Apr 28, 2017 9:36 am
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

Re: Minor fail analyzing scripts

Posted: Wed May 03, 2017 8:26 am
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.

Re: Minor fail analyzing scripts

Posted: Wed May 03, 2017 8:45 am
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 4199 times
This way you don't have to manually sign the scripts.

Re: Minor fail analyzing scripts

Posted: Wed May 03, 2017 9:51 am
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.

Re: Minor fail analyzing scripts

Posted: Wed May 03, 2017 9:54 am
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.

Re: Minor fail analyzing scripts

Posted: Wed May 03, 2017 11:18 am
by davidc
Depending on how the scripts are downloaded, you might have to "Unblock" the files in order for them to run.