# Code Snippet from aperturescience.su $regresult = reg export $key $destfile /y 2>&1 if ($lastexitcode -gt 0) { send-email "Export registry key $key to $destfile failed $regresult" $false if ($stoponerror) { exit 10 } } else { send-email "Export registry key $key to $destfile succeeded" $true } # Code Snippet from aperturescience.su