下载并安装 Windows PowerShell 5.1Download and install Windows PowerShell 5.1

如果使用的是 Windows 10 周年更新或 Windows Server 2016,则应已拥有 Windows PowerShell 5.1。If you are using Windows 10 Anniversary Update, or Windows Server 2016, you should already have Windows PowerShell 5.1. 这是因为此应用程序随这些操作系统预安装。That's because this application comes preinstalled with those operating systems.

要确定你使用的是什么版本的 Microsoft PowerShelll,请在 Windows 7 或 Windows Server 2008 R2 或 Windows Server 2012 计算机上执行以下步骤:To determine which version of Microsoft PowerShelll you are using, do the following on your Windows 7 or Windows Server 2008 R2 or Windows Server 2012 computer:

  1. 依次单击“开始”、“所有程序”、“附件”和“Windows PowerShell”,然后单击“Windows PowerShell”。Click Start, click All Programs, click Accessories, click Windows PowerShell, and then click Windows PowerShell.

  2. 在 PowerShell 控制台中,键入以下命令,然后按 ENTER:In the PowerShell console, type the following command and then press ENTER:

    Get-Host | Select-Object Version
    
  3. 控制台窗口中随后应显示以下类似信息:Information similar to the following should then be displayed in the console window:

     Version 
    -------
    4.0

    如果返回的版本号为 5.1,表明正在运行 Windows PowerShell 5.1。If the returned Version number is 5.1, then you are running Windows PowerShell 5.1. 如果返回的版本号不是 5.1,则需要安装 Windows PowerShell 5.1。If the returned Version number is not 5.1, then you'll need to install Windows PowerShell 5.1. 可从 Microsoft 下载中心下载 Windows Management Framework 5.1(其中包括 Windows PowerShell 5.1)。You can download Windows Management Framework 5.1, which includes Windows PowerShell 5.1, from the Microsoft Download Center.

验证已安装 Windows PowerShell 5.1 后,必须确保 PowerShell 已配置为可以运行远程脚本。After you've verified that Windows PowerShell 5.1 is installed, you must make sure that PowerShell has been configured for running remote scripts. 为此,以管理员身份启动 PowerShell。To do that, start PowerShell as an administrator. 在 Windows 7、Windows Server 2008 R2、Windows Server 2012 或 Windows Server 2012 R2 上执行以下操作:On Windows 7, Windows Server 2008 R2, Windows Server 2012, or Windows Server 2012 R2 do the following:

  1. 单击“启动”,依次单击“所有程序”、“附件”、“Windows PowerShell”,然后右键单击“Windows PowerShell”,单击“以管理员身份运行”。Click Start, click All Programs, click Accessories, click Windows PowerShell, right-click Windows PowerShell, and then click Run as administrator.

  2. 如果显示“用户帐户控制”对话框,单击“”确定要通过管理员凭据运行 PowerShell。If the User Account Control dialog box appears, click Yes to verify that you want to run PowerShell under administrator credentials.

如果运行的是 Windows 8,请完成此过程:If you are running Windows 8, complete this procedure instead:

  1. 访问超级按钮栏,单击“搜索”,然后右键单击“Windows PowerShell”。Access the Charms bar, click Search, and then right-click Windows PowerShell. 可以通过按住 Windows 键并按 C 来在任何 Windows 8 计算机(触摸屏或非触摸屏)上快速访问超级按钮栏。You can quickly access the Charms bar on any Windows 8 computer (touch screen or non-touch screen) by holding down the Windows key and pressing C.

  2. 在屏幕底部的工具栏中,单击“以管理员身份运行”。In the toolbar at the bottom of the screen, click Run as administrator.

  3. 如果显示“用户帐户控制”对话框,单击“”确定要通过管理员凭据运行 PowerShell。If the User Account Control dialog box appears, click Yes to verify that you want to run PowerShell under administrator credentials.

在 PowerShell 运行后,必须更改执行策略以允许运行远程脚本。After PowerShell is running, you must change the execution policy to allow the running of remote scripts. 在 PowerShell 控制台中,键入以下命令,然后按 ENTER:In the PowerShell console, type the following command and then press ENTER:

Set-ExecutionPolicy RemoteSigned -Force

备注

运行上述命令后,可能会收到以下错误消息:> Set-ExecutionPolicy:对注册表项“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Micrsoft.PowerShell”的访问被拒绝。When you run the preceding command, you might receive the following error message:> Set-ExecutionPolicy : Access to the registry key'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Micrsoft.PowerShell' is denied. 如果未在管理员凭据下运行 PowerShell,则通常会出现此错误消息。This error message typically occurs if you are not running PowerShell under administrator credentials. 关闭 PowerShell 会话,并以管理员身份启动新会话。Close your session of PowerShell, and start a new session as an administrator.

要验证是否已正确配置执行策略,请在 PowerShell 提示符处键入以下内容,然后按 Enter:To verify that the execution policy has been configured correctly, type the following at the PowerShell prompt and then press ENTER:

Get-ExecutionPolicy

如果获得以下值,则所有内容已正确配置:If you get back the following value, then everything has been configured correctly:

RemoteSigned

如果当前未运行 Windows PowerShell 5.1,则还需要从 Microsoft 下载中心下载并安装 Windows Management Framework 5.1。If you are not currently running Windows PowerShell 5.1, you'll also need to download and install Windows Management Framework 5.1 from the Microsoft Download Center. 这是一个安装程序包,包含 Windows PowerShell 5.1 和 Windows 远程管理 (WinRM) 3.0。This is an installation package that includes Windows PowerShell 5.1 and Windows Remote Management (WinRM) 3.0. 例如,如果运行的是 Windows 7 SP1,并且尚未更新到 Windows PowerShell 5.1,则可能需要此安装程序包。This installation package might be required if you, for example, are running Windows 7 SP1 and have not yet updated to Windows PowerShell 5.1. 如果运行的是 Windows Server 2016 或 Windows 10 周年更新,则无需安装 Windows PowerShell 5.1。If you are running Windows Server 2016, or Windows 10 Anniversary Update, there should be no need to install Windows PowerShell 5.1. 这些操作系统上预装了 Windows PowerShell 5.1。Windows PowerShell 5.1 comes preinstalled on those operating systems.

在安装 Windows Management Framework 5.1 之前:Before installing Windows Management Framework 5.1:

  • 确保已下载安装程序包的正确版本。Make sure you have downloaded the correct version of the installation package. 如果运行的是 64 位版本的 Windows 7 SP1,请下载文件 Win7AndW2K8R2-KB3191566-x64.ZIP。If you are running the 64-bit version of Windows 7 SP1, download the file Win7AndW2K8R2-KB3191566-x64.ZIP. 如果运行的是 32 位版本的 Windows 7,请下载文件 Win7-KB3191566-x86.ZIP。If you are running the 32-bit version of Windows 7, download the file Win7-KB3191566-x86.ZIP.

  • 如果计算机正在运行 Windows 7,请确保已安装 Windows 7 Service Pack 1。If you are running Windows 7 on your computer, make sure that you have installed Windows 7 Service Pack 1.

如果不确定正在运行的 Windows 版本,或者不确定是否已安装 Windows 7 Service Pack 1,请单击“开始”,右键单击“计算机”,然后单击“属性”。If you aren't sure which version of Windows you are running, or you aren't sure if you've installed Windows 7 Service Pack 1, click Start, right-click Computer, and then click Properties. “系统”对话框中将报告此信息。This information will be reported in the System dialog box.

要安装 Windows Management Framework 5.1,请完成安装和配置 WMF 5.1 中的程序。To install Windows Management Framework 5.1, complete the procedure in Install and Configure WMF 5.1.

计算机重新启动后,验证 Windows PowerShell 是否可以启动以及应用程序是否可在管理凭据下运行。After the computer has rebooted, verify that Windows PowerShell can start and that the application can be run under administrative credentials. 要执行此操作:To do this:

  1. 单击“启动”,依次单击“所有程序”、“附件”、“Windows PowerShell”,然后右键单击“Windows PowerShell”,单击“以管理员身份运行”。Click Start, click All Programs, click Accessories, click Windows PowerShell, right-click Windows PowerShell and then click Run as administrator.

  2. 如果显示“用户帐户控制”对话框,单击“”确定要通过管理员凭据运行 PowerShell。If the User Account Control dialog box appears, click Yes to verify that you want to run PowerShell under administrator credentials.

当 PowerShell 控制台出现时,应该验证 WinRM 服务是否正在运行并且已正确配置。When the PowerShell console appears, you should then verify that the WinRM service is running and has been configured correctly. 要验证服务是否正在运行,请在 PowerShell 提示符处键入以下命令,然后按 Enter:To verify that the service is running, type the following command at the PowerShell prompt and then press ENTER:

Get-Service winrm

屏幕上将显示有关 WinRM 服务的信息:Information about the WinRM service will then be displayed on screen:

Status   Name               DisplayName
------   ----               -----------
Running  winrm              Windows Remote Management (WS-Manag...

如果服务状态不是“正在运行”,请通过键入以下命令并按 Enter 来启动 WinRM 服务:If the service Status does not equal "Running", start the WinRM service by typing the following command and then pressing ENTER:

Start-Service winrm

服务启动后,请运行以下命令以确保 WinRM 使用基本身份验证:After the service has started, run the following command to make sure that WinRM is using Basic authentication:

winrm set winrm/config/client/auth '@{Basic="True"}'

屏幕上将显示以下类似信息:Information similar to the following will be displayed onscreen:

Auth
    Basic = true
    Digest = true
    Kerberos = true
    Negotiate = true
    Certificate = true
    CredSSP = false

如果基本身份验证设置为 true,则可以开始使用 PowerShell 连接 Skype for Business Online。If basic authentication has been set to true, then you're ready to use PowerShell to connect to Skype for Business Online.

提示

领英徽标 刚开始接触 Office 365?LinkedIn logo New to Office 365?

发现领英学习向 Office 365 管理员和 IT 专业人士提供的免费视频课程。Discover free video courses for Office 365 admins and IT pros, brought to you by LinkedIn Learning.

为 Windows PowerShell 设置计算机Set up your computer for Windows PowerShell