Skip to content

Instantly share code, notes, and snippets.

@MyITGuy
Created September 17, 2019 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MyITGuy/a6d1e636fe48b4f56c308d75ca88a171 to your computer and use it in GitHub Desktop.
Save MyITGuy/a6d1e636fe48b4f56c308d75ca88a171 to your computer and use it in GitHub Desktop.
# Demonstates Write-Output writing blank lines in the console
# This is visible with Write-Host and Write-Verbose
1..3 | ForEach-Object {
$Properties = @{
Name = "Iteration" + $_
}
$obj = New-Object -TypeName psobject -Property $Properties
if ($_ -eq 1) {
Write-Host "↓↓ [$($Properties.Name)] Write-Output writes blank line(s) for first object due to writing header row(s) ↓↓"
}
else {
Write-Host "↓↓ [$($Properties.Name)] No blank line(s) written ↓↓"
}
Write-Output -InputObject $obj
if ($_ -eq 1) {
Write-Host "↑↑ [$($Properties.Name)] Write-Output writes blank line(s) for first object due to writing header row(s) ↑↑"
}
else {
Write-Host "↑↑ [$($Properties.Name)] No blank line(s) written ↑↑"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment