- 浏览: 100934 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (209)
- http://docs.jpush.io/server/java_sdk/ (1)
- SpingMVC ModelAndView (1)
- Model (1)
- Control以及参数传递 (1)
- https://www.alipay.com/ (1)
- 检查指定的字符串列表是否不为空。 (1)
- 转自http://my.oschina.net/rpgmakervx/blog/505434 (1)
- 压缩js (1)
- 含包含 字母数字校验 (1)
- 判断浏览器是ie (1)
- fixbox (0)
- 转自http://www.cnblogs.com/lanzi/archive/2010/10/26/1861338.html (1)
- http://dl2.iteye.com/upload/attachment/0113/2406/afbd8d53-dcad-3afc-8d78-41c1591 (0)
- IDEA (0)
- maven搭建 (0)
- http://www.jeasyuicn.com/api/docTtml/index.htm (1)
- 给tomcat添加运行内存: (1)
- JPUSH推送 (1)
- requestScope (0)
- oracle中plsql安装client10连接数据库 (1)
- 不需要安装oracle11g (1)
- tuikuan (1)
- http://www.hjxmall.com/index.php (1)
- java (1)
- 参考 (1)
- xml签名验签模拟程序 (1)
- 技术网站收集分享 (1)
- Java NIO提供了与标准IO不同的IO工作方式 ------来源于 http://www.iteye.com/magazines/132-Java-NIO (1)
- oracle表查询语句优化 (0)
- oracle (5)
- a (1)
- TenpayHttpClient (2)
- mongodb (1)
- http://www.qcloud.com/product/cmongo.html?utm_source=pcsem1&utm_medium=bdgj46&utm_campaign=baidu (1)
- SpringMVC整合MongoDB开发 (0)
- SpringMVC整合MongoDB开发 https://www.mongodb.org (1)
- Java 语言中常见问题总结 (1)
- 数据库SQL优化大总结 (1)
- 拦截器与过滤器的区别 (1)
- Struts2中拦截器与过滤器的区别及执行顺序 (1)
- Spring声明式事务管理与配置 (0)
- oracle OPERTION (1)
- java 高并发多线程开发 (1)
- Collection 与 map 接口相关集合 (1)
- 多线程开发实践 (1)
- JVM调优总结 转自 http://www.importnew.com/18694.html (1)
- redis 五种数据类型的使用场景 转自于 http://blog.csdn.net/gaogaoshan/article/details/41039581 (1)
- HttpWatch http基础 来自于http://blog.csdn.net/gaogaoshan/article/details/21237555 (1)
- maven 远程仓库 http://blog.csdn.net/gaogaoshan/article/details/40266779 (1)
- 生成Webservice客户端的4中方法 http://blog.csdn.net/gaogaoshan/article/details/8980775 (1)
- http://fgh2011.iteye.com/blog/1564283 (1)
- sleep和wait有什么区别 http://xiaowei2002.iteye.com/blog/2174188 (1)
- JDK中常用包及其类 常见的几种RuntimeException (1)
- Java的运行原理 (1)
- mybatis缓存的使用及理解 http://my.oschina.net/dxqr/blog/123163 (1)
- 软件架构设计分析 (1)
- redis技术总结 (3)
- java面试总结知识点 (1)
- ZooKeeper技术 (1)
- Hadoop (1)
- sso单点登录 (1)
- SpringIOC (1)
- 书签ssssssssssssssssssssss (1)
- spring事务的隔离级别 http://www.cnblogs.com/yangy608/archive/2011/06/29/2093478.html (1)
- 秒杀系统架构分析与实战 http://www.importnew.com/18920.html (1)
- oracle 连接plsql配置 (1)
- maven工程集成springmvc http://blog.csdn.net/fox_lht/article/details/16952683 (1)
- java类序列化与反序列化版本唯一号serialVersionUID (1)
- spring注解用法总结 (1)
- eclipse导入maven项目找不到资源文件方法 (1)
- dubbo (0)
- socket 网络编程 服务器与客户端 编程 (1)
- Thread与Runnable实现线程利用线程插队实现求和操作 (1)
- 生产者与消费者模式 (1)
- JAXB注解 java 关于xml的注解,自动生成xml文件 - @XML*** (1)
- xml 与JAVAbean转换 (1)
- MAP (2)
- decimalToString (1)
- 反编译插件 (0)
- 反编译插件 https://sourceforge.net/projects/jadclipse/?source=typ_redirect (1)
- AWX (1)
- 官网地址Dinp (1)
- public interface ExecutorService extends Executor (1)
- MAIN (1)
- 转自于 http://blog.csdn.net/lufeng20/article/details/24314381 (1)
- JaxbUtil (1)
- HttpXmlClient (0)
- Http post 请求 (1)
- URLDecoder (1)
- spdb (0)
- 订单号生成规则 (1)
- 距离0点毫秒数 (1)
- MyBatis存储过程调用java (1)
- Banks (1)
- 学习网址 (1)
- hots配置oracle数据库配置修改 (1)
- 支付宝文档 (1)
- Jadclipse (1)
- filter (0)
- Filter过滤器 (1)
- 工具类 fixbox (1)
- java quartz (0)
- java quartz 实现定时任务,每个礼拜一到礼拜五定时执行 (1)
- Thread (4)
- getResourceAsStream (1)
- BigData (1)
- 开源架构 (17)
- 架构 (0)
- 文件操作 (2)
- tools (20)
- 测试工具 (1)
- vm (1)
- mq (1)
- blog (1)
- 开源架构搭建技术 (6)
- JAVA细节技术点总结 (1)
- 优化技术 (1)
- LINUX命令使用 (1)
- spring (2)
- 大数据 (1)
- struts2 (1)
- python (1)
- pay (1)
- linux (1)
- 压力测试 (1)
- 代码检查插件 (1)
- 游戏端开发 (1)
- 微信开发相关 (1)
- 搜索引擎 (1)
- 网络技术 (1)
- 分布式部署 (1)
- 堆栈信息 (1)
最新评论
https://github.com/profesorfalken/jPowerShell
Installation
To install jPowerShell you can add the dependecy to your software project management tool: http://mvnrepository.com/artifact/com.profesorfalken/jPowerShell/1.7
For example, for Maven you have just to add to your pom.xml:
maven工程依赖导入第三方jar
<dependency>
<groupId>com.profesorfalken</groupId>
<artifactId>jPowerShell</artifactId>
<version>1.7</version>
</dependency>
Instead, you can direct download the JAR file and add it to your classpath. https://repo1.maven.org/maven2/com/profesorfalken/jPowerShell/1.7/jPowerShell-1.7.jar
Basic Usage
The best way to document is providing a good example:
Single command execution
//Execute a command in PowerShell session
PowerShellResponse response = PowerShell.executeSingleCommand("Get-Process");
//Print results
System.out.println("List Processes:" + response.getCommandOutput());
Executing one or multiple commands using the same PowerShell session
PowerShell powerShell = null;
try {
//Creates PowerShell session (we can execute several commands in the same session)
powerShell = PowerShell.openSession();
//Execute a command in PowerShell session
PowerShellResponse response = powerShell.executeCommand("Get-Process");
//Print results
System.out.println("List Processes:" + response.getCommandOutput());
//Execute another command in the same PowerShell session
response = powerShell.executeCommand("Get-WmiObject Win32_BIOS");
//Print results
System.out.println("BIOS information:" + response.getCommandOutput());
} catch(PowerShellNotAvailableException ex) {
//Handle error when PowerShell is not available in the system
//Maybe try in another way?
} finally {
//Always close PowerShell session to free resources.
if (powerShell != null)
powerShell.close();
}
Configure jPowerShell Session
We can easily configure the jPowerShell session:
By project creating a jpowershell.properties file in the classpath of your project and settings the variables you want to override.
By call, using a map that can be chained to powershell call.
For example:
//Set the timeout when waiting for command to terminate to 30 seconds instead of 10 (default)
Map<String, String> myConfig = new HashMap<>();
myConfig.put("maxWait", "30000");
response = powerShell.configure(myConfig).executeCommand("Get-WmiObject Win32_BIOS");
The three variables that can be configured in jPowerShell are:
maxThreads: the maximum number of thread to use in pool. 3 is an optimal and default value
waitPause: the pause in ms between each loop pooling for a response. Default value is 10
maxWait: the maximum wait in ms for the command to execute. Default value is 10000
remoteMode: it should be true when we are executing a command in remote. Otherwise the execution will finish in timeout.
Executing PowerShell Script
In order to execute a PowerShell Script it is recommended to use the executeScript() method instead of executeCommand():
PowerShellResponse response = null;
try {
//Creates PowerShell session
PowerShell powerShell = PowerShell.openSession();
//Increase timeout to give enough time to the script to finish
Map<String, String> config = new HashMap<String, String>();
config.put("maxWait", "80000");
//Execute script
response = powerShell.configuration(config).executeScript("./myPath/MyScript.ps1");
//Print results if the script
System.out.println("Script output:" + response.getCommandOutput());
} catch(PowerShellNotAvailableException ex) {
//Handle error when PowerShell is not available in the system
//Maybe try in another way?
} finally {
//Always close PowerShell session to free resources.
if (powerShell != null)
powerShell.close();
}
PowerShell 打开一个Session会话,一个会话对象可以执行多个脚本命令,站点验证连通性的办法,直接执行SCMMServer 判断返回的IsConnect是否为True
获取VM,获取Hosts,GetCluster ,GetNetWork
Installation
To install jPowerShell you can add the dependecy to your software project management tool: http://mvnrepository.com/artifact/com.profesorfalken/jPowerShell/1.7
For example, for Maven you have just to add to your pom.xml:
maven工程依赖导入第三方jar
<dependency>
<groupId>com.profesorfalken</groupId>
<artifactId>jPowerShell</artifactId>
<version>1.7</version>
</dependency>
Instead, you can direct download the JAR file and add it to your classpath. https://repo1.maven.org/maven2/com/profesorfalken/jPowerShell/1.7/jPowerShell-1.7.jar
Basic Usage
The best way to document is providing a good example:
Single command execution
//Execute a command in PowerShell session
PowerShellResponse response = PowerShell.executeSingleCommand("Get-Process");
//Print results
System.out.println("List Processes:" + response.getCommandOutput());
Executing one or multiple commands using the same PowerShell session
PowerShell powerShell = null;
try {
//Creates PowerShell session (we can execute several commands in the same session)
powerShell = PowerShell.openSession();
//Execute a command in PowerShell session
PowerShellResponse response = powerShell.executeCommand("Get-Process");
//Print results
System.out.println("List Processes:" + response.getCommandOutput());
//Execute another command in the same PowerShell session
response = powerShell.executeCommand("Get-WmiObject Win32_BIOS");
//Print results
System.out.println("BIOS information:" + response.getCommandOutput());
} catch(PowerShellNotAvailableException ex) {
//Handle error when PowerShell is not available in the system
//Maybe try in another way?
} finally {
//Always close PowerShell session to free resources.
if (powerShell != null)
powerShell.close();
}
Configure jPowerShell Session
We can easily configure the jPowerShell session:
By project creating a jpowershell.properties file in the classpath of your project and settings the variables you want to override.
By call, using a map that can be chained to powershell call.
For example:
//Set the timeout when waiting for command to terminate to 30 seconds instead of 10 (default)
Map<String, String> myConfig = new HashMap<>();
myConfig.put("maxWait", "30000");
response = powerShell.configure(myConfig).executeCommand("Get-WmiObject Win32_BIOS");
The three variables that can be configured in jPowerShell are:
maxThreads: the maximum number of thread to use in pool. 3 is an optimal and default value
waitPause: the pause in ms between each loop pooling for a response. Default value is 10
maxWait: the maximum wait in ms for the command to execute. Default value is 10000
remoteMode: it should be true when we are executing a command in remote. Otherwise the execution will finish in timeout.
Executing PowerShell Script
In order to execute a PowerShell Script it is recommended to use the executeScript() method instead of executeCommand():
PowerShellResponse response = null;
try {
//Creates PowerShell session
PowerShell powerShell = PowerShell.openSession();
//Increase timeout to give enough time to the script to finish
Map<String, String> config = new HashMap<String, String>();
config.put("maxWait", "80000");
//Execute script
response = powerShell.configuration(config).executeScript("./myPath/MyScript.ps1");
//Print results if the script
System.out.println("Script output:" + response.getCommandOutput());
} catch(PowerShellNotAvailableException ex) {
//Handle error when PowerShell is not available in the system
//Maybe try in another way?
} finally {
//Always close PowerShell session to free resources.
if (powerShell != null)
powerShell.close();
}
PowerShell 打开一个Session会话,一个会话对象可以执行多个脚本命令,站点验证连通性的办法,直接执行SCMMServer 判断返回的IsConnect是否为True
获取VM,获取Hosts,GetCluster ,GetNetWork
- jPowerShell-master.zip (21.7 KB)
- 下载次数: 0
- jProcesses-master.zip (35.4 KB)
- 下载次数: 0
发表评论
-
ovirt rhev 虚拟机创建,迁移,存储,网络
2017-03-10 21:58 1018ovirt虚拟机存储位置迁移有两种方法: 1.通过导入导出域 ... -
https://github.com/TANGYANGBING
2017-03-04 18:42 1048https://github.com/TANGYANGBING ... -
Eclipse-findbugs
2017-01-17 22:18 311https://sourceforge.net/project ... -
springcloud 开源技术
2017-01-05 22:51 302http://docs.springcloud.cn/ htt ... -
大数数据技术
2016-12-11 13:38 389数字存在文件系统spark ,storm, hadoop hb ... -
mybatis 批量插入的两种方式
2016-09-10 15:54 1100一、mybiats foreach标签 fo ... -
angularjs与requirejs整合
2016-09-10 15:46 573摘要 angularjs与requirejs整合,AMD/CM ... -
RabbitMQ spring 使用总结
2016-09-10 15:37 996rabbitMQ相关概念不在本文介绍范围,rabbitMQ官 ... -
工具网址
2016-09-06 22:24 344http://git.oschina.net/dwzteam/ ... -
angular.js
2016-07-21 22:33 314http://docs.ngnice.com/guide A ... -
eureka---开 始就被设计成高可用与可伸缩的Service发现服务,这两个特点也是Netflix公司开发所有平台的两个特色
2016-07-18 20:42 1115(注:Eureka由两个组件组成:Eureka服务器和Eure ... -
Spring Boot
2016-07-14 21:56 417Spring Boot 项目旨在简化创建产品级的 Spring ... -
分布式发布订阅消息系统 Kafka
2016-07-14 21:06 400kafka是一种高吞吐量的分布式发布订阅消息系统,她有如下特性 ... -
OpenTSDB logo 开源监控系统 OpenTSDB
2016-07-14 20:49 408开源监控系统OpenTSDB,用hbase存储所有的时序(无须 ... -
zabbix logo 分布式系统监视 zabbix
2016-07-13 22:11 501zabbix能监视各种网络参数,保证服务器系统的安全运营;并提 ... -
dubbo
2016-05-04 08:58 308http://doc.okbase.net/congcong6 ...
相关推荐
本文将详细介绍PowerShell脚本在Windows系统管理中的作用,包括其基本语法、核心概念、实际应用案例,以及如何编写和执行PowerShell脚本。 PowerShell脚本是Windows系统管理的得力助手。通过自动化日常的系统管理...
在IT行业中,有时我们需要将PowerShell脚本转换为可执行(EXE)文件,以便于在没有PowerShell环境或者需要更安全分发的环境中运行。标题和描述中提到的"powershell脚本转exe文件"就是这个过程。下面将详细解释如何...
【Python-PowerLessShell依赖MSBuildexe来远程执行PowerShell脚本和命令不需要调用powershellexe】 在IT行业中,Python是一种广泛使用的编程语言,因其简洁、易读的语法和丰富的库支持而受到青睐。当涉及到系统管理...
中文版本精通windows powershell 脚本编程 的随书配套的脚本资源,原资源出版社无法下载了。所以找了半天,然后下载以后发现安装文件在WIN7无法安装就找到了其他机器安装然后直接提取了其中的脚本资源 所以现在无需...
PowerShell脚本是使用PowerShell语言编写的可执行程序,它们在Windows环境中提供了一种灵活且强大的自动化方式。 PowerShell脚本是Windows自动化的强大工具,它通过提供对系统管理任务的深入控制,极大地提高了IT...
Windows PowerShell™ 是专为系统管理员设计的新 Windows 命令行外壳程序。该外壳程序包括交互式提示和脚本环境,两者既可以独立使用也可以组合使用。 本文档介绍了 Windows PowerShell 的基本概念和功能,并提供了...
PowerShell因为在此系统中禁止执行脚本的解决方法 //www.jb51.net/article/95022.htm Powershell 脚本数字签名实现方法 您可能感兴趣的文章:Powershell 脚本数字签名实现方法史上最全的Android build.gradle配置...
Java 是一种跨平台的编程语言,而 PowerShell 是微软开发的一种命令行脚本环境,尤其适合管理系统资源。在这个场景下,我们可以利用 Java 编写的程序来调用 PowerShell 命令,实现对 Windows 的各种操作。 首先,让...
2022中职网络搭建windows powershell脚本创建题答案,需要在poweshell上运行,视频有完整演示过程
然而,在Windows环境中,Powershell作为默认的命令行工具,有时更适用于执行系统级别的任务。`ps1scriptify`是一个实用的工具,它允许开发者将Python脚本转换为等效的Powershell(`.ps1`)脚本,从而在Powershell...
《精通windows powershell 脚本编程》脚本资源安装文件,运行该程序可以将书上的样例脚本文件安装到本地硬盘的一个文件夹里边。
标题中的“dotnet-将一个PowerShell脚本嵌入到PNG文件的像素中并生成一个oneliner来执行”是一个高级技巧,它涉及到.NET开发、PowerShell编程以及数据隐藏技术。这种技术通常用于隐蔽通信或者在限制环境中执行代码,...
win系统自带游戏删除powershell脚本
PowerShell是一种命令行shell和脚本语言,由Microsoft开发,旨在增强系统管理员对操作系统及应用程序的管理能力。本文将深入探讨如何在C#中调用PowerShell以及执行PowerShell命令。 首先,要从C#代码中调用...
在"批量执行SQL脚本工具-PowerShell.7z"这个压缩包中,包含了适用于Windows 2012和Windows 2016操作系统的PowerShell脚本,旨在帮助用户批量处理SQL Server中的SQL脚本执行。以下是这个工具的主要知识点: 1. **...
2. **PowerShell脚本**:用于在Exchange环境中创建邮箱的PowerShell脚本。 3. **配置文件**:可能包含连接信息,如Exchange服务器的地址、认证凭据等。 4. **文档**:说明如何使用这些代码,可能包括安装步骤、配置...
有用的PowerShell脚本,用于配置基本的Windows Server2016。此存储库的目的是具有一些可以用来设置自己的服务器的有效配置。 如果发现任何错误,可以随意将代码用于自己的目的,并为该存储库做出贡献。 支持的角色...