New-FileCatalog
建立 Windows 目錄檔案,其中包含指定路徑中檔案和資料夾的密碼編譯哈希。
語法
New-FileCatalog
[-CatalogVersion <Int32>]
[-CatalogFilePath] <String>
[[-Path] <String[]>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
此 Cmdlet 只能在 Windows 平臺上使用。
New-FileCatalog
會為一組資料夾和檔案建立 Windows 目錄檔案。 此目錄檔案包含所提供路徑中所有檔案的哈希。 然後,使用者可以將目錄與其檔案一起散發,讓使用者可以驗證自目錄建立時間以來是否已對資料夾進行任何變更。
支援類別目錄版本 1 和 2。 第 1 版會使用 (已淘汰) SHA1 哈希演算法來建立檔案哈希,而第 2 版則使用 SHA256。
範例
範例 1:建立 'Microsoft.PowerShell.Utility' 的檔案目錄
$newFileCatalogSplat = @{
Path = "$PSHOME\Modules\Microsoft.PowerShell.Utility"
CatalogFilePath = '\temp\Microsoft.PowerShell.Utility.cat'
CatalogVersion = 2.0
}
New-FileCatalog @newFileCatalogSplat
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/2/2018 11:58 AM 950 Microsoft.PowerShell.Utility.cat
參數
-CatalogFilePath
您要建立目錄檔案的位置和名稱(.cat
)。 如果您只指定資料夾路徑,命令會在該位置建立名為 catalog.cat
的檔案。
類型: | String |
Position: | 0 |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-CatalogVersion
接受 1.0
或 2.0
指定目錄版本的可能值。 應盡可能避免 1.0
,因為它使用不安全的SHA-1哈希演算法。 版本 2.0
使用安全的SHA-256演算法。
類型: | Int32 |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
類型: | SwitchParameter |
別名: | cf |
Position: | Named |
預設值: | False |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Path
接受目錄檔案中應包含之檔案或資料夾的路徑或路徑陣列。 如果指定資料夾,命令就會包含資料夾中的所有檔案。
類型: | String[] |
Position: | 1 |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 Cmdlet 未執行。
類型: | SwitchParameter |
別名: | wi |
Position: | Named |
預設值: | False |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
輸入
您可以使用管線將做為目錄檔名的字串傳送至此 Cmdlet。
輸出
此 Cmdlet 會傳回代表所建立目錄的 FileInfo 物件。
備註
此 Cmdlet 僅適用於 Windows 平臺。