Reputation: 109
I have the following problem:
The script doesn't write anything in my export.txt file, but it does say "File found!"...
$client = "my-workstation"
$file = "c$\Windows\System32\notepad.exe"
$export = "C:\temp\export.txt"
If(Test-Path "\\$client\$file")
{
write-host $client | Out-File $export
write-host "File found!"
}
Upvotes: 1
Views: 566
Reputation: 58931
The Write-Host cmdlet writes messages to the console, it doesn't put anything to the pipeline thus you have to omit the Write-Host
:
$client | Out-File $export
Upvotes: 2