Questions tagged [write-host]

66 questions
0
votes
1 answer

POWERSHELL: piping exe file output in to variable

I am trying to execute a sript to run exe file, get the output, search through the output and then if its true do soemthing: $output = cmd /c file.exe additionalvariables --batch | write-host | where-object($_ -eq "Finished with…
user5711825
  • 85
  • 1
  • 1
  • 11
0
votes
1 answer

PowerShell log filter function buffering output

My application uses log4cplus for logging. When I launch it in CMD or PowerShell, logging is ok, line by line. I decided to add small filtering function in PS, to make the output colorful. # Simplified version function ColoredOutput { process {…
Werolik
  • 923
  • 1
  • 9
  • 23
0
votes
1 answer

Powershell Write-Host showing only dataTable name instead of data

I'm trying to write a Powershell script that executes a SQL query contained in a .sql file Function RunSQLScript ($connstring, $filePath) { $query = get-content $filePath; $DTSet = New-Object System.Data.DataSet; $Conn=New-Object…
Vittorio Sozzi
  • 103
  • 1
  • 9
0
votes
3 answers

Print a variable on Powershell

I need print on Powershell a line comand through a variable , I called $em_result, for example, em_result=20, Thanks. $em_result = ´gc C:\Users\mtmachadost\Desktop\Test\logError.txt | ?{$_ -match 'cajica11'} | %{($_ -split "\s+")[3]} | Measure -Sum…
0
votes
1 answer

echo in while loop get's added to my return value

I wasn't sure how to describe this problem in the title so here goes. I call a function from a script in another script. In that function i have a while loop that basically keeps looping through a set of ip's and looks up their hostname. when the…
Puzzle84
  • 540
  • 3
  • 20
-1
votes
2 answers

Foreach loop in powershell with hasharray

I'm writing a powershell script to ping all the servers and check which are offline. but i have a bug. By name it works perfectly. But when i do test-connection with an IP it seems to work BUT i cant output the name of the IP in the hashlist. Could…
S G
  • 29
  • 2
1 2 3 4
5