Set-AIPFileClassification
根據原則中設定的條件掃描檔案,為檔案自動設定 Azure 資訊保護標籤。
Syntax
Set-AIPFileClassification
[-JustificationMessage <String>]
[-Force]
[-PreserveFileDetails]
[-Path] <String[]>
[<CommonParameters>]
Set-AIPFileClassification
[-JustificationMessage <String>]
[-Force]
[-WhatIf]
[-DiscoveryInfoTypes <String[]>]
[-Path] <String[]>
[<CommonParameters>]
Description
當您設定標籤進行自動分類時 ,Set-AIPFileClassification Cmdlet 可以自動套用一或多個檔案的標籤。
執行此 Cmdlet 時,它會檢查檔案內容,以及是否已針對標籤符合設定的條件,就會套用該標籤。 如果選取的標籤套用保護,此動作會自動套用保護。
根據預設,如果檔案已經有標籤,則不會取代現有的標籤或保護。
當檔案因為手動加上標籤而未加上標籤時,與您指定的條件沒有相符,或檔案具有較高的分類,則會略過檔案,並加上「不套用標籤」的單一批註。
如需詳細資訊,請參閱: 自動將敏感度標籤套用至內容
以非互動方式執行 Cmdlet
您可以非互動方式執行此 Cmdlet。 如需詳細資訊,請參閱 統一標籤用戶端系統管理員指南。
範例
範例 1︰掃描資料夾中的所有檔案及其所有子資料夾,並根據針對自動分類設定的條件來套用標籤
PS C:\> Set-AIPFileClassification -Path C:\Projects\ -PreserveFileDetails
FileName : C:\Projects\Project1.docx
Status : Success
Comment :
MainLabelName : Confidential
MainLabelId : 074e257c-1234-1234-1234-34a182080e71
SubLabelName : Finance group
SubLabelId : d9f23ae3-1234-1234-1234-f515f824c57b
FileName : C:\Projects\Datasheet.pdf
Status : Skipped
Comment : No label to apply
MainLabelName :
MainLabelId :
SubLabelName :
SubLabelId :
FileName : C:\Projects\Analysis.xlsx
Status : Skipped
Comment : No label to apply
MainLabelName :
MainLabelId :
SubLabelName :
SubLabelId :
FileName : C:\Projects\Pricelist.xlsx
Status : Skipped
Comment : No label to apply
MainLabelName :
MainLabelId :
SubLabelName :
SubLabelId :
FileName : C:\Projects\Dashboard.xlsx
Status : Success
Comment :
MainLabelName : Public
MainLabelId : f018e9e7-0cfc-4c69-b27a-ac3cb7df43cc
SubLabelName :
SubLabelId :
此命令會掃描 Projects 資料夾及其任何子資料夾中的所有檔案,並根據自動套用標籤原則中設定的條件來設定標籤。 在此範例中,有五個檔案和兩個檔案會自動加上標籤。 Datasheet.pdf檔案未加上標籤,因為其內容不符合已設定的自動分類條件,Analysis.xlsx已經手動加上標籤,而且Pricelist.xlsx有較高的標籤。 因為命令是在不使用 -Force 參數的情況下執行, 所以不會 覆寫Analysis.xlsx和 Pricelist.xlsx 的現有標籤。
如果套用的標籤也設定為套用 Rights Management 保護,則成功使用此命令加上標籤的檔案也會受到保護。 在此情況下,這些檔案的 Rights Management 擁有者 (具有 Rights Management 完整控制權限的人員) 就是執行 PowerShell 命令的使用者。
由於已指定 PreserveFileDetails 參數,因此已標記檔案的 Date Modified 會保持不變。
範例 2︰掃描資料夾中的所有檔案及其所有子資料夾,並根據針對自動分類設定的條件來套用標籤,而且會覆寫任何現有的標籤
PS C:\> Set-AIPFileClassification -Path C:\Projects\ -Force -PreserveFileDetails
FileName : C:\Projects\Project1.docx
Status : Success
Comment :
MainLabelName : Confidential
MainLabelId : 074e257c-1234-1234-1234-34a182080e71
SubLabelName : Finance group
SubLabelId : d9f23ae3-1234-1234-1234-f515f824c57b
FileName : C:\Projects\Datasheet.pdf
Status : Skipped
Comment : No label to apply
MainLabelName :
MainLabelId :
SubLabelName :
SubLabelId :
FileName : C:\Projects\Analysis.xlsx
Status : Success
Comment :
MainLabelName : Public
MainLabelId : f018e9e7-0cfc-4c69-b27a-ac3cb7df43cc
SubLabelName :
SubLabelId :
FileName : C:\Projects\Pricelist.xlsx
Status : Success
Comment :
MainLabelName : Public
MainLabelId : f018e9e7-0cfc-4c69-b27a-ac3cb7df43cc
SubLabelName :
SubLabelId :
FileName : C:\Projects\Dashboard.xlsx
Status : Success
Comment :
MainLabelName : Public
MainLabelId : f018e9e7-0cfc-4c69-b27a-ac3cb7df43cc
SubLabelName :
SubLabelId :
此命令類似于上述範例,因為它也會掃描 Projects 資料夾中的所有檔案及其任何子資料夾,並根據自動套用標籤的設定條件來設定標籤。 不過,這次,因為命令包含 -Force 參數,所以也會取代 Dashboard.xlsx的現有標籤,並 Pricelist.xlsx。
Datasheet.pdf的內容不符合任何已設定的條件,而且此檔案會保留在沒有標籤的情況下。
範例 3: (統一標籤用戶端只會) 在 WhatIf 模式中掃描所有已知敏感性資訊類型的檔案
PS C:\> Set-AIPFileClassification -Path C:\Projects\Project1.docx -WhatIf -DiscoveryInfoTypes All
MainLabelName : General
MainLabelId : 89a453df-5df4-4976-8191-jdn2fsf9560a
SubLabelName :
SubLabelId :
WhatIf : True
MatchedInformationTypes : {Credit Card Number, U.S. Social Security Number (SSN), International Classification of
Diseases (ICD-10-CM), International Classification of Diseases (ICD-9-CM)}
LastModifiedBy :
LastModifiedTime : 8/19/2014 5:11:26 AM
FileName : C:\Projects\Project1.docx
Status : Success
Comment :
此命令會探索Project1.docx檔案中的所有已知資訊類型,而不套用保護或標籤。
範例 4: (統一標籤用戶端只會) 在 WhatIf 模式中掃描特定敏感性資訊類型的檔案
PS C:\> Set-AIPFileClassification -Path C:\Projects\Project1.docx -WhatIf -DiscoveryInfoTypes "50842eb7-edc8-4019-85dd-5a5c1f2bb085","a44669fe-0d48-453d-a9b1-2cc83f2cba77"
MainLabelName : General
MainLabelId : 89a453df-5df4-4976-8191-jdn2fsf9560a
SubLabelName :
SubLabelId :
WhatIf : True
MatchedInformationTypes : {Credit Card Number, U.S. Social Security Number (SSN)}
LastModifiedBy :
LastModifiedTime : 8/19/2014 5:11:26 AM
FileName : Project1.docx
Status : Success
Comment :
此命令會探索 Project1.docx 檔案中「信用卡號碼」和「社會安全號碼 (SSN) 」的特定資訊類型,而不需要套用保護或標籤。
範例 5: (統一標籤用戶端只會) 在 WhatIf 模式中掃描特定敏感性資訊類型的檔案,並顯示找到的值
PS C:\> $x=Set-AIPFileClassification -Path "C:\Projects\Project1.docx" -WhatIf -DiscoveryInfoTypes "50842eb7-edc8-4019-85dd-5a5c1f2bb085","a44669fe-0d48-453d-a9b1-2cc83f2cba77"
PS C:\> $x.MatchedInformationTypes
RulePackageSetId : 00000000-0000-0000-0000-000000000000
RulePackageId : 00000000-0000-0000-0000-000000000000
RuleId : 50842eb7-edc8-4019-85dd-5a5c1f2bb085
Name : Credit Card Number
Count : 1
UniqueCount : 1
Confidence : 85
SensitiveContents : {Offset: 2089, Length: 19}
RulePackageSetId : 00000000-0000-0000-0000-000000000000
RulePackageId : 00000000-0000-0000-0000-000000000000
RuleId : a44669fe-0d48-453d-a9b1-2cc83f2cba77
Name : U.S. Social Security Number (SSN)
Count : 1
UniqueCount : 1
Confidence : 85
SensitiveContents : {Offset: 7063, Length: 11}
PS C:\> $x.MatchedInformationTypes[0].SensitiveContents | fl
Offset : 2089
Length : 19
Value : 4539-9572-7949-2212
Context : OLOGICAL SCIENCES Credit Card #
Expiration Date: 4539-9572-7949-2212
8/2009 Department: BIOLOGICAL SCIENCES Anticipa
與上一個範例類似,第一個命令會在 Project1.docx 檔案中探索「信用卡號碼」和「社會安全號碼 (SSN) 」的特定資訊類型,而不套用保護或標籤。 不過,在此範例中,結果會儲存在變數中,以便進一步處理。
接著會使用第二個命令來顯示相符資訊類型的內容,其中包含 SensitiveContents 參數。
最後一個命令會顯示 和 格式,以便更容易讀取第一個敏感性資訊類型所識別的資料,在此範例中為信用卡詳細資料。
參數
-DiscoveryInfoTypes
注意:只有 Azure 資訊保護統一標籤用戶端才支援此參數。
指定當您使用 WhatIf 參數時要探索的敏感性資訊類型。
如果您想要搜尋特定的敏感性資訊類型,請指定該資訊類型的實體識別碼號碼,您可以在Exchange Server的敏感性資訊類型中找到。
例如,「50842eb7-edc8-4019-85dd-5a5c1f2bb085」 是要為信用卡號碼敏感性資訊類型指定的數位。
Type: | String[] |
Accepted values: | All, "rule_id_1", "rule_id_2" |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Force
套用設定的條件時,會取代現有的標籤。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-JustificationMessage
降低分類標籤、移除標籤或移除保護的理由原因 (如果 Azure 資訊保護原則要求使用者提供此資訊)。
如果設定標籤會觸發理由,但未提供這個原因,則不會套用標籤,即使已設定 -Force 參數也一樣。 在此情況下,傳回的狀態為「略過」,批註如下:「不套用標籤」
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Path
指定您要取得標籤和保護資訊的檔案的本機路徑、網路路徑或 SharePoint Server URL。
不支援萬用字元和 WebDav 位置。
針對 SharePoint 路徑,支援下列專案:
- SharePoint Server 2019
- SharePoint Server 2016
- SharePoint Server 2013
例如:
- C:\Folder\
- C:\Folder\Filename
- \\Server\Folder
- http://sharepoint.contoso.com/Shared%20Documents/Folder
當您以引號括住路徑值時,路徑可以包含空格。
Type: | String[] |
Aliases: | FullName, FileName |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PreserveFileDetails
指定此參數,以保留您標籤檔未變更的日期。
對於本機或網路檔案,上次修改日期會保持不變。
若為 SharePoint 檔案,[修改日期] 和 [修改日期] 會保持不變。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
與下列專案相關: 僅限統一標籤用戶端
顯示 Cmdlet 執行時會發生什麼情況,而且相當於掃描器的探索模式。 輸入或輸出檔案上不會套用變更。
搭配 DiscoveryInfoTypes 使用此參數來尋找所有敏感性資訊類型或特定敏感性資訊類型。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
輸入
System.String[]
輸出
Microsoft.InformationProtection.Powershell.AIP.Results.SetAIPFileClassificationResult