PowerShell
Введение | |
Set-ExecutionPolicy Unrestricted -Force | |
Из консоли запустить как администратор | |
Сеть | |
Пользователи | |
Команды | |
Похожие статьи |
Set-ExecutionPolicy Unrestricted -Force
Вы пробуете выполнить ваш скритп
./your_script.ps1
И получаете
.\your_script.ps1 : File C:\Users\Andrei\your_script.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. At line:1 char:1 + .\your_script.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
Нужно зайти в PowerShell в режиме администратора и выполнить
Set-ExecutionPolicy Unrestricted -Force
И выполните ещё раз
./your_script.ps1
Если Вы не можете запустить
PowerShell
в режиме администратора. Например, если Вы пользуетесь терминалом в
Visual Studio Code
Выполните
Set-ExecutionPolicy -Scope CurrentUser Unrestricted -Force
Переключить PowerShell в режим Администратора прямо из обычной консоли PowerShell можно командой
start-process powershell -verb runas
Проверка версии
$PSVersionTable
Name Value ---- ----- PSVersion 5.1.19041.2364 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.2364 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Установка PowerShell
Может пригодиться для обновления до более свежей версии.
С помощью winget. Сперва рекомендуется проверить доступные версии
winget search Microsoft.PowerShell
The `msstore` source requires that you view the following agreements before using. Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US"). Do you agree to all the source agreements terms? [Y] Yes [N] No: Y Name Id Version Source ------------------------------------------------------- PowerShell Microsoft.PowerShell 7.3.3.0 winget PowerShell Microsoft.PowerShell.Preview 7.4.1.0 winget
Непосредственно установка
winget install --id Microsoft.Powershell --source winget
Found PowerShell [Microsoft.PowerShell] Version 7.3.3.0 This application is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.3.3/PowerShell-7.3.3-win-x64.msi ██████████████████████████████ 101 MB / 101 MB Successfully verified installer hash Starting package install... Successfully installed
PowerShell 7 установится не на замену обычному Windows PowerShell, а как дополнительный
софт.
Чтобы зайти в него нужно ввести в поиск PowerShell 7
Проверка версии, обычно не нужна, так как версия показана перед первым приглашением командной строки. Тем не менее можно выполнить стандартную команду
$PSVersionTable
Name Value ---- ----- PSVersion 7.3.3 PSEdition Core GitCommitId 7.3.3 OS Microsoft Windows 10.0.19045 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
Открытые порты |
Открыть порт |
Get-NetIPConfiguration: информация о сети |
Разрешить RDP подключения |
Статус OpenSSH сервера |
Запустить sshd |
Список пользователей |
Создать пользователя |