doubleplay1
Technical User
Hi, I am fairly new to Powershell, but I am loving it. I am stuck at the end of my little script and am having problems comparing/parsing through two csv files and exporting the difference in the same format. Any help/suggestions are welcomed and appreciated!
Ok, so below you will find so far what kind of compare string has been put together so far with the help of another powershell user.
$Master = import-csv c:\scripts\master.csv
$New = import-csv c:\scripts\new.csv
Compare-Object $Master $New|
Where {$._SideIndicator -eq '=>'}|
ForEach-Object {$_.InputObject}|
Export-Csv c:\scripts\finalnew.csv
Basically, I want it to read each line in the master csv (grabbing all the information from each line) and parse through every line on the new.csv file to make sure none of that information is already on the master. e.g : If line 1 is on master and also on new, do not include it on the finalnew.csv or viceversa; whatever can make the script better would be cool. I basically will be using this as a master list for approved users and new as the new users and make sure that the difference is the output.
I will also post below the code that I am using to export the information from AD and to create the new.csv file I reference above.
Thanks for all your help!
Get-QADUser -enabled -sizelimit 0 |
Select-Object SamAccountName,@{n="LastLogonTimeStamp";e={$_.LastLogonTimeStamp.value}},WhenCreated,PasswordNeverExpires,AccountExpires,Description|
Sort-Object LastLogonTimeStamp |
Export-Csv c:\scripts\new.csv
Ok, so below you will find so far what kind of compare string has been put together so far with the help of another powershell user.
$Master = import-csv c:\scripts\master.csv
$New = import-csv c:\scripts\new.csv
Compare-Object $Master $New|
Where {$._SideIndicator -eq '=>'}|
ForEach-Object {$_.InputObject}|
Export-Csv c:\scripts\finalnew.csv
Basically, I want it to read each line in the master csv (grabbing all the information from each line) and parse through every line on the new.csv file to make sure none of that information is already on the master. e.g : If line 1 is on master and also on new, do not include it on the finalnew.csv or viceversa; whatever can make the script better would be cool. I basically will be using this as a master list for approved users and new as the new users and make sure that the difference is the output.
I will also post below the code that I am using to export the information from AD and to create the new.csv file I reference above.
Thanks for all your help!
Get-QADUser -enabled -sizelimit 0 |
Select-Object SamAccountName,@{n="LastLogonTimeStamp";e={$_.LastLogonTimeStamp.value}},WhenCreated,PasswordNeverExpires,AccountExpires,Description|
Sort-Object LastLogonTimeStamp |
Export-Csv c:\scripts\new.csv