工作组环境下管理windows.
此处指的是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.的更多相关文章
- Vmware ESX5i 环境下部署Windows Storage Server 2008 R2
ESX5i 环境下部署Windows Storage Server 2008 R2 Windows Storage Server 2008 这款产品微软早已发布,WSS2008是基于Win ...
- 【OGG】 RAC环境下管理OGG的高可用 (五)
[OGG] RAC环境下管理OGG的高可用 (五) 一.1 BLOG文档结构图 一.2 前言部分 一.2.1 导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道 ...
- 在虚拟机linux环境下编译windows版adb fastboot
原文出自:http://blog.chinaunix.net/uid-20546441-id-1746200.html 我根据虚拟机编译遇到的问题进行一些添加 [前提条件] Linux Android ...
- VS IDE环境下,windows GUI(Qt MFC,win32)使用控制台实时打印调试信息
在工程属性的页面下,点击Build Events,在Build Events下点击Post-Build Event. 然后再Command Line里面输入以下命令: editbin /SUBSYST ...
- MingW环境下的windows编程
一般在进行windows编程时都使用vc++精简版,其插入菜单,图片等资源等更简单,且vc中对中文有更好的支持,win7下安装的Mingw中文并不能很好地显示,有光标显示的位置和光标实际位置不符的问题 ...
- C#环境下使用Windows消息传递字符串数据的研究
前言: 日前,师兄交给了我一个课题,将一个后台运行的Console程序,修改为WindowsForm程序,并在其界面上增加配置设置,以及运行记录。 原来的Console程序,后台运行的流程在其中一个类 ...
- 今天在在linux环境下 管理自己的php项目时 删除一个分类 结果报了一个Table表名 doesn’t exist
在百度上查了 一下 发现是是大小写的问题 在此分享一下
- 关于在phpStudy环境下,windows cmd中 php不是内部命令问题
首先查看system32是否加入系统变量 其次要把当前运行的php版本的路径加入到系统变量中去,path中, 一定要是这个样子的: D:\phpStudy\php\php-5.6.27-nts 不然没 ...
- 记一次虚拟化环境下Windows IO性能的解析
前言随着云计算技术与服务的发展和进步,越来越多的客户选择将业务部署到云端.但由于引入了虚拟化层,在业务部署过程中经常会遇到IO问题,通常也不易调试.本文主要介绍利用perf.systemtap等工具, ...
随机推荐
- mysql 统计
每周: select count(*) as cnt,week(editdate) as weekflg from projects where year(editdate)=2007 group b ...
- servers中添加server时,看不到运行环境的选择。
servers中添加server时,看不到运行环境的选择. 主要原因是tomcat目录中的配置文件格式不对.
- 1034. Head of a Gang (30)
分析: 考察并查集,注意中间合并时的时间的合并和人数的合并. #include <iostream> #include <stdio.h> #include <algor ...
- CCF 201612-1 最大波动 (水题)
问题描述 小明正在利用股票的波动程度来研究股票.小明拿到了一只股票每天收盘时的价格,他想知道,这只股票连续几天的最大波动值是多少,即在这几天中某天收盘价格与前一天收盘价格之差的绝对值最大是多少. 输入 ...
- 第二章——建立一个HelloWorld项目,练习使用git的add/commit/push/pull/fetch/clone等基本命令。比较项目的新旧版本的差别-----答题者:徐潇瑞
1.首先下载安装git,很简单所以就不详细说了,当弹出一个类似的命令窗口的东西,就说明Git安装成功 2.因为Git是分布式版本控制系统,所以需要填写用户名和邮箱作为一个标识 3.接着,注册githu ...
- radio button(单选按钮)
单选按钮只是input输入框的一种类型. 每一个单选按钮都应该嵌套在它自己的label(标签)元素中. 注意:所有关联的单选按钮应该使用相同的name属性. 下面是一个单选按钮的例子: <lab ...
- Linux内核分析之扒开系统调用的三层皮(上)
一.原理总结 本周老师讲的内容主要包括三个方面,用户态.内核态和中断,系统调用概述,以及使用库函数API获取系统当前时间.系统调用是操作系统为用户态进程与硬件设备进行交互提供的一组接口,也是一种特殊的 ...
- How to do logging in C# with log4net
If you are writing server code in C# or to a lesser extent desktop/client then it's a good idea to i ...
- 作业,备份,存储过程,sqlserver print 语句,输出字符串
declare @filename nvarchar(100) set @filename='H:/backOrder/'+ convert(varchar(50),getdate(),112)+ l ...
- .NET Socket TCP 50W在线连接交互测试
在平常的交流中经常有人问.net socket能支持多少在线?和C++或linux下比起来应该差很远吧?其实产生这样问题的主要原因是.net很少人去做这方面的测试,而在linux下则经常听到什么100 ...