Hi,
If $file is imported from a csv file you can do it like this
$dayofweek = (Get-Date).DayOfWeek
$Datearray = @()
if($dayofweek -eq "Monday")
{
for($i=0;$i -le 3; $i++)
{
$Datearray += (Get-date).AddDays(-$i).ToString('yyyy-MM-dd')
}
}
else
{
$Datearray += Get-Date -Format yyyy-MM-dd
}
$OrderInfo = $file | Where-Object { $_."Issue Date" -in $Datearray } | Select-Object "Order Number"
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.