WMI的远程管理需要其计算机的本地管理员组权限,例:gwmi win32_computersystem -computer win08r2d

#在远程计算机上启动 notepad.exe 进程
invoke-wmimethod -path win32_process -name create -argumentlist notepad.exe -computername "win08r2d"

#停止 notepad.exe 进程
$np = get-wmiobject -query "select * from win32_process where name='notepad.exe'" -computername "win08r2d"
$np | remove-wmiobject

Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList "GPUPDATE /FORCE" -EnableAllPrivileges -ComputerName $RemoteComputer

==========================================

获取远程计算机上的服务
$server = gwmi win32_service -ComputerName win08r2d|?{$_.name -eq "dhcp"}

#查看服务当前运行状态
$server.state

#更改服务启动类型:
$server.ChangeStartMode("Automatic")  ,不可以为“Auto”
$server.ChangeStartMode("Manual")
$server.ChangeStartMode("Disabled")

返回值中 ReturnValue      : 0 表示成功

#启动/停止服务
$server.StopService()
$server.StartService()

服务启动类型如下:

Value Meaning
Boot

Device driver started by the operating system loader. This value is valid only for driver services.

System

Device driver started by the operating system initialization process. This value is valid only for driver services.

Automatic

Service to be started automatically by the Service Control Manager during system startup.

Manual

Service to be started by the Service Control Manager when a process calls theStartService method.

Disabled

Service that can no longer be started.

Return value

Return code Description
0

Success

1

Not Supported

2

Access Denied

3

Dependent Services Running

4

Invalid Service Control

5

Service Cannot Accept Control

6

Service Not Active

7

Service Request Timeout

8

Unknown Failure

9

Path Not Found

10

Service Already Running

11

Service Database Locked

12

Service Dependency Deleted

13

Service Dependency Failure

14

Service Disabled

15

Service Logon Failure

16

Service Marked For Deletion

17

Service No Thread

18

Status Circular Dependency

19

Status Duplicate Name

20

Status Invalid Name

21

Status Invalid Parameter

22

Status Invalid Service Account

23

Status Service Exists

24

Service Already Paused

远程计算机 进程/服务 启动停止(WMI)的更多相关文章

  1. python 远程调度进程服务与客户端

    python 远程调度进程服务与客户端 核心思想: 在本地或远程机器上创建一个进程,提供调度服务.使用了 APScheduler. 安装:APScheduler $ wget https://pypi ...

  2. Linux Oracle服务启动&停止脚本与开机自启动

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  3. Linux Oracle服务启动&停止脚本与开机自启动[转]

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  4. 【转】Linux Oracle服务启动&停止脚本与开机自启动

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设置相关参数,首先先介 ...

  5. (转)Linux Oracle服务启动&停止脚本与开机自启动

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  6. 在linux上oracle服务启动停止详细

    转至:https://www.cnblogs.com/baihuitestsoftware/articles/6365431.html 在CentOS 6.3下安装完Oracle 10g R2,重开机 ...

  7. Windows下使用service.bat安装tomcat服务, 启动停止tomcat服务

    在项目开发过程中,以前只是在Eclipse中配置.启动.停止tomcat服务器 如果只想在机器中使用tomcat服务器,而不想安装MyEclipse,可以使用service.bat 将tomcat安装 ...

  8. 【Linux】常用指令、ps查看进程、kill杀进程、启动停止tomcat命令、查看日志、查看端口、find查找文件

    1.说出 10 个 linux 常用的指令 1) ls 查看目录中的文件 2)cd /home 进入 '/ home' 目录:cd .. 返回上一级目录:cd ../.. 返回上两级目录 3)mkdi ...

  9. 使用shell脚本批处理控制大数据环境服务启动停止

    三台集群机器: master   192.168.168.200 slave1     192.168.168.201 slave2     192.168.168.202 1.start-maste ...

随机推荐

  1. antlr4 接触

    1. 配置IDE(可选) 2. 加减法示例 编写expr.g4 grammar AddMinus; expr: Minus Number #minusNum | expr op=('+'|'-') e ...

  2. 面试题-----求单链表的倒数第k个节点

    #include <iostream> using namespace std; struct node{ int value; struct node *next; }; struct ...

  3. C# WebBrowser设置代理

    WebBrowser控件是基于IE浏览器的,所以它的内核功能是依赖于IE. code: class IEProxy { //设置代理选项 private const int INTERNET_OPTI ...

  4. cordova打包APK,SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode ...

    javascript 严格模式 第一次接触let关键字,有一个要非常非常要注意的概念就是”javascript 严格模式”,比如下述的代码运行就会报错: let hello = 'hello worl ...

  5. Python__组合数据类型

    组合数据:集合类型.序列类型(元组类型.列表类型).字典类型 集合: 定义:集合是多个元素的无序组合.(无序,唯一,Python中要求放入集合中的数据类型是不可变的). 集合用大括号 {}表示,元素间 ...

  6. C# 数据库增加新表怎么更新ef

    找到dbmx文件,打开,右键,更新模型 也可以 右键从模型中删除 重新更新过来,感觉说了句废话 哈哈

  7. C# 实现二叉树各种排序

    1. 引言 在实际的项目中,树还是用的比较多的一种,尤其是对于具有层次结构的数据.相信很多人都学过树的遍历,比如先序遍历,后序遍历等,利用递归还是很容易理解的. 今天给大家介绍下二叉树的几种遍历算法, ...

  8. C# 学习笔记(二) 时间格式化字符串

    1. 以下4种时间格式化符号输出的固定时间格式在各个区域设置中都应是相同的: 标准格式字符串 由 DateTimeFormatInfo.InvariantInfo 属性定义 自定义格式字符串 “O”或 ...

  9. HTML杂项和HTML废弃标签

    一.HTML杂项 1.HTML注释  <!-- 里边放要注释的文字 --> 1)html的注释是为了方便后期的维护,方便后期更改时能够快速的定位到所需更改的部分 2)html的注释在页面的 ...

  10. mysql数据库定时任务

    应用系统运行中,经常需要定时执行一些任务,例如:定时更新汇总数据,定时更新状态数据等,目前 Treesoft数据库管理系统 增加[定时任务]功能,直接通过页面简单配置,即可按调度规则定时执行SQL任务 ...