如何使用 Powershell 3 增加并行进程数?

2024-04-21

我正在尝试并行运行 20 个进程。我如下更改了会话,但没有运气。我每个会话最多只能有 5 个并行进程。

$wo=New-PSWorkflowExecutionOption -MaxSessionsPerWorkflow 50 -MaxDisconnectedSessions 200 -MaxSessionsPerRemoteNode 50 -MaxActivityProcesses 50
Register-PSSessionConfiguration -Name ITWorkflows -SessionTypeOption $wo -Force
Get-PSSessionConfiguration ITWorkflows | Format-List -Property *

有没有一个开关参数可以增加进程数?

这就是我正在运行的:

Workflow MyWorkflow1
{
Parallel {
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns  "where OrderId between 2 and 2975416"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 2975417 and 5950831"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 5950832 and 8926246"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 8926247 and 11901661"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 11901662 and 14877076"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns"where OrderId between 14877077 and 17852491"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns  "where OrderId between 17852492 and 20827906"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 20827907 and 23803321"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 23803322 and 26778736"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 26778737 and 29754151"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 29754152 and 32729566"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 32729567 and 35704981"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 35704982 and 38680396"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 38680397 and 432472144"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 432472145 and 435447559"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns  "where OrderId between 435447560 and 438422974"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 864944289 and 867919703"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 867919704 and 870895118"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 870895119 and 1291465602"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 1291465603 and 1717986945"}
         }

jrv 来自 MSDN 论坛提供工作代码示例 https://social.microsoft.com/Forums/en-US/3ae1efc9-46d7-426f-b26f-c43dab43adb4/change-powershell-parallel-limit?forum=Offtopic:

$wo = New-PSWorkflowExecutionOption -MaxSessionsPerWorkflow 100 -MaxDisconnectedSessions 200
Register-PSSessionConfiguration -Name test-ping -SessionTypeOption $wo -Force

$s = New-PSWorkflowSession 
Invoke-Command $s { 
workflow Invoke-ParallelForEach{ 
    foreach -parallel ($i in 1..10){ 
        InlineScript{ 
            "foo: $using:i" 
        } 
        Get-Process -Name PowerShell* 
    } 
   } 
}

# now run the workflow with the custom configuration
Invoke-Command $s { Invoke-ParallelForEach -PSComputerName localhost -PSConfigurationName test-ping}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 Powershell 3 增加并行进程数? 的相关文章

  • 单机Octave并行计算——包和示例

    我想在单台机器 而不是集群 上并行化 Octave 中的 for 循环 前段时间我问了一个关于Octave并行版本的问题Octave并行计算 https stackoverflow com questions 7047840 paralle
  • 如何创建自定义 Powershell 运算符?

    是否可以在 Powershell 中创建自定义运算符 而且 我该怎么做呢 我搜索过谷歌 但没有任何结果 我特指一个中缀运算符 示例列表 包含 元素 我已经创建了 cmdlet 使用 Powershell 和 C 模块等 所以我只需要大概的内
  • Jenkins 中的 Powershell 转义路径字符

    我有一个声明性管道 应该执行 powershell 步骤来安装路径 路径作为参数提供 parameters string name UNC defaultValue server01 lab local shared data descri
  • Powershell“特殊”开关参数

    我有下面的powershell功能 Function Test Param Parameter string Text default text Write Host Text Text 我希望能够像下面这样调用这个函数 测试 文本 应该在
  • Powershell Bash/Zsh 命令中的多个参数

    无法在 Powershell 中运行以下 Bash Zsh 命令 KeyPath Join Path Path this Plate ChildPath install tekton key kubectl create secret do
  • Java 中的并行编程

    我们如何在Java中进行并行编程 有什么特殊的框架吗 我们怎样才能让这些东西发挥作用 我会告诉你们我需要什么 认为我开发了一个网络爬虫 它从互联网上爬取了大量数据 一个爬行系统无法使事情正常工作 因此我需要更多的系统并行工作 如果是这种情况
  • 在 PowerShell 错误消息中使用 touch 命令创建新文件

    我的桌面上有一个使用 PowerShell 创建的目录 现在我尝试在其中创建一个文本文件 我确实将目录更改为新目录 然后输入touch textfile txt 这是我收到的错误消息 touch The term touch is not
  • powershell 优雅/干净地关闭 Internet Explorer

    我想干净 优雅地关闭互联网浏览器 taskkill 会关闭它 但是当重新打开它时 它会询问您是否要重新打开上一个会话 尝试 CloseMainWindow 方法 通过向其主窗口发送关闭消息来关闭具有用户界面的进程 Get Process i
  • R 中使用 randomForest 进行内存高效预测

    TL DR我想知道使用基于大型数据集 数百个特征 数十万行 构建的随机森林模型执行批量预测的内存有效方法 Details 我正在处理一个大型数据集 内存中超过 3GB 并且想要使用以下方法进行简单的二进制分类randomForest 由于我
  • 我可以在 R 中并行读取 1 个大 CSV 文件吗? [复制]

    这个问题在这里已经有答案了 我有一个很大的 csv 文件 需要很长时间才能阅读 我可以使用 parallel 或相关的包在 R 中并行读取此内容吗 我尝试过使用 mclapply 但它不起作用 根据OP的评论 fread来自data tab
  • 在 Array Powershell 中获取新的附加值

    for Get All Files from the Folder FolderItems Get PnPFolderItem FolderSiteRelativeUrl FolderURL ItemType File Write Host
  • Git - 包含来自其他存储库的文件

    对于 Git 我想包含一些常见的 JS CSS 库和 或实用方法 即来自另一个存储库的特定文件 在我的项目中 我希望它们始终是最新的 我真的不想要整个远程存储库 如果我可以处理远程文件的 本地副本 并将更改推送回来 那就太好了 一个有点类似
  • Powershell Core 6 中的 HtmlWebResponseObject.ParsedHtml 替换

    我的目标是解析检索到的 html 文件Invoke WebRequest 如果可能的话 我想避免任何外部库 我面临的问题是Invoke WebRequest返回一个BasicHtmlWebResponseObject代替HtmlWebRes
  • PowerShell 与 MongoDB C# 驱动程序方法不兼容?

    由 C 泛型引起的最新 MongoDB 驱动程序的问题 Cannot find an overload for GetCollection and the argument count 1 我可能可以使用其他没有泛型的 GetCollect
  • 如何在Python中使用多处理来加速循环执行

    我有两个清单 列表 A 包含 500 个单词 列表 B 包含 10000 个单词 我正在尝试为列表 A 找到与 B 相关的相似单词 我正在使用 Spacy 的相似函数 我面临的问题是计算需要很长时间 我是多处理使用的新手 因此请求帮助 如何
  • Azure 函数核心工具安装卡在 Visual Studio Code 中

    我创建了 Azure 函数应用程序来执行 powershell 脚本 想先在我的本地运行它来测试它 当我运行它时 无论有没有调试选项 都会出现一个弹出窗口 其中显示 您必须安装 Azure Functions 核心工具才能调试本地函数 当我
  • 如何在powershell中将一个大文本文件拆分为多个文件

    你好 我有一个像这样的大文本文件 BIGFILE TXT COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5 COLUMN6 COLUMN7 COLUMN8 11 24 2013 50 67 51 22 50 6
  • C# 的快速线程安全随机数生成器

    我需要在多个正在运行的线程中快速生成随机浮点数 我尝试过使用System Random 但它对于我的需求来说太慢了 并且它在多个线程中返回相同的数字 当我在单线程中运行应用程序时 它工作正常 此外 我需要确保生成的数字在 0 到 100 之
  • 如何在 IIS 8 中远程停止/启动应用程序池

    注意 每条线使用一行 我在 IIS 6 中使用了这些命令 它们工作得很好 Start get wmiobject namespace root MicrosoftIISv2 computername REMOTE SERVER class
  • 如何在 powershell 中使用正则表达式选择“catch”代码块?

    我正在尝试分析多个目录中的大量 powershell 脚本 并且希望将任何 Catch 代码块拉入列表 变量中 我正在尝试编写一个正则表达式来选择以下格式的任何块 Catch write Host Function MyInvocation

随机推荐