{"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":"Glenn Toms","id":"10454394","name":"GlennToms","profile_url":"https://github.com/GlennToms"},{"display_name":"Dan Mabee","id":"40476441","name":"damabe","profile_url":"https://github.com/damabe"},{"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:17:03.3152775Z"},"_path":"module/configurationmanager/new-cmdetectionclausefile.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-cmdetectionclausefile?view=sccm-ps","content_git_url":"https://github.com/MicrosoftDocs/sccm-docs-powershell-ref/blob/main/sccm-ps/ConfigurationManager/New-CMDetectionClauseFile.md","default_moniker":"sccm-ps","depot_name":"MSDN.sccm-powershell","description":"建立檔案的偵測方法子句。","document_id":"ca880bf9-b25f-d12e-73da-e37aa2a995d3","document_version_independent_id":"522d12b7-b2b0-fa84-e479-49fe6e35f150","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":"c74b3f4574af7a8a480adb998b311f6eeeb3e856","gitcommit":"https://github.com/MicrosoftDocs/sccm-docs-powershell/blob/c74b3f4574af7a8a480adb998b311f6eeeb3e856/sccm-ps/ConfigurationManager/New-CMDetectionClauseFile.md","github_contributors":["aczechowski","GlennToms","damabe","sankethka"],"locale":"zh-tw","manager":"laurawi","Module Name":"ConfigurationManager","monikers":["sccm-ps"],"ms.author":"dannygu","ms.date":"12/30/2020","ms.service":"microsoft-endpoint-configuration-manager","ms.subservice":"other","ms.topic":"reference","open_to_public_contributors":true,"original_content_git_url":"https://github.com/MicrosoftDocs/sccm-docs-powershell/blob/live/sccm-ps/ConfigurationManager/New-CMDetectionClauseFile.md","original_content_git_url_template":"{repo}/blob/{branch}/sccm-ps/ConfigurationManager/New-CMDetectionClauseFile.md","PlatyPS schema version":"2.0.0","products":["https://authoring-docs-microsoft.poolparty.biz/devrel/f1499c3b-793f-48c3-a9ce-20285bcc6541"],"site_name":"Docs","title":"New-CMDetectionClauseFile","titleSuffix":"Configuration Manager","uhfHeaderId":"MSDocsHeader-Powershell","updated_at":"2026-08-03 08:17 AM","xrefs":[{"href":"https://learn.microsoft.com/powershell/module/configurationmanager/new-cmdetectionclausefile","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMDetectionClauseFile","schemaType":"PowershellCmdlet","summary":"<p>建立檔案的偵測方法子句。</p>\n","uid":"ConfigurationManager.New-CMDetectionClauseFile"}],"ocv-translation-feedback":true},"_xrefmap":{"ConfigurationManager":{"href":"./","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"ConfigurationManager","schemaType":"PowershellModule","uid":"ConfigurationManager"},"ConfigurationManager.New-CMDetectionClauseFile":{"href":"new-cmdetectionclausefile","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMDetectionClauseFile","schemaType":"PowershellCmdlet","summary":"<p>建立檔案的偵測方法子句。</p>\n","uid":"ConfigurationManager.New-CMDetectionClauseFile"}},"description":"<p>使用此 Cmdlet 在應用程式的偵測方法中建立 子句。 這個子句是指出應用程式存在的檔案規則。</p>\n<p>若要偵測資料夾而非檔案，請使用 <a href=\"new-cmdetectionclausedirectory\">New-CMDetectionClauseDirectory Cmdlet</a> 。</p>\n<p>使用此 Cmdlet 之後，請針對部署類型使用其中一個 <strong>Add-</strong> 或 <strong>Set-</strong> Cmdlet。 將此偵測子句對象傳遞至 <strong>AddDetectionClause</strong> 或 <strong>RemoveDetectionClause</strong> 參數。</p>\n<p>若要將偵測子句分組，請在部署類型 Cmdlet 上使用 <strong>GroupDetectionClauses</strong> 參數。</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":"$clause = New-CMDetectionClauseFile -Path \"C:\\Program Files\\Application\" -FileName App.exe -Value -PropertyType Version -ExpressionOperator GreaterEquals -ExpectedValue \"1.0.0\"\n\nSet-CMScriptDeploymentType -ApplicationName \"CentralApp\" -DeploymentTypeName \"Scripted install\" -AddDetectionClause $clause","description":"","summary":"<p>此範例會偵測版本大於或等於 <code>1.0.0</code>之特定檔<strong>夾中的應用程式 </strong>app.exe。</p>\n","title":"範例 1：依版本偵測應用程式"},{"code":"$cla1=New-CMDetectionClauseFile -FileName \"filetest\" -PropertyType Size -ExpectedValue 123 -ExpressionOperator IsEquals -Path \"C:\\\" -Value -Is64Bit\n$cla2=New-CMDetectionClauseFile -FileName \"foldertest\" -PropertyType DateCreated -ExpectedValue (Get-Date) -ExpressionOperator LessThan -Path \"C:\\\" -Value\n$cla3=New-CMDetectionClauseRegistryKey -Hive ClassesRoot -KeyName \"aaa\"\n$logic1=$cla1.Setting.LogicalName\n$logic2=$cla2.Setting.LogicalName\n$logic3=$cla3.Setting.LogicalName\n\nAdd-CMMsiDeploymentType -AddDetectionClause $cla1,$cla2,$cla3 -ApplicationName \"app\" -DeploymentTypeName \"dt\" -InstallCommand \"mycommand\" -ContentLocation \"\\\\server\\sources\\Orca.msi\" -GroupDetectionClauses $logic1,$logic2 -DetectionClauseConnector {LogicalName=$logic2;Connector=\"or\"},{LogicalName=$logic3;Connector=\"or\"}","description":"","summary":"<p>此範例會建立兩個檔案子句和一個登錄子句，然後使用它們將 MSI 部署類型新增至應用程式。</p>\n","title":"範例 2：建立 MSI 應用程式部署類型的多個子句"}],"inputs":[{"description":"","name":"<span class=\"no-loc xref\">None</span>\n"}],"links":[{"href":"new-cmdetectionclausedirectory","text":"New-CMDetectionClauseDirectory"},{"href":"new-cmdetectionclauseregistrykey","text":"New-CMDetectionClauseRegistryKey"},{"href":"new-cmdetectionclauseregistrykeyvalue","text":"New-CMDetectionClauseRegistryKeyValue"},{"href":"new-cmdetectionclausewindowsinstaller","text":"New-CMDetectionClauseWindowsInstaller"}],"module":"ConfigurationManager","name":"New-CMDetectionClauseFile","notes":"","outputs":[{"description":"","name":"<span class=\"no-loc xref\">System.Object</span>\n"}],"parameters":[{"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>當您新增此參數時，檔案必須存在於目標系統上，以指出此應用程式是否存在。</p>\n<p>若要評估此檔案屬性的規則，請使用 <strong>Value</strong> 參數，而不只是存在。</p>\n","isRequired":true,"name":"Existence","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>當您新增 <strong>Value</strong> 參數時，請使用 <strong>ExpectedValue</strong> 搭配 <strong>PropertyType</strong> 和 <strong>ExpressionOperator</strong>。 當您使用這些參數時，檔案必須滿足規則，以指出此應用程式是否存在。 這個 <strong>ExpectedValue</strong> 參數會指定要與文件系統比較的值。</p>\n<p>要比較的值取決於指定的 <strong>PropertyType</strong>。</p>\n","isRequired":true,"name":"ExpectedValue","parameterValueGroup":"","position":"Named","type":"<p><span class=\"no-loc xref\">String</span><span>[</span><span>]</span></p>\n"},{"aliases":"","defaultValue":"None","description":"<p>當您新增 <strong>Value</strong> 參數時，請搭配 <strong>PropertyType</strong> 和 <strong>ExpectedValue</strong> 使用 <strong>ExpressionOperator</strong>。 當您使用這些參數時，檔案必須滿足規則，以指出此應用程式是否存在。 這個 <strong>ExpressionOperator</strong> 參數會指定比較文件系統值與預期值的運算符。</p>\n<p>從 2010 版開始，參數類型從 <em>RuleExpressionOperator</em> 變更為 <em>FileFolderRuleExpressionOperator</em>。</p>\n","isRequired":true,"name":"ExpressionOperator","parameterValueGroup":"IsEquals, NotEquals, GreaterThan, LessThan, Between, GreaterEquals, LessEquals, OneOf, NoneOf","position":"Named","type":"<span class=\"no-loc xref\">FileFolderRuleExpressionOperator</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定指出應用程式存在的檔名。 使用 <strong>Path</strong> 參數來指定此檔案的路徑。</p>\n<p>例如，Configuration Manager 控制台預設會安裝為 <code>C:\\Program Files (x86)\\Microsoft Endpoint Manager\\AdminConsole\\bin\\Microsoft.ConfigurationManagement.exe</code>。 若要建立此檔案的規則，請將此參數 <code>Microsoft.ConfigurationManagement.exe</code> 設定為 ，並將 <strong>Path</strong> 參數設定為 <code>%ProgramFiles(x86)%\\Microsoft Endpoint Manager\\AdminConsole\\bin</code>。</p>\n","isRequired":true,"name":"FileName","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</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>新增此參數，表示此檔案與64位系統上的32位應用程式相關聯。</p>\n","name":"Is64Bit","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>指定檔案系統中指出應用程式存在的檔案路徑。 使用 <strong>FileName</strong> 參數來指定檔名。</p>\n<p>例如，Configuration Manager 控制台預設會安裝為 <code>C:\\Program Files (x86)\\Microsoft Endpoint Manager\\AdminConsole\\bin\\Microsoft.ConfigurationManagement.exe</code>。 若要建立此檔案的規則，請將此參數 <code>%ProgramFiles(x86)%\\Microsoft Endpoint Manager\\AdminConsole\\bin</code> 設定為 ，並將 <strong>FileName</strong> 參數設定為 <code>Microsoft.ConfigurationManagement.exe</code>。</p>\n","isRequired":true,"name":"Path","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">String</span>\n"},{"aliases":"","defaultValue":"None","description":"<p>當您新增 <strong>Value</strong> 參數時，請搭配 <strong>ExpressionOperator</strong> 和 <strong>ExpectedValue</strong> 使用 <strong>PropertyType</strong>。 當您使用這些參數時，檔案必須滿足規則，以指出此應用程式是否存在。 這個 <strong>PropertyType</strong> 參數會指定要評估的檔案屬性。</p>\n<p>例如，您將此參數設定為 <code>Version</code>，將 <strong>ExpressionOperator</strong> 設定為 <code>IsEquals</code>，並將 <strong>ExpectedValue 設定</strong> 為 <code>1.48.1.0</code>。 規則接著會檢查指定的檔案是否具有相同的檔案版本。</p>\n","isRequired":true,"name":"PropertyType","parameterValueGroup":"DateCreated, DateModified, Version, Size","position":"Named","type":"<span class=\"no-loc xref\">FileFolderProperty</span>\n"},{"aliases":"ValueRule","defaultValue":"None","description":"<p>當您新增 <strong>Value</strong> 參數時，檔案必須滿足規則，以指出此應用程式是否存在。 使用此參數搭配下列參數： <strong>ExpectedValue</strong>、 <strong>ExpressionOperator</strong> 和 <strong>PropertyType</strong>。</p>\n<p>若只要檢查檔案是否存在，請使用 <strong>Existence</strong> 參數，而不是評估規則。</p>\n","isRequired":true,"name":"Value","parameterValueGroup":"","position":"Named","type":"<span class=\"no-loc xref\">SwitchParameter</span>\n"}],"schema":"PowershellCmdlet","summary":"<p>建立檔案的偵測方法子句。</p>\n","syntaxes":["New-CMDetectionClauseFile -FileName <String> -PropertyType <FileFolderProperty> -ExpectedValue <String[]>\n -ExpressionOperator <FileFolderRuleExpressionOperator> [-Is64Bit] -Path <String> [-Value]\n [-DisableWildcardHandling] [-ForceWildcardHandling] [<CommonParameters>]","New-CMDetectionClauseFile -FileName <String> [-Is64Bit] -Path <String> [-Existence] [-DisableWildcardHandling]\n [-ForceWildcardHandling] [<CommonParameters>]"],"uid":"ConfigurationManager.New-CMDetectionClauseFile","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-CMDetectionClauseFile.md","xrefs":[{"href":"https://learn.microsoft.com/powershell/module/configurationmanager/new-cmdetectionclausefile","monikerGroup":"f98fea35b6ac2b0f56c6ee5ec06ffce9","name":"New-CMDetectionClauseFile","schemaType":"PowershellCmdlet","summary":"<p>建立檔案的偵測方法子句。</p>\n","uid":"ConfigurationManager.New-CMDetectionClauseFile"}],"canonical_url":"https://learn.microsoft.com/zh-tw/powershell/module/configurationmanager/new-cmdetectionclausefile?view=sccm-ps","_op_canonicalUrl":"https://learn.microsoft.com/zh-tw/powershell/module/configurationmanager/new-cmdetectionclausefile?view=sccm-ps"},"pageMetadata":"<meta name=\"description\" content=\"<p>使用此 Cmdlet 在應用程式的偵測方法中建立 子句。 這個子句是指出應用程式存在的檔案規則。</p>\n<p>若要偵測資料夾而非檔案，請使用 <a href=&quot;new-cmdetectionclausedirectory&quot;>New-CMDetectionClauseDirectory Cmdlet</a> 。</p>\n<p>使用此 Cmdlet 之後，請針對部署類型使用其中一個 <strong>Add-</strong> 或 <strong>Set-</strong> Cmdlet。 將此偵測子句對象傳遞至 <strong>AddDetectionClause</strong> 或 <strong>RemoveDetectionClause</strong> 參數。</p>\n<p>若要將偵測子句分組，請在部署類型 Cmdlet 上使用 <strong>GroupDetectionClauses</strong> 參數。</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-CMDetectionClauseFile.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-CMDetectionClauseFile\" />\r\n<meta name=\"notes\" content=\"\" />\r\n<meta name=\"schema\" content=\"PowershellCmdlet\" />\r\n<meta name=\"summary\" content=\"<p>建立檔案的偵測方法子句。</p>\n\" />\r\n<meta name=\"syntaxes\" content=\"New-CMDetectionClauseFile -FileName <String> -PropertyType <FileFolderProperty> -ExpectedValue <String[]>\n -ExpressionOperator <FileFolderRuleExpressionOperator> [-Is64Bit] -Path <String> [-Value]\n [-DisableWildcardHandling] [-ForceWildcardHandling] [<CommonParameters>]\" />\r\n<meta name=\"syntaxes\" content=\"New-CMDetectionClauseFile -FileName <String> [-Is64Bit] -Path <String> [-Existence] [-DisableWildcardHandling]\n [-ForceWildcardHandling] [<CommonParameters>]\" />\r\n<meta name=\"uid\" content=\"ConfigurationManager.New-CMDetectionClauseFile\" />\r\n","themesRelativePathToOutputRoot":"_themes/"}