Improved error handling

This commit is contained in:
Markus Fleschutz
2021-02-16 10:03:20 +01:00
parent 05d3c4e6fc
commit cda05d0c9b
108 changed files with 116 additions and 116 deletions

View File

@ -68,15 +68,15 @@ How to write good PowerShell Scripts?
Each PowerShell script should follow the 10 golden rules:
1. the filename should be named `<verb>-<object>.ps1`
2. the first line reads `#!/bin/powershell` to support PowerShell on Linux
3. the script has execute file permissions (chmod a+rx <file>) to support PowerShell on Linux
2. the first line reads `#!/bin/powershell` (to support Linux)
3. the script has execute file permissions: chmod a+rx <file> (to support Linux)
4. provide a comment-based help with syntax, description, link, author, and license
5. check the requirements (e.g. #Requires -RunAsAdministrator, or #Requires -Version 3)
6. prefer command-line options, else ask the user
7. use `Set-StrictMode -Version Latest` to enable additional error checking
7. recommended is `Set-StrictMode -Version Latest` to enable additional error checking
8. for readibility use UpperCamelCase for variables and functions, lowerCamelCase for everything else
9. on error call write-error with keyword "ERROR:" (required by log parser) and exit the error code (mostly 1)
10. on success call write-host -foregroundColor green with keyword "DONE" and call exit 0
9. on error call write-error with keyword "ERROR:" (to support log parsers) and exit the error code (mostly 1)
10. on success exit with error code 0 (exit 0)
Your Question is not answered here?
-----------------------------------