Your first line of code is superfluous. You create a variable but you never use it.
If you want to query a remote computer you will have to reach it in any way. You don't do this in your code.
Usually it's a good idea to check if a remote computer is available at all before querying it. This could be a start for you:
Get-Content -Path C:\Users\user\desktop\servers.txt |
ForEach-Object {
$Query = [PSCustomObject]@{
Server = $_
}
if (Test-Connection -ComputerName $_) {
$RemoteTextFile = "\\$_\C$\Program Files\Program\client.txt"
$Query.Connected = $true
$Query.String1 = Select-String -Pattern 'www.technet.com' -SimpleMatch -Path $RemoteTextFile -Quiet
$Query.String2 = Select-String -Pattern 'Company' -SimpleMatch -Path $RemoteTextFile -Quiet
}
else {
$Query.Connected = $false
$Query.String1 = ''
$Query.String2 = ''
}
$Query
Your input text file must contain one remote computer at a line and must not contain any empty row.
First you check if the remote computer is availabe, then you query the text file for the desired content, then you output the created object.
Of course as always there is a lot of room for improvement. ;-)
Live long and prosper!
(79,108,97,102|%{[char]$_})-join''