I've been strugling on a little thing for few hours now, and I wanted to know if one of you have the solution (maybe i'm missing a little thing)
I got a switch for setting the condition in a IF but seems it doesn't interprete it as a if condiction
switch ( $CampaignStatus )
{
"Complete" { $CampainCondition = ($DateStr -eq (get-date -Format "MM/dd/yyyy")) }
"Incomplete" { $CampainCondition = ($DateStr -eq (get-date -Format "MM/dd/yyyy")) }
"InProgress" { $CampainCondition = ($DateStr -gt (get-date -Format "MM/dd/yyyy")) }
}
foreach($c in $CampaignList) {
$index = $index +1
$DateStr = ConvertToFriendlyDate -Date $c.deadline
if ($CampainCondition) { blablabla}
Any idea ?
I tried with quotes, without etc
$DateStr -gt (get-date -Format "MM/dd/yyyy")won't work correctly. For comparing dates in string format, the year must come first.Complete, andIncompletewill return the same value. So, you really only need one. Another odd thing is your switch statement seems to be before your assignment of$DateStr, yet you are using that result to compare inside your switch. Can you elaborate more on that?