Windows где лежит powershell

To find the path to the PowerShell executable on your system, you can use the following command in a PowerShell prompt:

$PSHome

This command outputs the directory location where PowerShell is installed, typically something like `C:\Windows\System32\WindowsPowerShell\v1.0\`.

What is PowerShell?

PowerShell is a task automation framework from Microsoft that includes a command-line shell and an associated scripting language. It is designed for system administrators and power users to help manage the administration of the system by allowing them to automate tasks and configuration management. Understanding the path to PowerShell EXE is essential for effective use, as it allows users to quickly launch the shell or use it within scripts.

Bash to PowerShell Converter: A Quick Guide

Bash to PowerShell Converter: A Quick Guide

Understanding Executable Files

What is an Executable File?

An executable file (.exe) is a file format that contains a program, which can be directly executed by the computer. These files include the instructions that the operating system needs to run a program. Generally, executable files are contrasted with script files, where the latter requires an interpreter (like PowerShell or Python) to execute the contained code.

Essential Guide to Update to PowerShell 7

Essential Guide to Update to PowerShell 7

Where is PowerShell EXE Located?

PowerShell has specific default locations where the executable files are stored, depending on the version you are using.

Windows PowerShell

For Windows PowerShell, the default path is:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

PowerShell Core

For PowerShell Core (also known as PowerShell 7+), the default paths can vary based on how it was installed. Common paths include:

C:\Program Files\PowerShell\7\pwsh.exe

or, if installed via the Windows Store,

C:\Program Files\WindowsApps\Microsoft.PowerShell_7.2.0.0_x64__8wekyb3d8bbwe\pwsh.exe

Knowing the path to PowerShell EXE is crucial as it determines how you can access and run PowerShell in your scripts and commands.

Finding the PowerShell Path

Using Environment Variables

Windows maintains an environment variable known as `PATH`, which contains a list of directories that the operating system searches for executable files. You can view the `PATH` variable by executing the following command in any command line interface, including PowerShell:

echo $Env:Path

If PowerShell’s directory is included in this list, you can run PowerShell commands from any location without specifying the full path.

Using Windows Explorer

To manually navigate to the folder containing PowerShell EXE, you can use Windows Explorer:

  1. Open Windows Explorer (File Explorer).
  2. Navigate to `C:\Windows\System32\WindowsPowerShell\v1.0\` for Windows PowerShell or `C:\Program Files\PowerShell\7\` for PowerShell Core.
  3. Locate `powershell.exe` or `pwsh.exe` respectively.

Confirming PowerShell Version

It’s essential to check which version of PowerShell is currently installed, as it can influence the commands and scripts you execute. To confirm your PowerShell version, run the following command:

$PSVersionTable.PSVersion

This will display the version number, giving you insight into the features available to you.

Understanding Microsoft.PowerShell.Commands.Internal.Format.FormatStartData

Understanding Microsoft.PowerShell.Commands.Internal.Format.FormatStartData

Customizing the Path

Modifying Environment Variables

If you wish to add a new installation path of PowerShell to the system environment variable, follow these steps:

  1. Access System Properties:

    • Right-click on the This PC or Computer icon on the desktop.
    • Select Properties.
    • Click on Advanced system settings on the left sidebar.
  2. Edit Environment Variables:

    • In the System Properties window, click on the Environment Variables button.
    • Under the System variables section, find and select the `Path` variable, then click Edit.
  3. Add New Path:

    • Click New and enter the path to your PowerShell installation (e.g., `C:\Program Files\PowerShell\7\`).
    • Click OK to close all dialog boxes.

Now, you’ll be able to run PowerShell commands from any command line interface by just typing `powershell` or `pwsh`.

Mastering Microsoft.PowerShell.Commands.WriteErrorException

Mastering Microsoft.PowerShell.Commands.WriteErrorException

Troubleshooting Path Issues

Common Path-related Issues

When working with PowerShell, some users encounter issues where PowerShell is not recognized as a command. This usually happens because the executable’s path is not included in the system PATH variable. To resolve this:

  1. Confirm that the path to the PowerShell EXE is correct and included in your `PATH`.
  2. Ensure you are using the correct command for the version of PowerShell installed.

Verifying Executable Integrity

There may be situations where the path configured is incorrect or the executable is missing. You can verify if the executable exists at the specified path by using the following command:

Test-Path "C:\Program Files\PowerShell\7\pwsh.exe"

This command will return `True` if the file exists, or `False` if it doesn’t. If the path does not exist, you may need to reinstall PowerShell or correct the path.

Mastering PowerShell: Using powershell.exe -command Effectively

Mastering PowerShell: Using powershell.exe -command Effectively

Using PowerShell Launch Options

Launching PowerShell with Arguments

Understanding how to launch PowerShell with specific arguments can enhance your scripting capabilities. Different launch options allow you to customize the behavior of PowerShell when it starts.

For example, to launch PowerShell with no exit and to bypass the execution policy, use the following command:

Start-Process powershell.exe -ArgumentList "-NoExit", "-ExecutionPolicy Bypass"

This command ensures that the PowerShell window remains open and that scripts can run without being blocked by default execution policies.

Mastering PowerShell Expression for Swift Automation

Mastering PowerShell Expression for Swift Automation

Practical Applications of Knowing the Path

Knowing the path to PowerShell EXE is particularly useful for automating tasks within scripts. You can call PowerShell from batch files or other scripts, making it a versatile tool for system administration and automation.

For instance, you could create a batch file that runs a PowerShell script located anywhere in your filesystem. Writing a simple command like this in your batch file can initiate the script:

@echo off
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\path\to\script.ps1"

Watch PowerShell: Mastering Command Efficiency

Watch PowerShell: Mastering Command Efficiency

Conclusion

In summary, understanding the path to PowerShell EXE is invaluable for effective PowerShell usage. By locating the executable, customizing your environment, and troubleshooting common issues, you enhance your productivity as a system administrator or power user. Experimenting with different commands and configurations will lead to a deeper understanding and mastery of PowerShell.

Mastering PowerShell.exe -ExecutionPolicy for Secure Scripts

Mastering PowerShell.exe -ExecutionPolicy for Secure Scripts

Additional Resources

To further your PowerShell knowledge, consider checking official Microsoft documentation and related tutorials that delve into advanced scripting techniques. These resources will complement your understanding and expertise in using PowerShell effectively.

Все способы:

  • Способ 1: Поиск
  • Способ 2: «Пуск»
    • Вариант 1: Главное меню
    • Вариант 2: Контекстное меню
  • Способ 3: «Командная строка»
  • Способ 4: «Выполнить»
  • Способ 5: «Диспетчер задач»
  • Способ 6: Исполняемый файл
  • Вопросы и ответы: 0

Способ 1: Поиск

В абсолютном большинстве случаев, если вы не знаете, как открыть то или иное, стандартное для Виндовс 10 приложение, следует задействовать доступную на панели задач функцию поиска.

Как открыть «PowerShell» в Windows 10_002

Для решения нашей задачи кликните по поисковому полю или воспользуйтесь клавишами «Win+S», после чего начните вводить запрос «PowerShell» — как только искомый компонент появится в списке «Лучшее соответствие», вы сможете его «Открыть», нажав по соответствующей надписи-ссылке или ярлыку с названием.

Как открыть «PowerShell» в Windows 10_003

Читайте также: Включение и использование функции поиска в Windows 10

Способ 2: «Пуск»

Практически все системные приложения можно запустить через «Пуск», причем в случае с «ПоверШел» это можно сделать как из его основного меню, так и из дополнительного (контекстного).

Вариант 1: Главное меню

Вызовите меню «Пуск» с помощью кнопки на панели задач или клавиши «Win» на клавиатуре и пролистайте список с приложениями вниз. Найдите и откройте папку «Windows PowerShell», а затем запустите одиночным нажатием левой кнопки мышки (ЛКМ) одноименный исполняемый файл, первый в списке.

Как открыть «PowerShell» в Windows 10_004

Вариант 2: Контекстное меню

Еще более простым и быстрым в своей реализации, чем два предложенных выше решения, является использование дополнительного меню кнопки «Пуск». Нажмите по нему правой кнопкой мышки (ПКМ) или воспользуйтесь клавишами «Win+X» и выберите пункт «Windows PowerShell».

Как открыть «PowerShell» в Windows 10_005

Обратите внимание! В контекстном меню «Пуска» по умолчанию находится именно «PowerShell», однако его вполне можно заменить на классическую «Командную строку». Если в списке опций вы видите второе, а не первое из обозначенных приложений, откройте системные «Параметры» (сочетание клавиш «Win+I»), перейдите к разделу «Персонализация», затем откройте вкладку «Панель задач» и переведите в активное положение отмеченный на изображении ниже переключатель. Если же таким образом вы хотите запускать стандартную консоль, наоборот, отключите его.

Как открыть «PowerShell» в Windows 10_015

Способ 3: «Командная строка»

«ПоверШел» в некоторой степени представляет собой более усовершенствованный и современный аналог классической для разных версий ОС от Майкрософт консоли. При этом последнюю вполне можно задействовать для запуска первой.

  1. Используя поиск или любой другой удобный способ, откройте «Командную строку».
    Как открыть «PowerShell» в Windows 10_006

    Читайте также: Как открыть консоль в Виндовс 10

  2. Введите команду, представляющую собой наименование интересующего нас в рамках настоящей статьи компонента ОС Windows 10 (указано ниже) и нажмите «Enter».

    powershell

  3. Как открыть «PowerShell» в Windows 10_007

  4. «ПоверШел» будет незамедлительно открыта в отдельном окне.
  5. Как открыть «PowerShell» в Windows 10_003

Способ 4: «Выполнить»

Окно «Выполнить» — довольно удобный инструмент для быстрого запуска различных программ и компонентов, интегрированных в Windows 10, включая «PowerShell».

  1. Воспользуйтесь системным поиском или сочетанием клавиш «Win+R» для вызова средства запуска.

    Как открыть «PowerShell» в Windows 10_008

    Читайте также: Как открыть окно «Выполнить» в Виндовс 10

  2. Введите название искомого приложения.

    powershell

  3. Как открыть «PowerShell» в Windows 10_009

  4. Как только вы нажмете «ОК» или «Enter», произойдет запуск искомой оснастки.
  5. Как открыть «PowerShell» в Windows 10_003

Способ 5: «Диспетчер задач»

Встроенный в Windows 10 «Диспетчер задач» (ДЗ), помимо того, что позволяет мониторить состояние операционной системы, ее программных и аппаратных компонентов, также может использоваться и как средство запуска нужных программ и процессов.

  1. Откройте «Диспетчер задач». Проще всего для этого воспользоваться сочетанием клавиш «Ctrl+Shift+Esc» или контекстным меню, вызываемым на кнопке «Пуск» либо пустом месте панели задач – в обоих случаях потребуется выбрать пункт с соответствующим названием.
    Как открыть «PowerShell» в Windows 10_010

    Читайте также: Как открыть «Диспетчер задач» в Виндовс 10

  2. Разверните меню вкладки «Файл» и выберите в нем пункт «Запустить новую задачу».
  3. Как открыть «PowerShell» в Windows 10_011

  4. В поле появившегося окна введите уже знакомую по предыдущим способам и продублированную ниже команду, после чего нажмите «ОК» или «Enter». Если запуск требуется выполнить с правами администратора, установите галочку напротив соответствующего пункта.

    powershell

  5. Как открыть «PowerShell» в Windows 10_012

Способ 6: Исполняемый файл

Каждое системное приложение имеет свой исполняемый файл, у «ПоверШел» таковой находится по следующему пути:

C:\Windows\System32\WindowsPowerShell\v1.0

Как открыть «PowerShell» в Windows 10_013

Используя «Проводник», перейдите в указанную директорию, пролистайте список представленных в ней папок и файлов вниз, найдите элемент с названием «powershell» (тот, что имеет уже узнаваемый по предыдущим способам значок), расширением «EXE» (если отображается) и типом «Приложение».

Как открыть «PowerShell» в Windows 10_014

Запустите его двойным нажатием ЛКМ.

Как открыть «PowerShell» в Windows 10_003

Читайте также: Как открыть «Проводник» в Виндовс 10

Наша группа в TelegramПолезные советы и помощь

  1. Use Host.version to Find the Location of the PowerShell.exe in Windows Server 2008

  2. Get-Process to Find the Location of the PowerShell.exe in Windows Server 2008

PowerShell Location

PowerShell is a Command-line interface for Scripting purposes, automation requirements, and CI/CD systems management installed by default in every Windows PC, starting with Windows 7.

It is used to bridge this gap between Windows users and users of Linux-like systems.

This article is mainly about finding the PowerShell.exe file location in different ways.

The focus group of users of the provided solution would be Windows Server 2008 users. Yet, it applies to users from Windows 7 Version upwards.

Use Host.version to Find the Location of the PowerShell.exe in Windows Server 2008

When you use a version of Windows PowerShell newer to Version 1.0, you will have difficulty finding the correct pathway to Windows PowerShell. In my case, I have PowerShell version 5 installed on my Windows 10 PC.

Yet when the command to open the directory in Windows PowerShell dir is run, the shown version is v1.0.

PS C:\Windows\System32\WindowsPowerShell> dir

Output:

Directory: C:\Windows\System32\WindowsPowerShell
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          4/9/2021   7:23 PM                v1.0

Here what happens is confusion caused due to directory naming by Microsoft.

It shows Length Name as v1.0, but this is not my PC’s actual version name of the PowerShell application. Therefore, We will use the $Host.version command to find the correct version of PowerShell.

PS C:\Windows\System32\WindowsPowerShell> $Host.version

The output of this code shows the correct major and minor versions of PowerShell.

PS C:\Windows\System32\WindowsPowerShell> $Host.version
Major  Minor  Build  Revision
---- - ---- - ---- - --------
5      1      19041  1320

As you can see, the version is Windows PowerShell 5.1, not Version v1.0.

This confusion is caused because developers were updating the version. However, the file folder name remains the same as v1.0. Inside the v1.0 folder directory, you can see the .exe file of Windows PowerShell 5.1.

If you find the correct location, you have to go inside the v1.0 folder and get the .exe file. To find the right version information, you need to execute PowerShell’s $Host.version command.

Get-Process to Find the Location of the PowerShell.exe in Windows Server 2008

A convenient way of finding the location pathway of the PowerShell.exe file in Windows PC is through the Get-Process command.

You do not need to direct to the PowerShell folder to run the commands. Below is the command that would directly show the path of the PowerShell.exe file.

PS C:\Users\Agni> (Get-Process powershell | select -First 1).Path

Output:

PS C:\Users\Agni> (Get-Process powershell | select -First 1).Path
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Hence, this method can be identified as the hassle-free way to determine the correct pathway to the required .exe file. Yet, you cannot identify the version of your PowerShell as we did in the previous method.

Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe

Многие инструкции на этом сайте в качестве одного из первых шагов предлагают запустить PowerShell, обычно от имени администратора. Иногда в комментариях появляется от начинающих пользователей вопрос о том, как это сделать.

В этом руководстве подробно о способах открыть PowerShell, в том числе от администратора, в Windows 10, 8 и Windows 7, а также видео инструкция, где все эти способы показаны наглядно. Также может быть полезно: Способы открыть командную строку от имени администратора.

Запуск Windows PowerShell с помощью поиска

Моя первая рекомендация на тему запуска любой утилиты Windows, которую вы не знаете, как запустить — использовать поиск, он поможет почти всегда.

Кнопка поиска есть на панели задач Windows 10, в Windows 8 и 8.1 поле поиска можно открыть клавишами Win+S, а в Windows 7 найти в меню «Пуск». Шаги (на примере 10-ки) будут следующими.

  1. В поиск начните вводить PowerShell, пока не покажется необходимый результат. 
  2. Если требуется запуск от имени администратора, нажмите по Windows PowerShell правой кнопкой мыши и выберите соответствующий пункт контекстного меню. 

Как видите, очень просто и подходит для любой из последних версий Windows.

Как открыть PowerShell через контекстное меню кнопки «Пуск» в Windows 10

Если на вашем компьютере установлена Windows 10, то, пожалуй, ещё более быстрый способ открыть PowerShell — нажать правой кнопкой мыши по кнопке «Пуск» и выбрать нужный пункт меню (там присутствует сразу два пункта — для простого запуска и от имени администратора). Это же меню можно вызвать, нажав клавиши Win+X на клавиатуре.

Примечание: если в этом меню вместо Windows PowerShell у вас отображается командная строка, то заменить её на PowerShell вы, при желании, можете в Параметры — Персонализация — Панель задач, включив пункт «Заменить командную строку оболочкой Windows Powershell» (в последних версиях Windows 10 параметр включен по умолчанию).

Запуск PowerShell с помощью диалогового окна «Выполнить»

Еще один простой способ запуска PowerShell — использовать окно «Выполнить»:

  1. Нажмите клавиши Win+R на клавиатуре.
  2. Введите powershell и нажмите Enter или Ок.

При этом в Windows 7 можно установить отметку запуска от имени администратора, а в последней версии Windows 10, если при нажатии Enter или Ok удерживать клавиши Ctrl + Shift, то утилита также запуститься от имени администратора.

Видео инструкция

Другие способы открыть PowerShell

Выше перечислены далеко не все способы открытия Windows PowerShell, но, уверен, что их будет вполне достаточно. Если же нет, то:

Также, бывает, спрашивают, а что такое PowerShell ISE и PowerShell x86, которые находятся, например, при использовании первого способа. Отвечаю: PowerShell ISE — «Интегрированная среда сценариев PowerShell». По сути, с её помощью можно выполнять все те же команды, но, помимо этого, в ней присутствуют дополнительные возможности, облегчающие работу со скриптами PowerShell (справка, инструменты отладки, цветовая разметка, дополнительные горячие клавиши и т.п.). В свою очередь версии x86 нужны в случае, если вы работаете с 32-битными объектами или с удаленной системой x86.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как переустановить windows 10 с загрузочной флешки
  • Opus кодек для windows
  • Easy screen ocr для windows
  • Windows 10 как найти поиск
  • Windows xp unofficial service pack 4