我有一組員工資料($employees),在該陣列中,它們是一個名為 start_date 的欄位,它被列為一個字串。我試圖過濾掉 start_date 等于當月的任何作業人員。最初我以為我可以寫:
$employee | Where-Object {$_.start_date -ge Get-Date()}
這沒有用。
I then tried to convert the Get-Date to a string with:
$date = Get-Date -f '01/MM/yyyy'
$dateString = $date.toString
$employee | Where-Object {$_.start_date -ge $dateString}
這也沒有給我我所追求的結果。
我的同事與他的作業相當務實,我可能最好寫一個 foreEach-Object 但我一直在努力如何寫這個,并且不想讓他離開他的作業來幫助我完成這項任務。
示例陣列:
preferred_name : John
name_suffixes :
gender : M
date_of_birth : 09/05/1596
surname : Doe
supervisor : PRNMA01
start_date : 28/11/2020
school_email : [email protected]
teacher_code :
termination_date :
employee_photo : @{file_info=}
supervisor_2 :
title : Mr
driver_licence_no :
supplier_code :
given_names : John Jane
任務:獲取新員工名單,并將名單通過電子郵件發送給負責新員工培訓的部門。
對此的任何幫助都會很好。請確保您詳細解釋,因為我在這個領域不是很聰明。
提前致謝。
uj5u.com熱心網友回復:
您可以使用將start_date日期時間轉換為日期時間parseexact,然后直接比較日期時間物件。
$employee | Where-Object {[datetime]::parseexact($_.start_date, 'dd/MM/yyyy', $null) -ge (Get-Date)}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/366212.html
標籤:电源外壳
