mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 17:37:40 +00:00
11 lines
510 B
PowerShell
11 lines
510 B
PowerShell
function Write-WindowsLifecycleReceipt([hashtable]$Report,[string]$Receipt) {
|
|
try {
|
|
$bytes=[Text.UTF8Encoding]::new($false).GetBytes(($Report | ConvertTo-Json -Depth 6))
|
|
$temporary="$Receipt.pending"
|
|
$stream=[IO.FileStream]::new($temporary,[IO.FileMode]::Create,[IO.FileAccess]::Write,[IO.FileShare]::Read)
|
|
try {$stream.Write($bytes,0,$bytes.Length);$stream.Flush($true)} finally {$stream.Dispose()}
|
|
[IO.File]::Move($temporary,$Receipt,$true)
|
|
return $true
|
|
} catch {return $false}
|
|
}
|