Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Formatting output with write-host

Reply
 
Old 09-13-2007   #1 (permalink)
Vedran Matica


 
 

Formatting output with write-host

Hello,


I have a problem using write-host cmdlet.
Here's the line that I'm using to display FQDN of a computer:

write-host "Fully Qualified Domain Name: " $strCompName.ToLower() "."
$strPrimaryDomain`n

And I receive:
Fully Qualified Domain Name: xp-comp . test.local

I want to avoid space between computername, dot and a domain name.

How can I achieve it? I realize that ampersand is not required to
concatenate items in PS.

Thanks a lot in advance.

BR,
Vedran



My System SpecsSystem Spec
Old 09-13-2007   #2 (permalink)
Brandon Shell


 
 

Re: Formatting output with write-host

Try this
write-host "Fully Qualified Domain Name:
$($strCompName.ToLower()).$($strPrimaryDomain)"
or
write-host ("Fully Qualified Domain Name: {0}.{1}" -f
$strCompName.ToLower(),$strPrimaryDomain)

"Vedran Matica" <vedran.maticaREMOVE_THIS@xxxxxx-com.hr> wrote in message
news:exOwiWk9HHA.980@xxxxxx
Quote:

> Hello,
>
>
> I have a problem using write-host cmdlet.
> Here's the line that I'm using to display FQDN of a computer:
>
> write-host "Fully Qualified Domain Name: " $strCompName.ToLower() "."
> $strPrimaryDomain`n
>
> And I receive:
> Fully Qualified Domain Name: xp-comp . test.local
>
> I want to avoid space between computername, dot and a domain name.
>
> How can I achieve it? I realize that ampersand is not required to
> concatenate items in PS.
>
> Thanks a lot in advance.
>
> BR,
> Vedran
>
My System SpecsSystem Spec
Old 09-13-2007   #3 (permalink)
Kiron


 
 

Re: Formatting output with write-host

Try:

write-host "Fully Qualified Domain Name:
$($strCompName.ToLower()).$strPrimaryDomain`n"

--
Kiron

My System SpecsSystem Spec
Old 09-13-2007   #4 (permalink)
Vedran Matica


 
 

Re: Formatting output with write-host

I have just realized that I can use -separator parameter with an empty
string. :-)


Quote:

> Hello,
>
>
> I have a problem using write-host cmdlet.
> Here's the line that I'm using to display FQDN of a computer:
>
> write-host "Fully Qualified Domain Name: " $strCompName.ToLower() "."
> $strPrimaryDomain`n
>
> And I receive:
> Fully Qualified Domain Name: xp-comp . test.local
>
> I want to avoid space between computername, dot and a domain name.
>
> How can I achieve it? I realize that ampersand is not required to
> concatenate items in PS.
>
> Thanks a lot in advance.
>
> BR,
> Vedran
>

My System SpecsSystem Spec
Old 09-13-2007   #5 (permalink)
Vedran Matica


 
 

Re: Formatting output with write-host

Guys, thanks. You have a really good response time. :-)

And the best thing is that the same thing can be accomplished in various
ways.


Vedran


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Formatting output PowerShell
Formatting output PowerShell
formatting AD output PowerShell
Formatting HTML output possible? PowerShell
get-help output formatting bug PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46