此处指的是windows7

1.防火墙设置

开启wmi,remote admin,防火墙远程管理

可以使用命令行

netsh advfirewall export "C:\temp\WFconfiguration.wfw"
     netsh advfirewall import "C:\temp\WFconfiguration.wfw" 

2.修改Powershell执行策略

Set-ExecutionPolicy RemoteSigned
可以用脚本从批处理调用,参考http://stackoverflow.com/questions/932291/calling-powershell-cmdlets-from-windows-batch-file
http://www.computerperformance.co.uk/powershell/powershell_cmdlet.htm

Starting with Powershell version 2, you can run a Powershell script like so...

powershell -ExecutionPolicy RemoteSigned -File "C:\Path\Script.ps1" "Parameter with spaces" Parameter

3.安装powershell3.0

查看版本办法
PS下$host
或则

$psvertiontable

检查winrm版本

winrm id

4.在提权的命令行下建立管理员账号,加入管理员组

net user test * /add /comment:"test user" /expires:never /fullname:"xx”

net localgroup administrators test /add

查看用户和组,net user test

net localgroup administrators

5.命名网卡连接LAN0,LAN1,LAN-free,设置网络环境为专用网络

6.配置winRM

前提:提权的command下运行

被管理端:

winrm quickconfig

远程执行指令的两种方式

winrm –r:computername command

icm hostname {powershell-command}

icm是Invoke-Command的简写

client(发起访问的一方)配置(不在powershell下):
6.1 WinRM quickconfig  //配置winrm服务,防火墙例外设置,启动winrm listener
6.2 winrm set winrm/config/client @{TrustedHosts=”remote-computer-name”} //设置信任的客户端
(另一种方式

# Enabled Trusted Hosts for Universial Access

cd wsman:

cd localhost\client

Set-Item TrustedHosts * -force

restart-Service winrm

)
6.3 确定winrm在运行:get-service winrm
6.4 enable-psremoting –force (不确定是否要执行,应该是在被管理端执行)
参见:http://tech.ccidnet.com/art/302/20100701/2102911_1.html
http://technet.microsoft.com/en-us/library/hh849694.aspx

当执行该cmdlet时执行了以下操作,其中包括:

1. 启动或重新启动(如果已启动) WinRM 服务。

2. 将 WinRM 服务类型设置为自动启动。

3. 在本地计算机上创建一个侦听器以接受任意 IP 地址上的请求。

4. 对 WS-Management 流量启用防火墙例外(仅适用于 http),如果要启用PS远程管理,此时网络位置不能被设置为public,因为Windows 防火墙例外不能在网络位置是public时被启用。

5.启用所有注册的PS线程配置信息。

The Enable-PSRemoting cmdlet performs the following operations:

-- Runs the Set-WSManQuickConfig cmdlet, which performs the following tasks:

----- Starts the WinRM service.

----- Sets the startup type on the WinRM service to Automatic.

----- Creates a listener to accept requests on any IP address.

----- Enables a firewall exception for WS-Management communications.

----- Registers the Microsoft.PowerShell and Microsoft.PowerShell.Workflow session configurations, if it they are not already registered.

----- Registers the Microsoft.PowerShell32 session configuration on 64-bit computers, if it is not already registered.

----- Enables all session configurations.

----- Changes the security descriptor of all session configurations to allow remote access.

----- Restarts the WinRM service to make the preceding changes effective.

默认情况下,PowerShell远程管理使用5985(http)和5986(https)端口

当给Enable-PSRemoting cmdlet增加-force参数后执行将会在静默状态下启用远程管理,PowerShell远程管理是不能通过远程启用的。

如果远程管理被启用了,可以使用下面的cmdlet查看:

PS C:\ > Enter-PSSession –ComputerName localhost

用户将会看到如下图2所示的提示符:

6.5 winrs -r:Remote-computer-name whoami  //测试winrm连接,此处用whoami直接用本机用户名
winrs -r:Remote-computer-name ipconfig //在远程被管理端测试ipconfig
进入Powershell,
6.6 Get-Process | Sort-Object -Property CPU -Descending | Select -First 10 //本机的前10个进程
icm Remote-computer-name {Get-Process | Sort-Object -Property CPU -Descending | Select -First 10} //被管理的远端主机的前10个进程
一对多管理:

Invoke-Command -ComputerName WinServ-wfe, SQL-Server2008 -ScriptBlock {Get-Process}

Invoke-Command -ComputerName (get-content c:\scripts\servers.txt) -ScriptBlock {Get-Process}

这种方式也被称之为散开式或一对多远程管理。用户能用一条命令在多台主机上执行相同的命令。

脚本块中所有的命令和变量均会在远程计算机上运行。如果用户采用类似于-ScriptBlock {Get-Process –Name $procName},PowerShell认为远程计算机线程中$procName变量已经定义过了。用户能通过使用Invoke-Command命令,将本地计算机上的变量传递到远程线程。

2.2 传递变量到远程线程

前面的例子中,用户可以传递要寻找的进程名作为变量。ArgumentList参数能帮助用户传递到远程线程中:

$procName = "powershell"

Invoke-Command -ComputerName (get-content c:\scripts\servers.txt) ` -ScriptBlock {param ($Name) Get-Process -Name $Name} –ArgumentList $procName

上面的例子中可以显示如何使用-ArgumentList参数传递本地变量到远程线程。

工作组环境下管理windows.的更多相关文章

  1. Vmware ESX5i 环境下部署Windows Storage Server 2008 R2

    ESX5i 环境下部署Windows Storage Server 2008 R2       Windows Storage Server 2008 这款产品微软早已发布,WSS2008是基于Win ...

  2. 【OGG】 RAC环境下管理OGG的高可用 (五)

    [OGG] RAC环境下管理OGG的高可用 (五) 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道 ...

  3. 在虚拟机linux环境下编译windows版adb fastboot

    原文出自:http://blog.chinaunix.net/uid-20546441-id-1746200.html 我根据虚拟机编译遇到的问题进行一些添加 [前提条件] Linux Android ...

  4. VS IDE环境下,windows GUI(Qt MFC,win32)使用控制台实时打印调试信息

    在工程属性的页面下,点击Build Events,在Build Events下点击Post-Build Event. 然后再Command Line里面输入以下命令: editbin /SUBSYST ...

  5. MingW环境下的windows编程

    一般在进行windows编程时都使用vc++精简版,其插入菜单,图片等资源等更简单,且vc中对中文有更好的支持,win7下安装的Mingw中文并不能很好地显示,有光标显示的位置和光标实际位置不符的问题 ...

  6. C#环境下使用Windows消息传递字符串数据的研究

    前言: 日前,师兄交给了我一个课题,将一个后台运行的Console程序,修改为WindowsForm程序,并在其界面上增加配置设置,以及运行记录。 原来的Console程序,后台运行的流程在其中一个类 ...

  7. 今天在在linux环境下 管理自己的php项目时 删除一个分类 结果报了一个Table表名 doesn’t exist

    在百度上查了 一下  发现是是大小写的问题  在此分享一下

  8. 关于在phpStudy环境下,windows cmd中 php不是内部命令问题

    首先查看system32是否加入系统变量 其次要把当前运行的php版本的路径加入到系统变量中去,path中, 一定要是这个样子的: D:\phpStudy\php\php-5.6.27-nts 不然没 ...

  9. 记一次虚拟化环境下Windows IO性能的解析

    前言随着云计算技术与服务的发展和进步,越来越多的客户选择将业务部署到云端.但由于引入了虚拟化层,在业务部署过程中经常会遇到IO问题,通常也不易调试.本文主要介绍利用perf.systemtap等工具, ...

随机推荐

  1. springMVC验证码程序

    原文地址:http://my.oschina.net/u/1757031/blog/488322 import java.awt.Color; import java.awt.Font; import ...

  2. 有关eclipse连接SQL Server 2008的问题

    1.首先,提供一个链接http://blog.163.com/jackie_howe/blog/static/19949134720122261121214/ 这个链接有详细更改SQL Server ...

  3. asp.net 文件批量移动重命名

    最近闲时写了个批量移动重命名文件的工具 点击下载工具

  4. cocos2dx release note

    [传送门] 发布说明: https://github.com/fusijie/Cocos2dx-ReleaseNote-zh/blob/master/SUMMARY.md 更新记录: https:// ...

  5. checkboxes(复选按钮)

    复选按钮是input的输入框的另一种类型. 每一个复选按钮都应该嵌套进label元素中. 所有关联的复选按钮应该具有相同的name属性. 下面是复选按钮的例子: <label><in ...

  6. 融云官方cordova示例使用指南

    最近公司要在App里加IM功能,用融云IM.于是下载其cordova版示例:https://github.com/rongcloud/cordova-plugin-rongcloud-im-demo ...

  7. 6.3 Android Framework

    Android的四层架构分别为Linux2.6内核层,核心库层,应用框架层,应用层.Framework层为我们开发应用程序提供了非常多的API,满足我们业务上的需求.(Android是基于Linux内 ...

  8. centos下网络配置方法(网关、dns、ip地址配置)

    本文介绍了centos网络配置的方法,centos网络配置主要包括dns.网关.IP地址: 1.IP地址配置: /etc/sysconfig/network-scripts/ifcfg-eth0 2. ...

  9. SQL Server 利用锁提示优化Row_number()-程序员需知

    网站中一些老页面仍采用Row_number类似的开窗函数进行分页处理,此时如果遭遇挖坟帖的情形可能就需要漫长的等待且消耗巨大.这里给大家介绍根据Row_number()特性采用特定锁Hint提升查询速 ...

  10. WinDbg 命令三部曲:(三)WinDbg SOSEX 扩展命令手册

    本文为 Dennis Gao 原创技术文章,发表于博客园博客,未经作者本人允许禁止任何形式的转载. 系列博文 <WinDbg 命令三部曲:(一)WinDbg 命令手册> <WinDb ...