# Help Regarding compairing dates from two columns in CSV

**URL:** <https://forums.powershell.org/t/help-regarding-compairing-dates-from-two-columns-in-csv/12827>\
**Category:** PowerShell Help\
**Created:** [July 7, 2019, 5:26am UTC](https://forums.powershell.org/t/help-regarding-compairing-dates-from-two-columns-in-csv/12827 "2019-07-07T05:26:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aman1313](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@aman1313](https://forums.powershell.org/u/aman1313)\
**Post date:** [July 7, 2019, 5:26am UTC](https://forums.powershell.org/t/help-regarding-compairing-dates-from-two-columns-in-csv/12827/1 "2019-07-07T05:26:55Z")

</div>

Hello Everyone,

I am trying to compare terminated users dates from CSV against AD(In AD we use a powershell script that we run for terminating a user that sets date/time of user’s termination in user’s description field). I am thinking of

1. Importing users from CSV (that has list of terminated users and date/times of terminations generated in another system) based on username and get description field from AD that contains date/time of terminations and compare both times to find out any delays. I have small code that I started with

```
$testcsv = import-csv C:\users\username\documents\test.csv

ForEach ($user in $testcsv)
{

$username = $user.username
Get-ADUser -Filter {samaccountname -eq $username} -Properties * |
Select-Object description | Export-csv C:\users\username\documents\new.csv -append

}
```

Any Ideas on how to achieve this or plan this because I am new to PowerShell. Any guidance will be appreciated.

Thank You

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![postanote](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@postanote](https://forums.powershell.org/u/postanote)\
**Post date:** [July 7, 2019, 1:56pm UTC](https://forums.powershell.org/t/help-regarding-compairing-dates-from-two-columns-in-csv/12827/2 "2019-07-07T13:56:57Z")

</div>

Your post is only selecting users, you are not selecting any date info relative to the user or what’s in the CSV. Thus you can compare anything that you have not asked code. You don’t show any part of the CSV, so we see what the date string / format looks like.

You say …

> Any Ideas on how to achieve this or plan this because I am new to PowerShell.

… that's all well and good, as we all had to start form somewhere, but, you should really spend the needed time getting up to speed on it, to limit / eliminate, confusions, frustration, unnecessary errors, bad habits, poor code, and hurting your system or your environment.

See these resources below and the Free eBooks / videos on this site you asked this on. Use the ‘Free Resources’ like in the side menu section and the search bar to see other posts that could be close to what you are asking for.

You are just doing a read here, so, no real damage can be done, but just saying, as you go down this path, don’t guess, read the help files, view the videos on YouTube and MSDN Channel9 on PowerShell and ADDS, files, folders, loops, compare, etc. Just search for them.

Your query is really a PowerShell with ADDS 101 thing. Something easily found using your favorite search engine. Looking for stuff like ‘PowerShell working with csv’, ‘PowerShell date compare’, ‘PowerShell compare csv dates to active directory dates’, etc. Thus getting back stuff like this…

> _ **Compare AD against CSV** _ - https://community.idera.com/database-tools/powershell/ask\_the\_experts/f/active\_directory\_\_powershell\_remoting-9/19887/compare-ad-against-csv
> 
> _ **PowerShell Dates** _ - [PowerShell Dates](http://www.rlmueller.net/PowerShellDates.htm)
> 
> &nbsp;
> 
> _ **Learning this stuff.** _  
> [https://www.reddit.com/r/PowerShell/comments/bserj9/learn\_powershell/eooduq9/?context=3](https://www.reddit.com/r/PowerShell/comments/bserj9/learn_powershell/eooduq9/?context=3)  
> [https://www.reddit.com/r/PowerShell/comments/bserj9/learn\_powershell/eoodxzu/?context=3](https://www.reddit.com/r/PowerShell/comments/bserj9/learn_powershell/eoodxzu/?context=3)
> 
> _ **Best Practices** _  
> [https://www.reddit.com/user/get-postanote](https://www.reddit.com/user/get-postanote)
> 
> _ **Passwords** _  
> [https://www.reddit.com/r/PowerShell/comments/bv7ywa/whats\_the\_best\_practice\_for\_passwords\_in\_ps/epoux2c/?context=3](https://www.reddit.com/r/PowerShell/comments/bv7ywa/whats_the_best_practice_for_passwords_in_ps/epoux2c/?context=3)  
> [https://www.reddit.com/r/PowerShell/comments/c5qbjb/how\_to\_store\_password\_in\_powershell\_file/](https://www.reddit.com/r/PowerShell/comments/c5qbjb/how_to_store_password_in_powershell_file/)
> 
> _ **Practice with PSKoans** _
> 
> PSKoans : 0.50.0  
> A module designed to provide a crash-course introduction to PowerShell with programming koans.
> 
> > **[PSKoans 0.50.0](https://www.powershellgallery.com/packages/PSKoans/0.50.0)**
> >
> > A module designed to provide a crash-course introduction to PowerShell with programming koans.
> 
> Book references, normally the ones you’ll see most recommend:
> 
> _ **Beginning —** _
> 
> Learn Windows PowerShell in a Month of Lunches 3rd Edition  
> Donald W. Jones (Author),‎ Jeffrey Hicks (Author)  
> ISBN-13: 978-1617294167  
> ISBN-10: 1617294160
> 
> _ **Intermediate —** _
> 
> Windows PowerShell Cookbook: The Complete Guide to Scripting Microsoft’s Command Shell 3rd Edition  
> Lee Holmes (Author)  
> ISBN-13: 978-1449320683  
> ISBN-10: 1449320686
> 
> _ **Advanced —** _
> 
> Windows PowerShell in Action 3rd Edition  
> by Bruce Payette (Author),‎ Richard Siddaway (Author)  
> ISBN-13: 978-1633430297  
> ISBN-10: 1633430294
> 
> From Microsoft
> 
> Windows PowerShell Survival Guide  
> [https://social.technet.microsoft.com/wiki/contents/articles/183.windows-powershell-survival-guide.aspx](https://social.technet.microsoft.com/wiki/contents/articles/183.windows-powershell-survival-guide.aspx)

  
&nbsp;

_ **Lastly, never ever, run any code from any one from anywhere, that you do not fully understand and what it is / will do.** _ If you do, you could seriously damage your host and or your enterprise. Learn to master the -WhatIf, -Confirm, and leveraging the Set-StrictMode are part of your development, put that in your profile. Learn about profiles, and how to use them. Learn about execution policies, what they are and how / when to use them. Fully leverage auditing, monitoring and logging of PowerShell use by all users and processes. Especially as part of your corporate risk management effort.

&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![aman1313](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@aman1313](https://forums.powershell.org/u/aman1313)\
**Post date:** [July 8, 2019, 12:24pm UTC](https://forums.powershell.org/t/help-regarding-compairing-dates-from-two-columns-in-csv/12827/3 "2019-07-08T12:24:37Z")

</div>

Thank You

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:31pm UTC](https://forums.powershell.org/t/help-regarding-compairing-dates-from-two-columns-in-csv/12827/4 "2024-05-16T20:31:59Z")

</div>


