파일 유효성 검사 없이 보관 파일 확장
설명
이 예제에서는 리소스를 Archive
사용하여 파일이 특정 디렉터리로 .zip
확장되도록 하는 방법을 보여줍니다.
확인이 설정Present
되고 경로가 설정C:\ExampleArchivePath\Archive.zip
되고 대상이 대상으로 C:\ExampleDestinationPath\Destination
설정되면 리소스는 폴더의 Archive.zip
내용을 아직 없는 경우 폴더로 Destination
확장합니다.
유효성 검사 또는 체크섬 속성이 설정되지 않은 경우 리소스는 파일이 Archive.zip
있는 확장된 내용만 확인하지 않습니다. 폴더의 확장된 콘텐츠가 Destination
.의 내용과 Archive.zip
일치하지 않을 수 있습니다.
Invoke-DscResource
이 스크립트는 cmdlet과 함께 리소스를 Archive
Invoke-DscResource
사용하여 폴더로 확장되도록 하는 Archive.zip
Destination
방법을 보여줍니다.
[CmdletBinding()]
param()
begin {
$SharedParameters = @{
Name = 'Archive'
ModuleName = 'PSDscResource'
Properties = @{
Path = 'C:\ExampleArchivePath\Archive.zip'
Destination = 'C:\ExampleDestinationPath\Destination'
Ensure = 'Present'
}
}
$NonGetProperties = @(
'Ensure'
)
}
process {
$TestResult = Invoke-DscResource -Method Test @SharedParameters
if ($TestResult.InDesiredState) {
$QueryParameters = $SharedParameters.Clone()
foreach ($Property in $NonGetProperties) {
$QueryParameters.Properties.Remove($Property)
}
Invoke-DscResource -Method Get @QueryParameters
} else {
Invoke-DscResource -Method Set @SharedParameters
}
}
구성을 사용하여
이 코드 조각은 리소스 블록을 사용하여 Configuration
Archive
정의하여 폴더로 확장 Destination
되도록 하는 Archive.zip
방법을 보여줍니다.
Configuration ExpandArchiveNoValidation {
Import-DscResource -ModuleName 'PSDscResources'
Node localhost {
Archive ExampleArchive {
Path = 'C:\ExampleArchivePath\Archive.zip'
Destination = 'C:\ExampleDestinationPath\Destination'
Ensure = 'Present'
}
}
}
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.