Home computickets powershell scripting is disabled on this system

powershell scripting is disabled on this system

Author

Date

Category

if you execute from C: \ Windows \ system32, then everything is fine, if with D: \ SCRIPTS \ sc.ps1 then everything does not want to, how can this be fixed?

Unable to load file D: \ SCRIPTS \ sc.ps1 because scripting is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
  + CategoryInfo: Security Error: (:) [], ParentContainsErrorRecordException
  + FullyQualifiedErrorId: UnauthorizedAccess

here is the code

$ ipv4 = (Test-Connection -ComputerName $ env: computername -count 1) .ipv4address.IPAddressToString
  $ num = $ ipv4.split (".") [- 1]
  $ ie = Invoke-WebRequest -Uri "http: //****/indata.php? nt = $ num" -Method POST -ContentType "text / plain; charset = utf-8"

Answer 1, authority 100%

Solution to the problem:

  • Open a terminal from the admin.

  • Let’s write and run: Set-ExecutionPolicy RemoteSigned

  • We answer the question: A (Yes for all)


Answer 2, authority 9%

Follow the link , which is indicated by the error message, is the description of the execution policies.

To run local scripts, you need to set at least the REMOTESIGNED policy, in this case it will be possible to run local unsigned scripts.

To install the policy, you can use the command

Set-ExecutionPolicy -ExecutionPolicy & lt; PolicyName & gt;

You can also limit the scope of this policy by using the -Scope parameter. By default, the policy is installed for all users on the local computer, however using the CurrentUser value can restrict the application to only the current user, and using the Process value will limit the application to the currently running PowerShell process .

Thus, to execute, you can first execute the command:

& gt; Set-ExecutionPolicy RemoteSigned -Scope Process

and then run the script you want.


Answer 3

In my case, the following algorithm became the solution to the problem:

  1. D: \ SCRIPTS \ sc.ps1 – go to the folder with the script and right-click the buttons
  2. Choose to run with PowerShell – the console will appear
  3. I chose the highest runlevel

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions