PowerShell是一种比命令提示符更强大的命令行shell和脚本语言。自Windows10发布以来,它已成为默认选择,并且有许多方法可以打开它。
PowerShell和命令提示符之间的区别是什么
PowerShell的使用更复杂,但它比命令提示符强大得多。这就是为什么它成为超级用户和it专业人员的首选脚本语言和命令行界面,与其他Linux和类Unix Shell竞争。
PowerShell是一个使用cmdlet(发音为“command-lets”)的便捷工具,它允许你执行一些非常酷的操作,如自动运行Windows或在启动特定应用时自动连接到VPN。
虽然你可以从“开始”菜单打开PowerShell,但本文包含一些(可能)更简单、更鲜为人知的启动此工具的方法。
从超级用户菜单打开PowerShell
当你按Windows+X时,超级用户菜单出现在任务栏中。这是一种从一个菜单访问多个设置、实用程序和系统程序的简单方法。
要从此菜单中打开PowerShell,请按Windows+X,然后单击“Windows PowerShell”或“Windows PowerShell(管理员)”。

请注意,由于Windows 10的创意者更新,PowerShell默认显示在超级用户菜单中。如果你没有看到它,则你的计算机可能不是最新的,或者,你可能在“设置”菜单中将其替换为“命令提示符”。
使用开始菜单搜索打开PowerShell
打开PowerShell的最快方法之一可能是通过开始菜单搜索。只需单击开始或搜索图标,然后在搜索框中键入“powershell”。

现在,单击“打开”或“以管理员身份运行”以正常或以管理权限打开PowerShell。

通过滚动开始菜单中的所有应用程序
由于PowerShell是默认的Windows 10程序,因此你可以在开始菜单的“所有应用程序”部分中找到其应用程序图标。
只需单击开始图标,然后单击“所有应用程序”以展开计算机上安装的应用程序列表。

向下滚动,单击“Windows PowerShell”文件夹,然后选择“Windows PowerShell”将其打开。

要以管理员权限运行PowerShell,请右键单击图标,然后在显示的上下文菜单中单击“以管理员身份运行”。

从运行对话框
按Windows+R打开“运行”对话框,然后在文本框中键入“powershell”。你可以单击“确定”(或按Enter)打开常规PowerShell窗口,或按Ctrl+Shift+Enter打开提升的PowerShell窗。

从文件资源管理器文件菜单启动PowerShell
如果需要从计算机上的特定文件夹打开PowerShell实例,可以使用文件资源管理器在当前选定的目录中初始化它。
要执行此操作,请打开文件资源管理器,并导航到要从中打开PowerShell窗口的文件夹。
到达后,单击“文件”,将鼠标悬停在“打开Windows PowerShell”上,然后选择以下选项之一:
“打开Windows PowerShell”:这将在当前文件夹中以标准权限打开PowerShell窗口。“以管理员身份打开Windows PowerShell”:这将在当前文件夹中打开具有管理员权限的PowerShell窗口。
请注意,此方法在“快速访问”目录中不起作用。单击“文件”时,你会发现打开PowerShell的选项变灰。
从文件资源管理器地址栏
要从文件浏览器地址栏打开PowerShell,请打开文件资源管理器。单击地址栏,键入“powershell”,然后按Enter键。

PowerShell将以已设置的当前文件夹的路径打开。

从任务管理器
要打开任务管理器,请按Ctrl+Shift+Esc。在出现的窗口中,单击“详细信息”。

现在,单击文件>运行新任务。

在文本框中键入“powershell”,然后单击“确定”继续。

如果要以管理员权限运行PowerShell,请确保选中“以系统管理权限创建此任务”选项。
从右键单击上下文菜单
另一种可以从任何位置打开Windows PowerShell的方法是通过右键单击上下文菜单。但是,如果你只是右键单击该文件夹,则不会看到该选项。相反,在右键单击时按Shift键。这将打开上下文菜单,并包括“在此处打开PowerShell窗口”选项。

你还可以修改注册表将PowerShell永久添加到右键单击上下文菜单。

在桌面上创建PowerShell快捷方式
如果你只想单击图标打开PowerShell,那么很容易为桌面创建一个。
要执行此操作,请右键单击桌面上的空白点。在关联菜单中,单击“新建”>“快捷方式”。

右键单击桌面上的空白空间,然后转到“新建”>“快捷方式”。
在出现的窗口中,在文本框中键入“powershell”,然后单击“下一步”继续。

命名快捷方式,然后单击“完成”以创建它。

现在,无论何时双击图标,PowerShell都将打开。

如果要以管理权限打开PowerShell,请右键单击快捷方式,然后从上下文菜单中选择“属性”。

单击“高级”。

最后,选择“用管理员身份运行”选项旁边的框,以允许快捷方式以最高权限运行。

在两个窗口中单击“确定”保存更改并关闭属性窗口。
请记住,可以同时安装多个版本的PowerShell。如果需要,则需要指定要使用的版本。例如,PowerShell 7将自己安装到“C:\Program Files\PowerShell\7”,而Windows附带的默认PowerShell位于“C:\Windows\System32\WindowsPowerShell\f1.0”。