compareobject - Powershell Compare-Object and getting the Differences into a File -


i'm new ps , have been cracking head on particular problem. i'm trying differences between in ad , scom monitoring already. based on i'll run discovery or push out services , if ports open.

i've been able build 2 files comparison using get-scomagent , get-adcomputer , works champ. problem compare-object limited in getting present in 1 file , not in other. figured i'd loop through , see can find.

"looping through compare files" foreach ($server in get-content "c:\scom\xxxx\serversinadformatted.txt") {     compare-object -referenceobject $(get-content "$server") -differenceobject $(get-content "c:\scom\xxxx\serverswithscomagentsformatted.txt")  | export-csv -path "c:\scom\xxxx\differences.csv" } 

update: i'm trying not getting output:

foreach ($server in get-content "c:\scom\xxxx\serversinadformatted.txt") {     select-string -path "c:\scom\xxxx\serverswithscomagentsformatted.txt" -pattern $server } 

really needs act sdiff or grep can export out file can use discovery using scom ps api. know there differences in way strings handled in win os not connecting dots.

any appreciated.

#

for reason compare isn't working. seemingly differences in amount of whitespaces after servername. leads innaccurate results since servers in both places compare maks them unique.

both text files have server1.somedomain.com (spaces after last character)

i know i'll need strip whitespaces , have tried .trimend when @ file in notepad there still spaces. need have crlf that's all.

foreach ($line in $serversinad) { $serversinad = $line.trimend(); $line += "$line`n" $serversinad >formattedfile }


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -