Операционная система: Windows 7 64bit (недавно переустановил)
Версия PowerShell 3.0
Моя учётная запись единственная в системе имеет права админа
Понадобилось запустить скрипты powerShell (написанные мною). При запуске скрипта (F5) PowerShell ISE ругается следующим сообщением:
«Невозможно загрузить файл D:Test.ps1, так как выполнение сценариев отключено в этой системе. Для получения дополнительных сведений см. about_Execu
tion_Policies по адресу http://go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : Ошибка безопасности: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess»
Запустил консоль PowerShell (64bit) с правами админа: установил executionpolicy на Unrestricted
Перезагрузил ПК, в консоли PowerShell проверил политику безопасности (get-executionpolicy), получил ответ: Unrestricted
Запустил PowerShell ISE, создал новый скрипт, вставил в него код из двух строк, сохранил на диске. Нажал Выполнить (F5) — получил такую же ошибку:
«Невозможно загрузить файл D:Test2.ps1, так как выполнение сценариев отключено в этой системе. Для получения дополнительных сведений см. about_Execu
tion_Policies по адресу http://go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : Ошибка безопасности: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess»
Перезагружался несколько раз уже, устанавливал разные политики — всё без результатно. В чём может быть проблема? Раньше до переустановки Windows всё работало. Версия Ос была такая же, обновления стояли все последние, версия powershell была 2.0 (в ней устанавливалась
политика на RemoteSigned) и после этого powershell был обновлён до 3.0. Но по-прежнему скрипты работали без проблем.
|
0 / 0 / 0 Регистрация: 19.09.2022 Сообщений: 8 |
|
|
1 |
|
|
27.09.2022, 20:40. Показов 530. Ответов 2
Подскажите как решить ошибку Миниатюры
__________________
0 |
|
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
27.09.2022, 20:40 |
|
Ответы с готовыми решениями: Ошибка безопасности Ошибка настроек безопасности Возникла проблема, пытался разобраться сам, но не смог, прошу… WebClient — ошибка безопасности почему в ответе — ошибка безопасности?? код по примеру из книжки, вроде… Ошибка безопасности доступа 2 |
|
86 / 58 / 29 Регистрация: 08.02.2021 Сообщений: 166 |
|
|
27.09.2022, 23:03 |
2 |
|
Вот
0 |
|
86 / 58 / 29 Регистрация: 08.02.2021 Сообщений: 166 |
|
|
27.09.2022, 23:12 |
3 |
|
Должно быть написано «cmd» Миниатюры
0 |
Невозможно загрузить файл c:scriptsMyScript.ps1, так как выполнение
сценариев отключено в этой системе. Для получения дополнительных сведений
см. about_Execution_Policies по адресу https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : Ошибка безопасности: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
File c:scriptsMyScript.ps1 cannot be loaded because running scripts is disabled on
this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Сообщение говорит о том, что не хватает прав для запуска скрипта — работает текущая политика безопасности PowerShell. Существуют следующие уровни настройки безопасности: AllSigned, Bypass, Default, RemoteSigned, Restricted, Undefined, Unrestricted. Самое распространенное состояние политики, когда появляется такая ошибка — Restricted.
Чтобы разрешить запуск скриптов, нужно назначить политику Unrestricted, для этого запустите команду с правами администратора:
powershell Set-ExecutionPolicy Unrestricted
Чтобы узнать текущее состояние политики, запустите следующую команду:
powershell Get-ExecutionPolicy
Skip to content
I wrote a small simple PowerShell script to copy (sync) files from one folder to another in Windows PowerShell ISE. It ran fine whist I was testing it running each command line individually. I then saved the file with a .ps1 extension and when I ran it I got the following error message:
File <file location and name> cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+FullyQualifiedErrorId : UnauthorizedAccess

The reason for this error is that the default policy does not allow a script to be run. Depending on your Windows version the default policy is either Restricted or RemoteSigned:
- Windows Server default is RemoteSigned
- Windows Clients default is Restricted
In my case here, I am running a Windows 10 machine and it was restricted. Here’s a brief explanation of each defaults:
- RemoteSigned
- Scripts can run but if they have not been created on the local machine (i.e. downloaded from another source) then they require a digital signature
- Restricted
- Scripts are not allowed to run but individual commands are allowed.
For more information about these defaults please refer to this Microsoft page:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.1
How to Fix it
There are a couple of options to fixing this and I’ve provided the commands under each of the options below:
- Allowing all scripts to run (not so secure)
|
Set—ExecutionPolicy RemoteSigned |
- Allowing all scripts to run under the current user (more secure)
|
Set—ExecutionPolicy RemoteSigned —Scope CurrentUser |
- Allowing this specific script file to run (the most secure)
|
Set—ExecutionPolicy ByPass —File <File Name>.ps1 |
To run these commands, copy them to a new PowerShelll file and run them from there. If prompted to change the policy, click “Yes”. An example prompt is below:

Refer to the URL below for more information on the PowerShell set-executionpolicy command:
https://docs.microsoft.com/en-gb/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.1
Good luck and feel free to leave a comment if you are having an issue.
Recent Posts
[], ParentContainsErrorRecordException