Quantcast
Viewing all articles
Browse latest Browse all 122

powershell - format output per folder name while comparing two text files

I am trying to compare the permissions of users in a list of folders for source and target server saved in two text files and collect the differences in a third file. I am able to capture the differences between file 1 and 2, however I am unable to format the output to display as per each folder name in file 1 and 2. My current output looks like below:

The current folder is Output}                                                   Target       User domain\name has 'FullControl' rights in Output}                            Target       The current folder is Script}                                                   Target       User domain\name has 'FullControl' rights in Script}                            Target       The current folder is Output}                                                   Source       User domain\vname has 'ReadAndExecute, Synchronize' rights in Output}           Source       The current folder is Script}                                                   Source       User domain\vname has 'ReadAndExecute, Synchronize' rights in Script}     Source       

Need assistance to format this output as per the folder names as below

The current folder is Output}                                                   Target       User domain\name has 'FullControl' rights in Output}                            Target The current folder is Output}                                                   Source       User domain\vname has 'ReadAndExecute, Synchronize' rights in Output}           SourceThe current folder is Script}                                                   Target       User domain\name has 'FullControl' rights in Script}                            Target The current folder is Script}                                                   Source       User domain\vname has 'ReadAndExecute, Synchronize' rights in Script}     Source 

The code:

$file1 = Get-Content $outfile1$file2 = Get-Content $outfile2$diffcheck = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2 | Out-File  $tempfileget-content -Path $tempfile | Select-Object -Skip 4 | Sort-Object  | Out-File $output

Viewing all articles
Browse latest Browse all 122

Trending Articles