{"content":"<div></div>","rawMetadata":{"metadata":{"_op_canonicalUrlPrefix":"https://learn.microsoft.com/zh-cn/powershell/","_op_gitContributorInformation":{"author":{"display_name":"Banreet Kaur","id":"92906285","name":"Banreet","profile_url":"https://github.com/Banreet"},"contributors":[{"display_name":"Aaron Czechowski","id":"26784733","name":"aczechowski","profile_url":"https://github.com/aczechowski"},{"display_name":"Dan Mabee","id":"40476441","name":"damabe","profile_url":"https://github.com/damabe"},{"display_name":"Chris Kibble","id":"39386226","name":"ChrisKibble","profile_url":"https://github.com/ChrisKibble"},{"display_name":"sankethka","id":"16908144","name":"sankethka","profile_url":"https://github.com/sankethka"}],"update_at":"2026/9/1","updated_at_date_time":"2026-09-01T12:21:29.430826Z"},"_path":"module/configurationmanager/new-cmtsstepruncommandline.json","_rel":"../../","_tocRel":"../sccm-ps/toc.json","apiPlatform":"powershell","author":"Banreet","breadcrumb_path":"/powershell/sccm/bread/toc.json","canonical_url":"https://learn.microsoft.com/zh-cn/powershell/module/configurationmanager/new-cmtsstepruncommandline?view=sccm-ps","content_git_url":"https://github.com/MicrosoftDocs/sccm-docs-powershell-ref/blob/main/sccm-ps/ConfigurationManager/New-CMTSStepRunCommandLine.md","default_moniker":"sccm-ps","depot_name":"MSDN.sccm-powershell","external help file":"AdminUI.PS.dll-Help.xml","feedback_product_url":"https://feedbackportal.microsoft.com/feedback/forum/4669adfc-ee1b-ec11-b6e7-0022481f8472","feedback_system":"Standard","git_commit_id":"62e555aa39764a14ca841753bfe1cb32f721e6b3","gitcommit":"https://github.com/MicrosoftDocs/sccm-docs-powershell/blob/62e555aa39764a14ca841753bfe1cb32f721e6b3/sccm-ps/ConfigurationManager/New-CMTSStepRunCommandLine.md","github_contributors":["aczechowski","damabe","ChrisKibble","sankethka"],"locale":"zh-cn","manager":"laurawi","Module Name":"ConfigurationManager","monikers":["sccm-ps"],"ms.author":"dannygu","ms.date":"08/31/2021","ms.service":"configuration-manager","ms.subservice":"other","ms.topic":"reference","online version":"","open_to_public_contributors":true,"original_content_git_url":"https://github.com/MicrosoftDocs/sccm-docs-powershell/blob/live/sccm-ps/ConfigurationManager/New-CMTSStepRunCommandLine.md","original_content_git_url_template":"{repo}/blob/{branch}/sccm-ps/ConfigurationManager/New-CMTSStepRunCommandLine.md","PlatyPS schema version":"2.0.0","products":["https://authoring-docs-microsoft.poolparty.biz/devrel/f1499c3b-793f-48c3-a9ce-20285bcc6541"],"site_name":"Docs","titleSuffix":"Configuration Manager","uhfHeaderId":"MSDocsHeader-Powershell","updated_at":"2026-09-01 12:21 PM","xrefs":[{"href":"https://learn.microsoft.com/powershell/module/configurationmanager/new-cmtsstepruncommandline","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMTSStepRunCommandLine","schemaType":"PowershellCmdlet","summary":"<p>创建可添加到任务序列的 <strong>“运行命令行”</strong> 步骤。</p>\n","uid":"ConfigurationManager.New-CMTSStepRunCommandLine"}],"ocv-translation-feedback":true},"_xrefmap":{"ConfigurationManager":{"href":"./","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"ConfigurationManager","schemaType":"PowershellModule","uid":"ConfigurationManager"},"ConfigurationManager.New-CMTSStepRunCommandLine":{"href":"new-cmtsstepruncommandline","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMTSStepRunCommandLine","schemaType":"PowershellCmdlet","summary":"<p>创建可添加到任务序列的 <strong>“运行命令行”</strong> 步骤。</p>\n","uid":"ConfigurationManager.New-CMTSStepRunCommandLine"}},"description":"<p>此 cmdlet 创建一个新的 <strong>运行命令行</strong> 步骤对象。 然后使用 <a href=\"add-cmtasksequencestep\">Add-CMTaskSequenceStep</a> cmdlet 将步骤添加到任务序列。 有关此步骤的详细信息，请参阅 <a href=\"/mem/configmgr/osd/understand/task-sequence-steps#BKMK_RunCommandLine\">关于任务序列步骤：运行命令行</a>。</p>\n<div class=\"NOTE\">\n<p>注意</p>\n<p>从 Configuration Manager 站点驱动器运行 Configuration Manager cmdlet，例如 <code>PS XYZ:\\&gt;</code>。 有关详细信息，请参阅 <a href=\"/powershell/sccm/overview\">入门</a>。</p>\n</div>\n","examples":[{"code":"$step = New-CMTSStepRunCommandLine -Name \"Run Command Line\" -CommandLine \"cmd.exe /c copy Jan98.dat c:\\sales\\Jan98.dat\" -PackageId \"XYZ00821\"\n\n$tsNameOsd = \"Default OS deployment\"\n$tsOsd = Get-CMTaskSequence -Name $tsNameOsd -Fast\n\n$tsOsd | Add-CMTaskSequenceStep -Step $step -InsertStepStartIndex 11","description":"","summary":"<p>此示例首先为 <strong>“运行命令行”</strong> 步骤创建对象。 它指定要使用的命令行和包。</p>\n<p>然后，它获取任务序列对象，并将此新步骤添加到索引 11 处的任务序列。</p>\n","title":"示例 1"}],"inputs":[{"description":"","name":"<span class=\"no-loc xref\">None</span>\n"}],"links":[{"href":"get-cmtsstepruncommandline","text":"Get-CMTSStepRunCommandLine"},{"href":"remove-cmtsstepruncommandline","text":"Remove-CMTSStepRunCommandLine"},{"href":"set-cmtsstepruncommandline","text":"Set-CMTSStepRunCommandLine"},{"href":"/mem/configmgr/osd/understand/task-sequence-steps#BKMK_RunCommandLine","text":"关于任务序列步骤：运行命令行"}],"module":"ConfigurationManager","name":"New-CMTSStepRunCommandLine","notes":"<p>有关此返回对象及其属性的详细信息，请参阅 <a href=\"/mem/configmgr/develop/reference/osd/sms_tasksequence_runcommandlineaction-server-wmi-class\">SMS_TaskSequence_RunCommandLineAction服务器 WMI 类</a>。</p>\n","outputs":[{"description":"","name":"<span class=\"no-loc xref\">IResultObject</span>\n"}],"parameters":[{"aliases":"","defaultValue":"None","description":"<p>指定任务序列运行的命令行。 包括文件扩展名，例如 <code>.exe</code>。 包括所有必需的设置文件和命令行选项。</p>\n<p>例如：<code>cmd.exe /c copy Jan98.dat c:\\sales\\Jan98.dat</code></p>\n","isRequired":true,"name":"CommandLine","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"Conditions","defaultValue":"None","description":"<p>指定要用于此步骤的条件对象。 若要获取此对象，请使用任务序列条件 cmdlet 之一。 例如 <a href=\"get-cmtsstepconditionvariable\">Get-CMTSStepConditionVariable</a>。</p>\n","name":"Condition","parameterValueGroup":"","position":"Named","type":"<p><span class=\"no-loc xref\">IResultObject</span><span>[</span><span>]</span></p>\n"},{"aliases":"cf","defaultValue":"None","description":"<p>提示你在运行 cmdlet 之前进行确认。</p>\n","name":"Confirm","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>添加此参数以启用步骤选项“ <strong>出错时继续</strong>”。 启用此选项时，如果步骤失败，任务序列将继续。</p>\n","name":"ContinueOnError","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>为此任务序列步骤指定可选说明。</p>\n","name":"Description","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"DisableThisStep","defaultValue":"None","description":"<p>添加此参数以禁用此任务序列步骤。</p>\n","name":"Disable","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>此参数将通配符视为文本字符值。 不能将其与 <strong>ForceWildcardHandling</strong> 组合使用。</p>\n","name":"DisableWildcardHandling","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"DisableRedirectionFor64BitFileSystem","defaultValue":"None","description":"<p>默认情况下，64 位操作系统使用 WOW64 文件系统重定向程序来运行命令行。 此行为是为了正确查找 32 位版本的 OS 可执行文件和库。 添加此参数以禁用 WOW64 文件系统重定向器的使用。 Windows 使用本机 64 位版本的 OS 可执行文件和库运行命令。 在 32 位 OS 上运行时，此选项不起作用。</p>\n","name":"DisableWow64Redirection","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>此参数处理通配符，并可能导致意外行为， (不建议) 。 不能将其与 <strong>DisableWildcardHandling</strong> 组合使用。</p>\n","name":"ForceWildcardHandling","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"StepName","defaultValue":"None","description":"<p>指定此步骤的名称，以便在任务序列中标识它。</p>\n","isRequired":true,"name":"Name","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"Output, OutputVariable","defaultValue":"None","description":"<p>指定自定义任务序列变量的名称。 使用此参数时，该步骤会将命令输出的最后 1000 个字符保存到 变量。</p>\n","name":"OutputVariableName","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>当在命令行上指定目标计算机上尚不存在的文件或程序时，请使用此参数为包含所需文件的包指定包 <strong>ID</strong> 。 包不需要程序。 如果目标计算机上存在指定的文件，则不需要此选项。</p>\n<p>此值是标准包 ID，例如 <code>XYZ00821</code>。</p>\n","name":"PackageId","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>添加此参数以以 Windows 用户帐户（而不是本地系统帐户）的形式运行命令行。 然后使用 <strong>UserName</strong> 和 <strong>UserPassword</strong> 参数。</p>\n","name":"RunAsUser","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"SuccessCodes","defaultValue":"None","description":"<p>指定一个整数值数组作为命令的退出代码，步骤应将其评估为成功。</p>\n","name":"SuccessCode","parameterValueGroup":"","position":"Named","type":"<p><span class=\"no-loc xref\">Int32</span><span>[</span><span>]</span></p>\n"},{"aliases":"TimeoutInMinutes","defaultValue":"None","description":"<p>指定一个整数值，该值表示 Configuration Manager 允许命令行运行的时间。 此值可以是从 <code>1</code> 分钟到 <code>999</code> 分钟。 默认值 <code>15</code> 为分钟。</p>\n<p>如果输入的值不允许指定命令有足够的时间成功完成，则此步骤将失败。 整个任务序列可能会失败，具体取决于步骤或组条件。 如果超时过期，Configuration Manager 将终止命令行进程。</p>\n","name":"Timeout","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">Int32</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>使用 <strong>RunAsUser</strong> 参数时，请使用此参数指定 Windows 用户帐户的名称。 若要指定帐户密码，请使用 <strong>UserPassword</strong> 参数。</p>\n","name":"UserName","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>使用 <strong>RunAsUser</strong> 参数时，请使用此参数指定使用 <strong>UserName</strong> 指定的帐户的密码。</p>\n","name":"UserPassword","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SecureString</span>\n"},{"aliases":"wi","defaultValue":"None","description":"<p>显示在 cmdlet 运行时发生的情况。 cmdlet 不会运行。</p>\n","name":"WhatIf","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"StartIn","defaultValue":"None","description":"<p>指定启动命令的文件夹。 此路径最多可包含 127 个字符。</p>\n","name":"WorkingDirectory","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"}],"schema":"PowershellCmdlet","summary":"<p>创建可添加到任务序列的 <strong>“运行命令行”</strong> 步骤。</p>\n","syntaxes":["New-CMTSStepRunCommandLine -CommandLine <String> [-DisableWow64Redirection] [-PackageId <String>] [-RunAsUser]\n [-SuccessCode <Int32[]>] [-Timeout <Int32>] [-UserName <String>] [-UserPassword <SecureString>]\n [-WorkingDirectory <String>] [-Condition <IResultObject[]>] [-ContinueOnError] [-Description <String>]\n [-Disable] -Name <String> [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]","New-CMTSStepRunCommandLine -CommandLine <String> [-DisableWow64Redirection] [-OutputVariableName <String>]\n [-PackageId <String>] [-RunAsUser] [-SuccessCode <Int32[]>] [-Timeout <Int32>] [-UserName <String>]\n [-UserPassword <SecureString>] [-WorkingDirectory <String>] [-Condition <IResultObject[]>] [-ContinueOnError]\n [-Description <String>] [-Disable] [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]","New-CMTSStepRunCommandLine -CommandLine <String> [-DisableWow64Redirection] [-OutputVariableName <String>]\n [-PackageId <String>] [-RunAsUser] [-SuccessCode <Int32[]>] [-Timeout <Int32>] [-UserName <String>]\n [-UserPassword <SecureString>] [-WorkingDirectory <String>] [-Condition <IResultObject[]>] [-ContinueOnError]\n [-Description <String>] [-Disable] [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]"],"uid":"ConfigurationManager.New-CMTSStepRunCommandLine","hideEdit":true,"ms.translationtype":"MT","ms.contentlocale":"zh-cn","loc_version":"2024-08-21T21:18:36.7205003Z","loc_source_id":"Github-72476255#live","loc_file_id":"Github-72476255.live.MSDN.sccm-powershell.sccm-ps/ConfigurationManager/New-CMTSStepRunCommandLine.md","xrefs":[{"href":"https://learn.microsoft.com/powershell/module/configurationmanager/new-cmtsstepruncommandline","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMTSStepRunCommandLine","schemaType":"PowershellCmdlet","summary":"<p>创建可添加到任务序列的 <strong>“运行命令行”</strong> 步骤。</p>\n","uid":"ConfigurationManager.New-CMTSStepRunCommandLine"}],"canonical_url":"https://learn.microsoft.com/zh-cn/powershell/module/configurationmanager/new-cmtsstepruncommandline?view=sccm-ps","_op_canonicalUrl":"https://learn.microsoft.com/zh-cn/powershell/module/configurationmanager/new-cmtsstepruncommandline?view=sccm-ps"},"pageMetadata":"<meta name=\"description\" content=\"<p>此 cmdlet 创建一个新的 <strong>运行命令行</strong> 步骤对象。 然后使用 <a href=&quot;add-cmtasksequencestep&quot;>Add-CMTaskSequenceStep</a> cmdlet 将步骤添加到任务序列。 有关此步骤的详细信息，请参阅 <a href=&quot;/mem/configmgr/osd/understand/task-sequence-steps#BKMK_RunCommandLine&quot;>关于任务序列步骤：运行命令行</a>。</p>\n<div class=&quot;NOTE&quot;>\n<p>注意</p>\n<p>从 Configuration Manager 站点驱动器运行 Configuration Manager cmdlet，例如 <code>PS XYZ:\\&amp;gt;</code>。 有关详细信息，请参阅 <a href=&quot;/powershell/sccm/overview&quot;>入门</a>。</p>\n</div>\n\" />\r\n<meta name=\"hideEdit\" content=\"true\" />\r\n<meta name=\"loc_file_id\" content=\"Github-72476255.live.MSDN.sccm-powershell.sccm-ps/ConfigurationManager/New-CMTSStepRunCommandLine.md\" />\r\n<meta name=\"loc_source_id\" content=\"Github-72476255#live\" />\r\n<meta name=\"loc_version\" content=\"2024-08-21T21:18:36.7205003Z\" />\r\n<meta name=\"module\" content=\"ConfigurationManager\" />\r\n<meta name=\"ms.contentlocale\" content=\"zh-cn\" />\r\n<meta name=\"ms.translationtype\" content=\"MT\" />\r\n<meta name=\"name\" content=\"New-CMTSStepRunCommandLine\" />\r\n<meta name=\"notes\" content=\"<p>有关此返回对象及其属性的详细信息，请参阅 <a href=&quot;/mem/configmgr/develop/reference/osd/sms_tasksequence_runcommandlineaction-server-wmi-class&quot;>SMS_TaskSequence_RunCommandLineAction服务器 WMI 类</a>。</p>\n\" />\r\n<meta name=\"schema\" content=\"PowershellCmdlet\" />\r\n<meta name=\"summary\" content=\"<p>创建可添加到任务序列的 <strong>“运行命令行”</strong> 步骤。</p>\n\" />\r\n<meta name=\"syntaxes\" content=\"New-CMTSStepRunCommandLine -CommandLine <String> [-DisableWow64Redirection] [-PackageId <String>] [-RunAsUser]\n [-SuccessCode <Int32[]>] [-Timeout <Int32>] [-UserName <String>] [-UserPassword <SecureString>]\n [-WorkingDirectory <String>] [-Condition <IResultObject[]>] [-ContinueOnError] [-Description <String>]\n [-Disable] -Name <String> [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]\" />\r\n<meta name=\"syntaxes\" content=\"New-CMTSStepRunCommandLine -CommandLine <String> [-DisableWow64Redirection] [-OutputVariableName <String>]\n [-PackageId <String>] [-RunAsUser] [-SuccessCode <Int32[]>] [-Timeout <Int32>] [-UserName <String>]\n [-UserPassword <SecureString>] [-WorkingDirectory <String>] [-Condition <IResultObject[]>] [-ContinueOnError]\n [-Description <String>] [-Disable] [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]\" />\r\n<meta name=\"syntaxes\" content=\"New-CMTSStepRunCommandLine -CommandLine <String> [-DisableWow64Redirection] [-OutputVariableName <String>]\n [-PackageId <String>] [-RunAsUser] [-SuccessCode <Int32[]>] [-Timeout <Int32>] [-UserName <String>]\n [-UserPassword <SecureString>] [-WorkingDirectory <String>] [-Condition <IResultObject[]>] [-ContinueOnError]\n [-Description <String>] [-Disable] [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]\" />\r\n<meta name=\"uid\" content=\"ConfigurationManager.New-CMTSStepRunCommandLine\" />\r\n","themesRelativePathToOutputRoot":"_themes/"}