Questions tagged [write-host]
66 questions
2
votes
1 answer
Run a command in middle of Write-Host
I have a write-host line that I want to execute a command in the middle of, so the output will be inserted in the middle of the write-host string.
Basically I have a txt file that holds configuration data for a suite of scripts, one of the…

Ken
- 125
- 1
- 12
2
votes
1 answer
Output file doesn't match Write-Host
When I Write-Host from my .ps1 file I see:
Parentfolder >> ChildFolder
When I output to a file, I see:
ParentFolder
>>
ChildFolder
I am using a simple write-host ($childgroup.name), ">>", ($object.samaccountname)
When I try to output the same…

Stephen-HHC
- 23
- 4
2
votes
2 answers
Write-Host and Log on one line?
I'm very new to PowerShell, and self-teaching myself it at that. My question is can you have 'write-host' and 'log-write' on the same line, to run as one action?
What I have is this:
Write-Host "Node Id is $nodeProps["NodeID"]"
LogWrite "Node Id…

Spence Rico
- 23
- 1
- 3
1
vote
2 answers
using Write-host multiple times
I am trying to write a Powershell script that will use the Write-Host commands a couple of times. when i run the script i get the output of the Write-host and then the output from the commands themselves. I've looked and Googled this issue but no…

Murray Mint
- 11
- 1
1
vote
2 answers
Powershell: How to export AD PC results to CSV
newbie question here.
I have this script below for powershell that gives me the PC information from AD.
but i've been having trouble exporting the results to csv.
also how do just get the ipv4 ip address and dont include ipv6?
and say if the PC is…

Renil
- 11
- 1
1
vote
0 answers
No output in PowerShell Plugin of Jenkins
I'm using the Jenkins Plugin (not pipeline) Windows Powershell for my scripts. Everything is fine, if the script is written directly into the Command-Window.
But for some more complex operations I'm using a .ps1-File located on my SCM, since all…

MarcoB
- 51
- 2
- 6
1
vote
1 answer
Piping output from Write-Host to other command
I have this script that finds files based on certain cafeterias and write their path using Write-Host. Now, I would like to pipe all of these file paths, and do stuff with those files.
Basically the first script is like…

Peter Poulsen
- 440
- 4
- 11
1
vote
0 answers
Powershell problematic without working code changes
I have several points of working code that now no longer works. Here is a block of code:
if ($day -eq 01) {
echo "The Day of Days" }
else {
echo "Not Today" }
I get the following result:
At D:\PS_Scripts\Archive-Log.ps1:88 char:15
+ …

roachd
- 11
- 2
1
vote
2 answers
Function with String Message, echos to screen, change the color of message
Good Morning all,
SOLVED
Both responses worked hand in hand. Big Thanks to Scepticalist and Wasif Hasan for the examples!!
I have a logging function that has a message parameter. Through the function it writes the message with a text color of green.…

Fitzgery
- 558
- 5
- 14
1
vote
2 answers
PowerShell switch parameter doesn't work as expected
I have the following PowerShell function to help me do benchmarks. The idea is that you provide the command and a number and the function will run the code that number of times. After that the function will report the testing result, such as Min,…

Just a learner
- 26,690
- 50
- 155
- 234
1
vote
1 answer
"$xyz" and "Write-Host "$xyz"" giving different output
I am hashing all the files in one location, an origin folder, and writing the hashes to a variable and then doing the same to all the files in another location, a destination folder:
$origin = Get-ChildItem .\Test1 | Get-FileHash | Format-Table…

Ken
- 125
- 1
- 12
1
vote
1 answer
Remove space between objects when using Write-Host
I have a text file that has something like this:
Year= YYYY
Month= MM
I then read the file in, select the line I want, split the line so I only get what is to the right of the "=" sign, trim blank spaces, and put it all into a variable with this…

Ken
- 125
- 1
- 12
1
vote
2 answers
Trying to test code, keep getting "System.____comobject" instead of variable value
I'm trying to write a small powershell script that does a few things
1) Parses Inbox items in my outlook
2) Searches for a RegEx string
3) Dumps the line that matches the RegEx string into a CSV
I can't get #3 to work. It definitely runs for about…

Ghawblin
- 71
- 2
- 17
1
vote
1 answer
How to filter an object of devices to a single one based on hostname in powershell?
I'm trying to get the sitename of a device by using the hostname of a single device from an object that contains the details of 100's of devices in Powershell. How do I filter it?
The data is originally from an API and is being pulled in as Json,…

Weighsone
- 103
- 1
- 10
1
vote
2 answers
Powershell : Write host to current directory/$computername
I'm trying to output a CSV in the current directory, but in a folder that matches the $ComputerName, which already exists. I'm doing this for a list of machines regularly and rather than manually put them in their folder it would be awesome to do it…

Indigo
- 21
- 2