尽解powershell的workflow
-------1【简介】---------
Microsoft .NET Framework 4.0 发布于2010年4月左右。
.net4 的新特性,是并行多任务机制。.net4 workflow(WF),翻译为工作流,它依赖并行多任务机制,并成为其延伸。(也有说法说WF在.net3中就有)
powershell workflow中,并行语句产生的,每个并行任务,都会产生一个powershell。exe进程。是并发【多进程】!任务。
它弥补了powershell v2.0原先只有多线程(*-job命令)的不足。
--------2【浅谈多线程,多进程脚本的区别】---------
bat,bash中没有多线程。powershell只有一个前台线程,无数个后台线程。
但有了隔离,脚本代码跑的会更健壮。坏了就杀掉,不影响其他脚本。
powershell 传教士 原创文章 允许转载,但必须保留名字和出处,否则追究法律责任。2014-03-29写,2019-09-18改,
--------3 【workflow的原理和使用场景】---------
假如说你有200个任务,并限定200个进程并发。
1workflow会先启动这200个powershell.exe,也就是400秒内,光吃cpu,内存了,没运行任务。
--------4 【workflow数据的输出】---------
http://bbs.chinaunix.net/thread-4314470-1-1.html
https://pan.baidu.com/s/16deKKe3ZnCg809lffiVZWg
比如,用一个脚本,写入数据库。等workflow执行完毕后,在任务脚本最后一行,调用另一个脚本,读取数据库,写入txt。
--------5 【powershell workflow最大进程数设置】---------
cpu密集型任务,应该根据cpu核心设定,比如有16核心,则开15,或16个进程。
io密集型任务,可以开100,200,这样。
Enable-PSRemoting -SkipNetworkProfileCheck -Force
Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP-NoScope" -RemoteAddress Any
Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP" -RemoteAddress Any
Set-Item WSMan:\localhost\Client\TrustedHosts -Value '*'
$我的工作流参数 = New-PSWorkflowExecutionOption -MaxActivityProcesses 200
Register-PSSessionConfiguration -Name '我的工作流配置' -SessionTypeOption $我的工作流参数 -SessionType Workflow -Force
(Get-PSSessionConfiguration -Name '我的工作流配置' ).maxactivityprocesses
restart-service -Name WinRM -Force
--------6 【workflow脚本例子】---------
$我的workflow代码 = {
workflow bingfa3
{
foreach -parallel ($renwu in 1..60)
{
inlinescript
{
Start-Sleep -Seconds 1
$using:renwu
Start-Sleep -Seconds 60
}
}
#问:这个脚本谁写的?有问题找谁技术支持?
#答:QQ群号=183173532
#名称=powershell交流群
# 2019-09-18 转载留名
}
bingfa3
}
$本机ip = '192.168.11.22'
$workflow连接1 = New-PSSession -ComputerName $本机ip -ConfigurationName '我的工作流配置'
Invoke-Command -Session $workflow连接1 -ScriptBlock $我的workflow代码
Remove-PSSession $workflow连接1
--------7 【手册,资料】---------
New-PSWorkflowExecutionOption https://docs.microsoft.com/zh-cn/powershell/module/psworkflow/new-psworkflowexecutionoption?view=powershell-5.1
About Workflows https://docs.microsoft.com/zh-cn/powershell/module/psworkflow/about/about_workflows?view=powershell-5.1
About WorkflowCommonParameters https://docs.microsoft.com/zh-cn/powershell/module/psworkflow/about/about_workflowcommonparameters?view=powershell-5.1
尽解powershell的workflow的更多相关文章
- 使用PowerShell解三道测试开发笔试题
在网上看到了三道测试开发的笔试题,答案是用Python解的.这段时间正好在学PowerShell,练习一下:) 1. 验证邮箱格式 2. 获取URL的后缀名 3. 获取前一天时间或前一秒 我的解法是: ...
- PowerShell攻防进阶篇:nishang工具用法详解
PowerShell攻防进阶篇:nishang工具用法详解 导语:nishang,PowerShell下并肩Empire,Powersploit的神器. 开始之前,先放出个下载地址! 下载地址:htt ...
- 赖法,强制启动,https版的winrm ---powershell远程连接(winrm)的4个安全级别,详解
---------[winrm的“四级”安全]--------- 四级安全,就是最不安全的. winrm默认使用http+5985端口,密码传输加密,数据.命令传输明文.有被人窃取机密,和插入攻击命令 ...
- 【PowerShell】文件的解压与压缩
1 New-Item -ItemType File 1.txt -Force #新建文本文件 2 Compress-Archive -Path '1.txt' -DestinationPath '1. ...
- linux下mono,powershell安装教程
1简介 简单来说pash就是bash+powershell 2官网 https://github.com/Pash-Project/Pash 3下载fedora20---lxde桌面---32位版. ...
- Install and Configure SharePoint 2013 Workflow
这篇文章主要briefly introduce the Install and configure SharePoint 2013 Workflow. Microsoft 推出了新的Workflow ...
- 如何用PowerShell列出你机器上的.NET Framework的版本号和SP服务补丁
代码下载:本文提到的脚本,可以从微软的代码库下载, How to determine versions & service pack levels of .NET Framework by P ...
- Struts2拦截器的使用 (详解)
Struts2拦截器的使用 (详解) 如何使用struts2拦截器,或者自定义拦截器.特别注意,在使用拦截器的时候,在Action里面必须最后一定要引用struts2自带的拦截器缺省堆栈default ...
- 使用PowerShell读取SharePoint里列表的内容
1. 在https://www.microsoft.com/en-us/download/details.aspx?id=42038这里下载SharePoint Online Client Compo ...
随机推荐
- 14-scrapy框架(CrawlSpider)
CrawlSpider介绍 CrawlSpider是Spider的一个子类,意味着拥有Spider的方法,以及自己的方法,更加高效简洁.其中最显著的功能就是"LinkExtractors&q ...
- node 连接 mysql 数据库三种方法------笔记
一.mysql库 文档:https://github.com/mysqljs/mysql mysql有三种创建连接方式 1.createConnection 使用时需要对连接的创建.断开进行管理 2. ...
- 多模块springboot项目启动访问不了jsp页面
被springboot项目maven打包.启动.访问折腾的头都大了,一步一个坑,在解决了所有的问题之后,那种欣喜若狂的心情只有自己能体会,决定要好好记录一下了,废话不多说了,直接进入正题. 问题和排查 ...
- MySQL-8.0.18 引入了破坏性变更
MySQL-8.0.18 引入了破坏性变更 变更日志里面有这样一项 When the server is run with --initialize, there is no reason to lo ...
- 点云3D 目标检测
点云 点云是雷达采集到的信息. 关于点云基本介绍参考https://zhuanlan.zhihu.com/p/22581673 ros中的点云消息结构:http://docs.ros.org/jade ...
- 基于C# WinForms窗体——飞机大战
原文:基于C# WinForms窗体——飞机大战 using System; using System.Collections.Generic; using System.ComponentModel ...
- ABP进阶教程4 - 分页排序
点这里进入ABP进阶教程目录 下载插件 打开Datatables官网(https://datatables.net/download/) 下载插件,复制到JD.CRS.Web.Mvc\wwwroot\ ...
- MySQL基础之数据管理【3】
MySQL中的多表联查 --查询emp的id username age depName create table emp( id int unsigned auto_increment key, us ...
- 【LeetCode】53.最大子序和
最大子序和 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和. 示例: 输入: [-2,1,-3,4,-1,2,1,-5,4], 输出: 6 解释: ...
- IDEA设置默认WorkingDirectory