工作组环境下管理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等工具, ...
随机推荐
- 【Maven】Eclipse 使用Maven创建Java Web项目
创建环境 系统:win 10 软件:eclipse,maven 创建步骤 需求创建一个Servlet版本是3.0,Java版本是1.7的项目Maven web项目 使用eclipse工具创建maven ...
- 【kd-tree】bzoj2716 [Violet 3]天使玩偶
#include<cstdio> #include<cmath> #include<algorithm> using namespace std; #define ...
- CSS3 线性渐变(linear-gradient) 兼容IE8,IE9
一.线性渐变在 Mozilla 下的应用 语法: -moz-linear-gradient( [<point> || <angle>,]? <stop>, ...
- iOS9的一些问题
1.App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. ...
- 推荐一个C语言学习教程
Linux C编程一站式学习 http://learn.akae.cn/media/index.html
- JavaWeb学习总结(三)——Tomcat服务器学习和使用(二)
一.打包JavaWeb应用 在Java中,使用"jar"命令来对将JavaWeb应用打包成一个War包,jar命令的用法如下:
- How to Call SharePoint 2013 API Service to Query The Lists
How to Call SharePoint 2013 API In SharePoint 2013, we can query the list by it owner service, then ...
- 微信JSSDK多图片上传并且解决IOS系统上传一直加载的问题
微信多图片上传必须挨个上传,也就是不能并行,得串行: 那么我们可以定义一个如下所示的上传函数: var serverIds = []; function uploadImages(localImage ...
- Zynga 开源其服务器性能监控分析工具 zPerfmon
流年不利的社交游戏服务商Zynga近日在官方博客宣布开源zPerfmon——该工具负责监控Zynga数以千计的社交游戏服务器.zPerfmon的源代码目前已经上传至Github. 包括Facebook ...
- MVC路由探寻,涉及路由的惯例、自定义片段变量、约束、生成链接和URL等
引子 在了解MVC路由之前,必须了解的概念是"片段".片段是指除主机名和查询字符串以外的.以"/"分隔的各个部分.比如,在http://site.com/Hom ...