external help file | Module Name | online version | schema |
---|---|---|---|
PSScriptTools-help.xml |
PSScriptTools |
2.0.0 |
Write a detailed message string.
Write-Detail [[-Message] <String>] [-Prefix <String>] [<CommonParameters>]
Write-Detail [[-Message] <String>] [-Prefix <String>] [-Time]
[<CommonParameters>]
Write-Detail [[-Message] <String>] [-Prefix <String>] [-Date]
[<CommonParameters>]
This command is designed to be used within your functions and scripts to make it easier to write a detailed message that you can use as verbose output. The assumption is that you are using an advanced function with a Begin, Process and End scriptblocks. You can create a detailed message to indicate what part of the code is being executed. The output can include a full time stamp, or a time string which includes a millisecond value.
In a script you might use it like this in a Begin block:
$pfx = "BEGIN"
Write-Detail "Starting $($MyInvocation.MyCommand)" -Prefix $pfx | Write-Verbose
Write-Detail "PS $($PSVersiontable.PSVersion)" -Prefix $pfx | Write-Verbose
If you don't specify a prefix, it will default to PROCESS.
PS C:\> Write-Detail "Getting file information" -Prefix Process
[PROCESS] Getting file information
Normally you would use this command in a function, but here is an example from the console so that you can see what to expect.
The message to display after the time stamp and prefix.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Indicate whether you are in the BEGIN, PROCESS or END script block. Although you can specify any text. It will be displayed in upper case.
Type: String
Parameter Sets: (All)
Aliases:
Accepted values:
Required: False
Position: Named
Default value: PROCESS
Accept pipeline input: False
Accept wildcard characters: False
Display a date value like 9/15/2018 11:36:41.
Type: SwitchParameter
Parameter Sets: Date
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Display a time value with milliseconds like 11:37:01:4029.
Type: SwitchParameter
Parameter Sets: Time
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/