Wait-Debugger
스크립트에서 다음 문을 실행하기 전에 디버거에서 스크립트를 중지합니다.
Wait-Debugger []
Wait-Debugger
cmdlet 직후 지점에서 PowerShell 스크립트 실행 엔진을 중지하고 디버거가 연결될 때까지 기다립니다. 이는 DSC 리소스에서 Enable-RunspaceDebug -BreakAll
사용하는 것과 비슷하지만 스크립트의 특정 지점에서 중단됩니다.
주의
작업이 완료되면 Wait-Debugger
줄을 제거해야 합니다. 실행 중인 스크립트는 Wait-Debugger
중지될 때 중단된 것처럼 보입니다.
[DscResource()]
class FileResource
{
[DscProperty(Key)]
[string] $Path
[DscProperty(Mandatory)]
[Ensure] $Ensure
[DscProperty(Mandatory)]
[string] $SourcePath
[DscProperty(NotConfigurable)]
[Nullable[datetime]] $CreationTime
[void] Set()
{
$fileExists = $this.TestFilePath($this.Path)
if ($this.ensure -eq [Ensure]::Present)
{
if (! $fileExists)
{
$this.CopyFile()
}
}
else
{
if ($fileExists)
{
Write-Verbose -Message "Deleting the file $($this.Path)"
Remove-Item -LiteralPath $this.Path -Force
}
}
}
[bool] Test()
{
$present = Test-Path -LiteralPath $this.Path
if ($this.Ensure -eq [Ensure]::Present)
{
return $present
}
else
{
return (! $present)
}
}
[FileResource] Get()
{
$present = Test-Path -Path $this.Path
if ($present)
{
$file = Get-ChildItem -LiteralPath $this.Path
$this.CreationTime = $file.CreationTime
$this.Ensure = [Ensure]::Present
}
else
{
$this.CreationTime = $null
$this.Ensure = [Ensure]::Absent
}
return $this
}
[void] CopyFile()
{
# Testing only - Remove before deployment!
Wait-Debugger
if (! (Test-Path -LiteralPath $this.SourcePath))
{
throw "SourcePath $($this.SourcePath) is not found."
}
if (Test-Path -LiteralPath $this.Path -PathType Container)
{
throw "Path $($this.Path) is a directory path"
}
Write-Verbose "Copying $($this.SourcePath) to $($this.Path)"
Copy-Item -LiteralPath $this.SourcePath -Destination $this.Path -Force
}
}
None
개체를 이 cmdlet으로 파이프할 수 없습니다.
None
이 cmdlet은 출력을 반환하지 않습니다.