{"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"}],"update_at":"2026/8/3","updated_at_date_time":"2026-08-03T08:25:56.3487582Z"},"_path":"module/configurationmanager/new-cmtsrule.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-cmtsrule?view=sccm-ps","content_git_url":"https://github.com/MicrosoftDocs/sccm-docs-powershell-ref/blob/main/sccm-ps/ConfigurationManager/New-CMTSRule.md","default_moniker":"sccm-ps","depot_name":"MSDN.sccm-powershell","document_id":"8dc3993b-0ea5-815f-4825-c8540197642f","document_version_independent_id":"92603e7a-e3d5-5623-69f5-bdb2be242fe0","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":"48cf632fb4b9ad92060012681a500478254de750","gitcommit":"https://github.com/MicrosoftDocs/sccm-docs-powershell/blob/48cf632fb4b9ad92060012681a500478254de750/sccm-ps/ConfigurationManager/New-CMTSRule.md","github_contributors":["aczechowski"],"locale":"zh-tw","manager":"laurawi","Module Name":"ConfigurationManager","monikers":["sccm-ps"],"ms.author":"dannygu","ms.date":"09/01/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-CMTSRule.md","original_content_git_url_template":"{repo}/blob/{branch}/sccm-ps/ConfigurationManager/New-CMTSRule.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:25 AM","xrefs":[{"href":"https://learn.microsoft.com/powershell/module/configurationmanager/new-cmtsrule","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMTSRule","schemaType":"PowershellCmdlet","summary":"<p>建立規則以新增至 <strong>[設定動態變數</strong> ] 工作順序步驟。</p>\n","uid":"ConfigurationManager.New-CMTSRule"}],"ocv-translation-feedback":true},"_xrefmap":{"ConfigurationManager":{"href":"./","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"ConfigurationManager","schemaType":"PowershellModule","uid":"ConfigurationManager"},"ConfigurationManager.New-CMTSRule":{"href":"new-cmtsrule","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMTSRule","schemaType":"PowershellCmdlet","summary":"<p>建立規則以新增至 <strong>[設定動態變數</strong> ] 工作順序步驟。</p>\n","uid":"ConfigurationManager.New-CMTSRule"}},"description":"<p>使用此 Cmdlet 來建立您新增至 <strong>[設定動態變數</strong> ] 工作順序步驟的規則物件。 若要新增規則，請使用 <a href=\"new-cmtsstepsetdynamicvariable\">New-CMTSStepSetDynamicVariable</a> 或 <a href=\"set-cmtsstepsetdynamicvariable\">Set-CMTSStepSetDynamicVariable</a> Cmdlet。 當工作順序執行此步驟時，它會依序評估動態規則和變數。 當評估特定裝置上的規則時，它可以接著根據這些規則來設定工作順序變數。</p>\n<p>規則有四種類型：</p>\n<ul>\n<li>\n              <strong>計算機</strong>：評估硬體資產標籤、UUID、序號或 MAC 位址的值。</li>\n<li>\n              <strong>位置</strong>：評估預設網路閘道的值。</li>\n<li>\n              <strong>製作和模型</strong>：評估計算機製造和模型的值。</li>\n<li>\n              <strong>工作順序變數</strong>：新增要評估的工作順序變數、條件和值。</li>\n</ul>\n<p>如需詳細資訊，請參閱 <a href=\"/mem/configmgr/osd/understand/task-sequence-steps#dynamic-rules-and-variables\">動態規則和變數</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":"$tsrule = New-CMTSRule -Variable @{'OSDDownloadDestinationLocationType' = 'TSCache'} -ReferencedVariableName \"_SMSTSInWinPE\" -ReferencedVariableOperator equals -ReferencedVariableValue TRUE\n\n$tsname = \"Default IPU\"\n$tsstep = \"Set Dynamic Variables\"\n\nSet-CMTSStepSetDynamicVariable -TaskSequenceName $tsname -StepName $tsstep -AddRule $tsrule","description":"","summary":"<p>此範例會建立下列規則：</p>\n<p><code>IF _SMSTSInWinPE equals &quot;TRUE&quot; THEN SET OSDDownloadDestinationLocationType = &quot;TSCache&quot;</code></p>\n<p>然後，它會將此規則新增至工作順序中此步驟的現有實例。</p>\n","title":"範例 1：在 Windows PE 中設定下載目的地"}],"inputs":[{"description":"","name":"<span class=\"no-loc xref\">None</span>\n"}],"links":[{"href":"set-cmtsstepsetdynamicvariable","text":"Set-CMTSStepSetDynamicVariable"},{"href":"new-cmtsstepsetdynamicvariable","text":"New-CMTSStepSetDynamicVariable"},{"href":"/mem/configmgr/osd/understand/task-sequence-steps#BKMK_SetDynamicVariables","text":"關於工作順序步驟 - 設定動態變數"},{"href":"/mem/configmgr/osd/understand/using-task-sequence-variables","text":"如何在 Configuration Manager 中使用工作順序變數"}],"module":"ConfigurationManager","name":"New-CMTSRule","notes":"","outputs":[{"description":"","name":"<span class=\"no-loc xref\">IResultObject</span>\n"}],"parameters":[{"aliases":"","defaultValue":"None","description":"<p>指定<strong>計算機</strong>規則類型的<strong>資產標籤</strong>。 最大值為 255 個字元。</p>\n<p>例如，如果您將此值設定為 <code>123456</code>，它會新增下列規則： <code>IF Asset tag equals &quot;123456&quot; THEN</code></p>\n","name":"AssetTag","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\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>] 規則類型的 <strong>[預設網關</strong>]。</p>\n<p>例如，如果您將此值設定為 <code>192.168.10.1</code>，它會新增下列規則： <code>IF Default gateway equals &quot;192.168.10.1&quot; THEN</code></p>\n","name":"DefaultGateway","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</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":"","defaultValue":"None","description":"<p>此參數會處理通配符，並可能導致非預期的行為 (不建議) 。 您無法將其與 <strong>DisableWildcardHandling</strong> 結合。</p>\n","name":"ForceWildcardHandling","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定<strong>電腦</strong>規則類型的 <strong>MAC 位址</strong>。</p>\n<p>例如，如果您將此值設定為 <code>00:11:22:33:44:55</code>，它會新增下列規則： <code>IF MAC address equals &quot;00:11:22:33:44:55&quot; THEN</code></p>\n","name":"MacAddress","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定<strong>Make</strong><strong>和 Model</strong> 規則類型的 Make。 若要設定其他值，請使用 <strong>Model</strong> 參數。 當兩個值都為 true 時，規則會評估為 true。</p>\n<p>您可以使用通配符：</p>\n<ul>\n<li>\n              <code>*</code>：多個字元</li>\n<li>\n              <code>?</code>：單一字元</li>\n</ul>\n<p>例如，如果您將此值設定為 <code>Surface</code> ，並將 <strong>Model</strong> 設定為 <code>*</code>，則會新增下列規則： <code>IF Make equals &quot;Surface&quot; AND Model equals &quot;*&quot; THEN</code></p>\n","name":"Make","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定 <strong>[建立]</strong> 和 [模型] 規則類型的 <strong>[模型</strong> ]。 若要設定其他值，請使用 <strong>Make</strong> 參數。 當兩個值都為 true 時，規則會評估為 true。</p>\n<p>您可以使用通配符：</p>\n<ul>\n<li>\n              <code>*</code>：多個字元</li>\n<li>\n              <code>?</code>：單一字元</li>\n</ul>\n<p>例如，如果您將此值設定為 <code>*</code> ，並將 <strong>Make</strong> 設為 <code>Surface</code>，則會新增下列規則： <code>IF Make equals &quot;Surface&quot; AND Model equals &quot;*&quot; THEN</code></p>\n","name":"Model","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定 [<strong>工作順序變數</strong>] 規則類型的 [<strong>變數</strong>]。 它需要您也設定 <strong>ReferencedVariableOperator</strong> 和 <strong>ReferencedVariableValue</strong> 參數。</p>\n<p>此變數名稱可以是內建的工作順序變數或您建立的自定義工作順序變數。 如需詳細資訊，請 <a href=\"/mem/configmgr/osd/understand/using-task-sequence-variables\">參閱如何在 Configuration Manager 中使用工作順序變數</a>。</p>\n<p>例如，如果您設定下列值：</p>\n<ul>\n<li>\n              <strong>ReferencedVariableName</strong>： <code>OSDRegisteredOrgName</code></li>\n<li>\n              <strong>ReferencedVariableOperator</strong>： <code>Equals</code></li>\n<li>\n              <strong>ReferencedVariableValue</strong>： <code>Contoso</code></li>\n</ul>\n<p>然後，它會新增下列規則： <code>IF OSDRegisteredOrgName equals &quot;Contoso&quot; THEN</code></p>\n","name":"ReferencedVariableName","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定 [<strong>工作順序變數</strong>] 規則類型的 <strong>[條件</strong>]。 它需要您也設定 <strong>ReferencedVariableName</strong> 和 <strong>ReferencedVariableValue</strong> 參數。 如需可用的運算符，請參閱此參數的接受值清單。</p>\n<p>例如，如果您設定下列值：</p>\n<ul>\n<li>\n              <strong>ReferencedVariableName</strong>： <code>OSDRegisteredOrgName</code></li>\n<li>\n              <strong>ReferencedVariableOperator</strong>： <code>Equals</code></li>\n<li>\n              <strong>ReferencedVariableValue</strong>： <code>Contoso</code></li>\n</ul>\n<p>然後，它會新增下列規則： <code>IF OSDRegisteredOrgName equals &quot;Contoso&quot; THEN</code></p>\n","name":"ReferencedVariableOperator","parameterValueGroup":"Exists, NotExists, Equals, NotEquals, Greater, GreaterEqual, Less, LessEqual, Like, NotLike","position":"Named","type":"<span class=\"no-loc xref\">VariableOperatorType</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定 [<strong>工作順序變數</strong>] 規則類型的 <strong>[值</strong>]。 您也必須設定 <strong>ReferencedVariableName</strong> 和 <strong>ReferencedVariableOperator</strong> 參數。</p>\n<p>例如，如果您設定下列值：</p>\n<ul>\n<li>\n              <strong>ReferencedVariableName</strong>： <code>OSDRegisteredOrgName</code></li>\n<li>\n              <strong>ReferencedVariableOperator</strong>： <code>Equals</code></li>\n<li>\n              <strong>ReferencedVariableValue</strong>： <code>Contoso</code></li>\n</ul>\n<p>然後，它會新增下列規則： <code>IF OSDRegisteredOrgName equals &quot;Contoso&quot; THEN</code></p>\n","name":"ReferencedVariableValue","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定<strong>電腦</strong>規則類型的<strong>序號</strong>。</p>\n<p>例如，如果您將此值設定為 <code>123456</code>，它會新增下列規則： <code>IF Asset tag equals &quot;123456&quot; THEN</code></p>\n","name":"SerialNumber","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定<strong>電腦</strong>規則類型的 <strong>UUID</strong>。</p>\n<p>例如，如果您將此值設定為 <code>de5ba380-f692-45e0-bbd3-0e40543b549e</code>，它會新增下列規則： <code>IF UUID equals &quot;de5ba380-f692-45e0-bbd3-0e40543b549e&quot; THEN</code></p>\n","name":"Uuid","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"Variables","defaultValue":"None","description":"<p>指定現有或自定義工作順序變數，以及當規則評估為 true 時，步驟應該設定的相關值。</p>\n<p>例如，如果您將此值設定為 <code>@{'OSDDownloadDestinationLocationType' = 'TSCache'}</code>，它會在規則的 之後 <code>THEN</code> 新增下列變數： <code>SET OSDDownloadDestinationLocationType = &quot;TSCache&quot;</code></p>\n<p>若要在相同的哈希表中指定多個變數，請使用分號 () <code>;</code> 分隔符。 例如：<code>@{'OSDRegisteredUserName' = 'Contoso';'OSDRegisteredOrgName' = 'Contoso'}</code></p>\n","isRequired":true,"name":"Variable","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">Hashtable</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"}],"schema":"PowershellCmdlet","summary":"<p>建立規則以新增至 <strong>[設定動態變數</strong> ] 工作順序步驟。</p>\n","syntaxes":["New-CMTSRule -Variable <Hashtable> [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]","New-CMTSRule [-AssetTag <String>] [-MacAddress <String>] [-SerialNumber <String>] [-Uuid <String>]\n -Variable <Hashtable> [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]","New-CMTSRule [-DefaultGateway <String>] -Variable <Hashtable> [-DisableWildcardHandling]\n [-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]","New-CMTSRule [-Make <String>] [-Model <String>] -Variable <Hashtable> [-DisableWildcardHandling]\n [-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]","New-CMTSRule [-ReferencedVariableName <String>] [-ReferencedVariableOperator <VariableOperatorType>]\n [-ReferencedVariableValue <String>] -Variable <Hashtable> [-DisableWildcardHandling] [-ForceWildcardHandling]\n [-WhatIf] [-Confirm] [<CommonParameters>]"],"uid":"ConfigurationManager.New-CMTSRule","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-CMTSRule.md","xrefs":[{"href":"https://learn.microsoft.com/powershell/module/configurationmanager/new-cmtsrule","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMTSRule","schemaType":"PowershellCmdlet","summary":"<p>建立規則以新增至 <strong>[設定動態變數</strong> ] 工作順序步驟。</p>\n","uid":"ConfigurationManager.New-CMTSRule"}],"canonical_url":"https://learn.microsoft.com/zh-tw/powershell/module/configurationmanager/new-cmtsrule?view=sccm-ps","_op_canonicalUrl":"https://learn.microsoft.com/zh-tw/powershell/module/configurationmanager/new-cmtsrule?view=sccm-ps"},"pageMetadata":"<meta name=\"description\" content=\"<p>使用此 Cmdlet 來建立您新增至 <strong>[設定動態變數</strong> ] 工作順序步驟的規則物件。 若要新增規則，請使用 <a href=&quot;new-cmtsstepsetdynamicvariable&quot;>New-CMTSStepSetDynamicVariable</a> 或 <a href=&quot;set-cmtsstepsetdynamicvariable&quot;>Set-CMTSStepSetDynamicVariable</a> Cmdlet。 當工作順序執行此步驟時，它會依序評估動態規則和變數。 當評估特定裝置上的規則時，它可以接著根據這些規則來設定工作順序變數。</p>\n<p>規則有四種類型：</p>\n<ul>\n<li>\n              <strong>計算機</strong>：評估硬體資產標籤、UUID、序號或 MAC 位址的值。</li>\n<li>\n              <strong>位置</strong>：評估預設網路閘道的值。</li>\n<li>\n              <strong>製作和模型</strong>：評估計算機製造和模型的值。</li>\n<li>\n              <strong>工作順序變數</strong>：新增要評估的工作順序變數、條件和值。</li>\n</ul>\n<p>如需詳細資訊，請參閱 <a href=&quot;/mem/configmgr/osd/understand/task-sequence-steps#dynamic-rules-and-variables&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-CMTSRule.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-CMTSRule\" />\r\n<meta name=\"notes\" content=\"\" />\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-CMTSRule -Variable <Hashtable> [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]\" />\r\n<meta name=\"syntaxes\" content=\"New-CMTSRule [-AssetTag <String>] [-MacAddress <String>] [-SerialNumber <String>] [-Uuid <String>]\n -Variable <Hashtable> [-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm]\n [<CommonParameters>]\" />\r\n<meta name=\"syntaxes\" content=\"New-CMTSRule [-DefaultGateway <String>] -Variable <Hashtable> [-DisableWildcardHandling]\n [-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]\" />\r\n<meta name=\"syntaxes\" content=\"New-CMTSRule [-Make <String>] [-Model <String>] -Variable <Hashtable> [-DisableWildcardHandling]\n [-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]\" />\r\n<meta name=\"syntaxes\" content=\"New-CMTSRule [-ReferencedVariableName <String>] [-ReferencedVariableOperator <VariableOperatorType>]\n [-ReferencedVariableValue <String>] -Variable <Hashtable> [-DisableWildcardHandling] [-ForceWildcardHandling]\n [-WhatIf] [-Confirm] [<CommonParameters>]\" />\r\n<meta name=\"uid\" content=\"ConfigurationManager.New-CMTSRule\" />\r\n","themesRelativePathToOutputRoot":"_themes/"}