# Powershell Skript to check EOL Dates in CSV File

**URL:** <https://forums.powershell.org/t/powershell-skript-to-check-eol-dates-in-csv-file/17286>\
**Category:** PowerShell Help\
**Created:** [August 11, 2021, 2:35pm UTC](https://forums.powershell.org/t/powershell-skript-to-check-eol-dates-in-csv-file/17286 "2021-08-11T14:35:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptsonic](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@ptsonic](https://forums.powershell.org/u/ptsonic)\
**Post date:** [August 11, 2021, 2:35pm UTC](https://forums.powershell.org/t/powershell-skript-to-check-eol-dates-in-csv-file/17286/1 "2021-08-11T14:35:17Z")

</div>

Hi all 🖐,

i´m really new into Powershell Scripting and i hope i can get some help from you.

Situation: I created an Script which checking the Windows Version of the Server and compare it with a List of support Versions in a CSV File. Really Simple.

```auto
$winver = (get-wmiobject Win32_OperatingSystem).caption

$EOLList = @()
Import-Csv -Path C:\__LocalData\EOL.csv | ForEach-Object {$EOLList += $_.WindowsVersion}

If ($EOLList -contains $winver) {
    write-host "Windows OK"
}

else{
    write-host "EOL"
}

```

Now i want to extend the Script and the CSV File. I added the EOL Dates to the CSV File.

```auto
WindowsVersion Date      
-------------- ----      
Microsoft Windows Server 2019 09.01.2029
Microsoft Windows Server 2016 11.01.2027
Microsoft Windows Server 2012R2 10.10.2023
Microsoft Windows Server 2012 10.10.2023

```

I want to check if the current Server Version is in this List and also check how many Days left to the EOL Date.

I hope some of you guys can help me with this 😀

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 11, 2021, 3:55pm UTC](https://forums.powershell.org/t/powershell-skript-to-check-eol-dates-in-csv-file/17286/2 "2021-08-11T15:55:04Z")

</div>

ptsonic,  
Welcome to the forum. 👋🏽

I’m not completely sure if I got what you want to do actually. If I got it right I’d do it a little different. I’d use a hashtable as lookup table (and I added an entry for Windows 10 with a fictional date because I didn’t have a server to test 😉 )

```auto
$LookUpTable = @{
    'Microsoft Windows Server 2019' = '09.01.2029'
    'Microsoft Windows Server 2016' = '11.01.2027'
    'Microsoft Windows Server 2012R2' = '10.10.2023'
    'Microsoft Windows Server 2012' = '10.10.2023'
    'Microsoft Windows 10 Pro' = '31.12.2044'
}
$CurrentSystem = Get-CimInstance -ClassName CIM_OperatingSystem | Select-Object -ExpandProperty Caption
$DaysCount = New-TimeSpan -Start (Get-Date) -End $LookUpTable[$CurrentSystem]

"`n`tThe support for the current system will end in {0} days form now, at {1}.`n" -f ($DaysCount.TotalDays -as [int]) , $LookUpTable[$CurrentSystem]

```

Could you please format your code as code next time? As you can see it is incomplete because the forum software tried to _interpret_ it and removed some charachters in this process. This will not happen when you use the _preformatted text_ button ( **\</\>** ) to post your code.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ptsonic](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@ptsonic](https://forums.powershell.org/u/ptsonic)\
**Post date:** [August 11, 2021, 4:24pm UTC](https://forums.powershell.org/t/powershell-skript-to-check-eol-dates-in-csv-file/17286/3 "2021-08-11T16:24:50Z")

</div>

Hi Olaf,

thanks for your fast answer. Firstable i correct my post and formated the code 😉

I will try your solution tomorrow.

The Final Situation is that i want to implement a Sensor in Icinga that will show me the Status of the Operation System.

OK (Green) – Windows under support  
Warning (Orange) – Support will end in X Days  
Error (Red) – Product is End of life

---

<div class="post-metadata">

**Author:** ![ptsonic](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@ptsonic](https://forums.powershell.org/u/ptsonic)\
**Post date:** [August 12, 2021, 9:22am UTC](https://forums.powershell.org/t/powershell-skript-to-check-eol-dates-in-csv-file/17286/4 "2021-08-12T09:22:55Z")

</div>

Hi Olaf,

i just want let you know the Solution works fine 😀  
Thanks for your fast answer.

---

<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:22pm UTC](https://forums.powershell.org/t/powershell-skript-to-check-eol-dates-in-csv-file/17286/5 "2024-05-16T20:22:01Z")

</div>

Closed on May 16, 2024, 8:22pm UTC


