Checking network connection...completed.
Checking file...completed.
Writing network information to file...completed.
This bugged me to no end; so I wrote the “Write-NoteStart” function to make it easier for me to sleep at night. When using this function the output looks more like this:
Checking network connection.............completed.
Checking file...........................completed.
Writing network information to file.....completed.
Here is the function:
function Write-NoteStart { <# .SYNOPSIS This function will place periods after writing a string and not write a new line. .DESCRIPTION This script is used to produce dots/periods after a given string for aligning results. You can adjust the position it should add dots up to. .EXAMPLE Write-NoteStart "Checking status" -DotTo 40 Write-Host "completed." Write-NoteStart "Checking your connection" -DotTo 40 Write-Host "completed." ----------------------------------------------------------- This would produce: Checking status.........................completed. Checking your connection................completed. .INPUTS A string and an int. .OUTPUTS Write-Host to the screen with your string followed by periods. .NOTES Original Function name: Write-NoteStart.ps1 Original Author: Norman Skinner Original Created on: 02/01/2012 Version: 1.0.0.0 #> param ( [string] # The string for the start of the line. $Note = "No data", [int] # What line position to run dots to. $DotTo = 60 ) if ($Note.Length -lt $DotTo) { Write-Host $Note -NoNewline for ($i = $Note.Length;$i -lt $DotTo; $i++) { Write-Host "." -NoNewline } } else { Write-Host $Note } }
No comments:
Post a Comment