{"content":"<div></div>","rawMetadata":{"metadata":{"_op_canonicalUrlPrefix":"https://learn.microsoft.com/zh-tw/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/8/3","updated_at_date_time":"2026-08-03T08:28:44.4098627Z"},"_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-tw/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","document_id":"1c71c77c-fc77-bb79-08ab-ff0873c065da","document_version_independent_id":"d4df6662-eadb-815f-a79f-f77c3beb02b0","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-tw","manager":"laurawi","Module Name":"ConfigurationManager","monikers":["sccm-ps"],"ms.author":"dannygu","ms.date":"08/31/2021","ms.service":"microsoft-endpoint-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-08-03 08:28 AM","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 可執行檔和連結庫。 新增此參數以停用W64檔系統重新導向器的使用。 Windows 會使用原生 64 位版本的作業系統可執行檔和連結庫來執行命令。 在 32 位作業系統上執行時，此選項沒有任何作用。</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>封裝的套件識別</strong> 碼。 套件不需要程式。 如果指定的檔案存在於目的地計算機上，則不需要此選項。</p>\n<p>此值是標準套件識別碼，例如 <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> minutes。</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-tw","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-tw/powershell/module/configurationmanager/new-cmtsstepruncommandline?view=sccm-ps","_op_canonicalUrl":"https://learn.microsoft.com/zh-tw/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-tw\" />\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/"}