PowerShell, Windows

Parse File from Multiple Remote Servers

I had a requirement to retrieve the specific contents of a file from multiple remote servers and delete the other displayed information which didn’t interest me.

In my case I knew what to specifically look for – “https” – in the XML file. Additionally to that I also wanted to know what server had what URL and then finally delete any unnecessary text.

$servers = 'server1,server2,server3'.Split(',')

foreach ($server in $servers) {
Write-Host $server
$result = Invoke-Command -ComputerName $server -ScriptBlock { Get-Content -Path "C:\Program Files\Microsoft Team Foundation Server 12.0\Version Control Proxy\Web Services\VersionControlProxy\proxy.config" | Where-Object {$_ -like '*https*'}}
$result.Replace("<Uri>", "").Replace("</Uri>","")


Leave a Comment

Your email address will not be published. Required fields are marked *