Run is producing this error but run in console does not

Ask your PowerShell-related questions, including questions on cmdlet development!
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.
This topic is 6 years and 4 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.
Locked
User avatar
chris.hartmann@braunability.com
Posts: 4
Last visit: Mon Dec 04, 2023 8:18 am

Run is producing this error but run in console does not

Post by chris.hartmann@braunability.com »

ERROR: & : File \\braunlift.com\share\Home Drives\chris_hartmann\PowerShell_Scripts\User-Profiles\Get-UserProfile.ps1 cannot be loaded. The file
ERROR: \\braunlift.com\share\Home Drives\chris_hartmann\PowerShell_Scripts\User-Profiles\Get-UserProfile.ps1 is not digitally signed. You cannot run this script on
ERROR: the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
ERROR: https:/go.microsoft.com/fwlink/?LinkID=135170.
line (1, 2): ERROR: At Line: 1 char: 2
ERROR: + &'\\braunlift.com\share\Home Drives\chris_hartmann\PowerShell_Scripts ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : SecurityError: (:) [], PSSecurityException
ERROR: + FullyQualifiedErrorId : UnauthorizedAccess
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Run is producing this error but run in console does not

Post by mxtrinidad »

Make sure to have set the execution policy on the machine before running the script. If this system is on a domain network, you may need your security team to set the proper Security Policy to allow the script to execute.

As the error message said, you can run the following command to get information about execution policy:

Get-Help about_Execution_Policies -detailed

:)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Run is producing this error but run in console does not

Post by jvierra »

This error:

"File \\braunlift.com\share\Home Drives\chris_hartmann\PowerShell_Scripts\User-Profiles\Get-UserProfile.ps1 cannot be loaded. The file
ERROR: \\braunlift.com\share\Home Drives\chris_hartmann\PowerShell_Scripts\User-Profiles\Get-UserProfile.ps1 is not digitally signed. You cannot run this script "


Is because the system is set to "RemoteSigned" and the share is not trusted. Your domain admins will not wat to change this or to force you to sign all scripts. This should not happen. This can happen if the domain trust with the PC has a problem or if your Intranet Zone is not set correctly. Contact you net Admin and have them look at your system to see why it is not trusting the share. All shared folders in a domain should be trusted by default. Things happen and can cause this.
This topic is 6 years and 4 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.
Locked