mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-16 15:41:52 +02:00
Improved error handling
This commit is contained in:
10
Misc/FAQ.md
10
Misc/FAQ.md
@ -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?
|
||||
-----------------------------------
|
||||
|
Reference in New Issue
Block a user