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.
Now i want to extend the Script and the CSV File. I added the EOL Dates to the CSV File.
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’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 )
$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.