Enable and Use Remote Commands in Windows PowerShell

The Windows PowerShell remoting features are supported by the WS-Management protocol and the Windows Remote Management (WinRM) service that implements WS-Management in Windows. Computers running Windows 7 and later include WinRM 2.0 or later. On computers running earlier versions of Windows, you need to install WinRM 2.0 or later as appropriate and if supported. Currently, remoting is supported on Windows Vista with Service Pack 1 or later, Windows 7, Windows Server 2008, and Windows Server 2008 Release 2.

You can verify the availability of WinRM and configure a PowerShell for remoting by following these steps: 
1. Start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator.

2. The WinRM service is confi gured for manual startup by default. You must change the startup type to Automatic and start the service on each computer you want to work with. At the PowerShell prompt, you can verify that the WinRM service is running using the following command: 
get-service winrm
The value of the Status property in the output should be “Running”.

3. To configure Windows PowerShell for remoting, type the following command: 
Enable-PSRemoting –force

In many cases, you will be able to work with remote computers in other domains. However, if the remote computer is not in a trusted domain, the remote computer might not be able to authenticate your credentials. To enable authentication, you need to add the remote computer to the list of trusted hosts for the local computer in WinRM. To do so, type: 
winrm s winrm/config/client ‘@{TrustedHosts="RemoteComputer"}‘
Here, RemoteComputer should be the name of the remote computer, such as: 
winrm s winrm/config/client ‘@{TrustedHosts="CorpServer56"}‘

When you are working with computers in workgroups or homegroups, you must either use HTTPS as the transport or add the remote machine to the TrustedHosts configuration settings. If you cannot connect to a remote host, verify that the service on the remote host is running and is accepting requests by running the following command on the remote host: 
winrm quickconfig
This command analyzes and configures the WinRM service.

To use Windows PowerShell remoting features, you must start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator. When starting PowerShell from another program, such as the command prompt (cmd.exe), you must start that program as an administrator. 
Client access ps script: Invoke-Command -ComputerName RemoteComputer -ScriptBlock {dir c:\}

From the Microsoft Press book Windows PowerShell 2.0 Administrator’s Pocket Consultant by William R. Stanek.

时间: 2024-10-07 06:00:08

Enable and Use Remote Commands in Windows PowerShell的相关文章

Windows Powershell 3 极速入门

Learn Windows PowerShell 3 in a Month of Lunches(2rd) 2013, DON JONES 这本书基于 PowerShell 3.0,做初学者教材甚好,若有 Linux shell 基础则可一目十行.如下便是摘录式笔记,仅记录一些感兴趣的重点,涉及大部分章节. 书中很少涉及语法,因为按作者的说法:操起命令直接上,这才是 PS 的主要使用模式(PowerShell-ish ways),而非一般的脚本编程,流控之类的语法都只是命令的粘合剂. 读完一遍,

Windows PowerShell 学习---第一章 PowerShell介绍

第1章 PowerShell介绍 1.1.什么是PowerShell 2006年,微软发布一款叫做Windows PowerShell的全新脚本语言. PowerShell与命令提示符shell一样,PowerShell可以进行交互性地输入命令.也可以很容易的使用管道和重定向将文件和程序串联起来. 不过,PowerShell确是一个强大的面向对象的语言,可以用于复杂的脚本编程. 1.2.面向对象的命令shell 关于cmd 如果在命令提示符下输入dir,dir命令将会在屏幕打印出目录中的文件名.

(2)Windows PowerShell使用

什么是PowerShell: Windows PowerShell 是一种命令行外壳程序和脚本环境,使命令行用户和脚本编写者可以利用 .NET Framework 的强大功能.PowerShell是命令提示符的更高级版本. 它用于执行诸如 ping 或 copy 之类的外部程序,并自动执行无法从 cmd.exe 访问的不同系统管理任务. PowerShell与cmd的区别: PowerShell与Bash Shell比较: 如何打开PowerShell: 在Windows下方的搜索处,直接搜索打

有奖试读—Windows PowerShell实战指南(第2版)

为什么要学PowerShell? Windows用户都已习惯于使用图形化界面去完成工作,因为GUI总能轻易地实现很多功能,并且不需要记住很多命令.使得短时间学会一种工具成为可能. 但是不幸的是,GUI并不能带来效率提升上的汇报,如果你花费5分钟在活动目录中创建一个新的用户(一般需要填写大量信息),之后再新建用户时,通常不会更快,那么新建100个新用户就会花费500分钟,通常没有任何办法使得我们输入信息以及单击操作更快,从而加快这个过程. 微软一直都有CMD命令来进行Windows的操作,但是很不

部署 Windows PowerShell Web 访问

部署 Windows PowerShell Web 访问 适用对象:Windows Server 2012, Windows Server 2012 R2 Windows PowerShell® Web Access 在 Windows Server® 2012 中首次引入,充当 Windows PowerShell 网关,可提供以远程计算机为目标的基于 Web 的 Windows PowerShell 控制台. 它可让 IT 专业人士在 Web 浏览器中运行来自 Windows PowerSh

在 Windows 7 和 Windows Server 2008 R2 上安装 Windows PowerShell 3.0

在 Windows 7 和 Windows Server 2008 R2 上安装 Windows PowerShell 3.0 Windows 7 和 Windows Server 2008 R2 内核版本同为6.1,以下步骤说明如何在运行 Windows 7 SP1 和 Windows Server 2008 R2 SP1 的机器上安装 Windows PowerShell 3.0. 安装准备 1. 在安装Windows Management Framework 3.0之前,卸载任何Windo

使用 Windows PowerShell 来管理和开发 windowsazure.cn 账户的特别注意事项

6月6日,微软面向中国大陆用户开放了Microsoft Azure公众预览版的申请界面.大家可以申请免费的 beta 试用,收到内附邀请码的通知邮件后只需输入激活码即可开始免费试用.具体网址为: http://windowsazure.cn/zh-cn/pricing/free-trial/ 在实际使用这个账号的时候,发现有一些地方需要特别注意. 在使用PowerShell工具中,需要下载发布配置文件(PublishSettingProfile),从而获得设置Windows PowerShell

Windows PowerShell 会话中使用 FSharp 代码编译器

<# $fSharpCode= @" moduleTest let HelloWorld = "Hello World!!!!" printfn "%s" HelloWorld let rec Loop n = seq [ if n <= 0 then () else yield n; yield! Loop (n-1) ] |> Seq.sort printfn "%A" (Loop 5) let rec facto

Office 365系列之九:使用Windows PowerShell管理O365平台

正如之前我们说的,通过O365管理中心.Exchange 管理中心.Lync管理中心SharePoint 管理中心能做的事情和能够实现的需求是远远满足不了客户的时间需求的.可以使用用于 Windows PowerShell 的 Azure Active Directory 模块 cmdlet 执行 Azure AD 管理任务.而且还可以做到使用单个 Windows PowerShell 窗口连接和同时管理 Office 365.SharePoint.Exchange 和 Lync 管理任务.接下