1. Write-Host
Purpose: Used to display information directly to the console. It does not produce output that can be captured or redirected. Use Case: Primarily for user-facing messages or status updates during script execution. Example : Write-Host "This is a message to the user."
2. Write-Output Purpose: Sends output to the pipeline, which can then be captured, redirected, or used by other commands. If used at the end of a script or function, it becomes the default output.
Use Case: Suitable for returning data from functions or scripts that may be used in further processing.
Example : Write-Output "This output can be captured."
# or simply
"This also outputs to the pipeline."
3. Write-Verbose Purpose: Used for providing additional information that can be toggled on or off based on user preference. This information is helpful for debugging or understanding the flow of a script.
Use Case: Ideal for scripts that need to provide detailed logs without cluttering the standard output.
Example: $VerbosePreference = "Continue" # Set to show verbose messages
Write-Verbose "This is a verbose message for debugging."