randle Posted March 4, 2015 Posted March 4, 2015 Hi, A very simply answer I'm sure but can I find it anywhere?....... I want the console output of a PowerShell script to have a blank line between each command so not to look like one clump of text. Am I missing the obvious other than adding a line with just "write-host"? I know I can use different colours for text but would still prefer a space.
halbaradkenafin Posted March 4, 2015 Posted March 4, 2015 If it's a script you've created yourself and are using Write-Host or Write-Output to put messages on the console then adding `n (backtick then n) to the end of each string which you're outputting should do it, if not then you can just put `n`n and that should work.
randle Posted March 4, 2015 Author Posted March 4, 2015 Thanks for that. I did see this syntax on my searches but wasn't sure it was what I wanted but does look to do the job thanks however, the write-host line I'm tying to manipulate follows a Get-Service cmdlet so need the blank line before the write-host command. Adding `n at the beginning or on a line above doesn't work and can't add this to the end of the Get-Service cmdlet either.
halbaradkenafin Posted March 4, 2015 Posted March 4, 2015 Thanks for that. I did see this syntax on my searches but wasn't sure it was what I wanted but does look to do the job thanks however, the write-host line I'm tying to manipulate follows a Get-Service cmdlet so need the blank line before the write-host command. Adding `n at the beginning or on a line above doesn't work and can't add this to the end of the Get-Service cmdlet either. Can you post the code you've got?
randle Posted March 4, 2015 Author Posted March 4, 2015 Get-Service -DisplayName RM* -ComputerName $Computername | sort-object status Write-Host -ForegroundColor Cyan "RM Service Host Service restarted on $Computername"
halbaradkenafin Posted March 4, 2015 Posted March 4, 2015 Get-Service -DisplayName RM* -ComputerName $Computername | sort-object status Write-Host -ForegroundColor Cyan "RM Service Host Service restarted on $Computername" Just tested this and it works on my rdp machine running powershell 3. Write-Host" `n RM Service Host Service restarted on $Computername" 1
randle Posted March 4, 2015 Author Posted March 4, 2015 Ah!! I was adding it at the end of the line of last command or before the "Write-Host....". Didn't realise it was meant to go before the actual output but makes sense now. Thanks for your help with this
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now