Hi,
Have been stuck on this for awhile. I have a script that outputs ipconfig/routes/linkspeed, etc... to a text file in one location. After network changes, we would like to run the script again to get same information and save that text file to another location. Text files are named the same in both location, servername.log.
I would like to get the contents of each text file, and compare the text files with the same filename from the two folder against each other. Any difference in the files would be outputted to another text file. Any help appreciated as i been stuck on this.
script to get info below:
$servernames = get-content "...\serverlist.txt"
ForEach ($servers in $servernames)
{
Write-Host "checking $servers"
$logRoot = "...\PreChecks"
$logFilename = $servers + ".log"
$logFile = Join-Path $logRoot $logFilename
$logdate = get-date
Out-file $logFile
Write-Output "Date: $logdate" | Out-file $logFile -Append
Write-Output "Server: $servers" | Out-file $logFile -Append
$session = New-PSSession -ComputerName $servers
Write-Output "" | Out-file $logfile -Append
Write-Output "Route Print" | Out-file $logfile -Append
#route.exe print | out-file $logfile -Append
Invoke-Command -Session $session -ScriptBlock {route.exe print} | out-file $logfile -Append
Write-Output "" | Out-file $logfile -Append
Write-Output "TraceRoute" | Out-file $logfile -Append
Invoke-Command -Session $session -ScriptBlock {tracert.exe eq4innas01b} | out-file $logfile -Append
Write-Output "" | Out-file $logfile -Append
Write-Output "IPConfig" | Out-file $logfile -Append
Invoke-Command -Session $session -ScriptBlock {ipconfig.exe /all} | out-file $logfile -Append
Write-Output "" | Out-file $logfile -Append
Write-Output "NIC LinkSpeed" | Out-file $logfile -Append
Invoke-Command -Session $session -ScriptBlock {Get-WmiObject -namespace root\wmi -Class msndis_linkspeed | select-object instancename, ndislinkspeed} | fl | out-file $logfile -Append
Get-PSSession | Remove-PSSession
}
Thx