共用方式為


封存

概要

展開或移除封存 () .zip 檔案的內容。

語法

Archive [String] #ResourceName
{
    Destination = [string]
    Path = [string]
    [Checksum = [string]{ CreatedDate | ModifiedDate | SHA-1 | SHA-256 | SHA-512 }]
    [Credential = [PSCredential]]
    [DependsOn = [string[]]]
    [Ensure = [string]{ Absent | Present }]
    [Force = [bool]]
    [PsDscRunAsCredential = [PSCredential]]
    [Validate = [bool]]
}

描述

資源 Archive 可讓您以等冪方式管理封存 () .zip 檔案的擴充內容。 它可以確保封存的擴充內容是最新的,或從系統移除。

規格需求

  • 電腦必須提供 System.IO.Compression 類型元件。
  • 電腦上必須提供 System.IO.Compression.FileSystem 類型元件。

金鑰屬性

Destination

指定展開內容應寫入或移除的資料夾路徑。

Type: System.String

路徑

指定封存檔案的路徑。

Type: System.String

選擇性屬性

總和檢查碼

指定驗證封存擴充內容時要使用的總和檢查碼方法。 如果您指定 ChecksumValidate as $false 的值,則資源會擲回不正確引數例外狀況。

如果您將 Validate 指定為 $true則總和檢查碼 的預設值為 ModifiedDate

注意

使用 總和檢查碼驗證 表示另一個檢查碼。 雖然您可以指定沒有總和檢查碼的驗證,但最佳做法是同時指定這兩者。

指定的方法會決定資源如何根據封存驗證展開的內容:

  • 使用 ModifiedDate 時,資源會檢查每個展開檔案的 LastWriteTime 屬性是否符合封存中該檔案的 LastWriteTime 屬性。
  • 使用 CreatedDate 時,資源會檢查每個展開檔案的 CreationTime 屬性是否符合封存中該檔案的 CreationTime 屬性。
  • 使用 SHA-1SHA-256SHA-512 時,資源會使用指定的 SHA 方法,根據封存中該檔案的雜湊來驗證每個展開檔案的雜湊。
Type: System.String
Accepted Values:
  - ModifiedDate
  - CreatedDate
  - SHA-1
  - SHA-256
  - SHA-512
Default Value: ModifiedDate

認證

視需要指定具有存取指定 路徑目的地 許可權的使用者帳號憑證。

Type: System.Management.Automation.PSCredential
Default Value: None

Ensure

指定封存檔案的展開內容是否應該存在。 若要展開封存,請將此屬性指定為 Present 。 若要移除封存的展開內容,請將此屬性指定為 Absent 。 預設值是 Present

Type: System.String
Accepted Values:
  - Absent
  - Present
Default Value: Present

Force

指定是否要覆寫 目的地中的現有內容。 當 Force$false 時,如果目的地的專案需要覆寫,資源就會發生錯誤。 預設值是 $false

Type: System.Boolean
Default Value: false

Validate

指定是否要透過指定的總和檢查碼方法來驗證展開的內容。 預設值是 $false

當 Validate$true 且目的地的檔案不符合封存中的檔案時:

  • 如果 確定PresentForce$false ,則資源錯誤,並顯示目的地檔案無法覆寫的訊息。
  • 如果 [確定 ] 為 Present ,且 Force$true ,則資源會覆寫檔案。
  • 如果 [確定 ] 為 Absent ,則資源不會移除檔案。
Type: System.Boolean
Default Value: false

範例