I am trying to use PowerShell to get the dates from a Sharepoint list and compare today's date to see if there is a match.
I have some code so far but it doesn't seem to be working. I am guessing I have some data types wrong when I am doing a comparison or something of that nature. This is the code I have so far below:
$unusableDatesArray is set with a CAML query to a list in SharePoint The column name of the date field in SharePoint is called 'UnusableDate' and of type date/time
$todaysDate = Get-Date
$foundUnusableDate = $false
ForEach($item in $unusableDatesArray) {
if($item['UnusableDate'] -eq $todaysDate) {
$foundUnusableDate = $true
}
}
Even though both values appear to have 8/10/2017 12:00:00 AM
as the value when I find a matching date, $foundUnusableDate
never ends up being true. If anyone knows what I am doing wrong please chime in.
[Datetime]$item['UnusableDate']
– Jason Snell