PowerShell รับรายละเอียดการดำเนินการตามกำหนดเวลา
ใช้คำสั่ง `Get-ScheduledTask` พร้อมด้วยคุณสมบัติ Actions เพื่อรับรายละเอียดการดำเนินการตามกำหนดการใน PowerShell คุณสมบัติ `Actions` ของงานแสดงถึงการกระทำที่จะดำเนินการเมื่อรันงาน
( Get-ScheduledTask -TaskName "UserTask").ActionsGet-ScheduledTask cmdlet ใน PowerShell ดึงรายการงานและข้อมูล
ในบทความนี้ เราจะพูดถึงวิธีรับรายละเอียดการดำเนินการตามกำหนดการ และรายการงานและการดำเนินการตามกำหนดการโดยใช้สคริปต์ PowerShell
PowerShell รับรายละเอียดการดำเนินการตามกำหนดเวลา
คำสั่ง Get-ScheduledTask ใน PowerShell รับรายละเอียดงานที่กำหนดเวลาไว้ทั้งหมด ใช้คุณสมบัติ TaskName เพื่อกรองงานที่กำหนดเวลาไว้เพื่อดึงข้อมูลเฉพาะงานที่กำหนดเวลาไว้ที่ระบุเท่านั้น
( Get-ScheduledTask -TaskName "UserAccountTests").Actionsในสคริปต์ PowerShell ข้างต้น Get-ScheduledTask cmdlet ใช้คุณสมบัติ การดำเนินการ เพื่อรับรายละเอียดการดำเนินการตามกำหนดเวลาสำหรับชื่องานที่ระบุ “UserAccountTests“
ผลลัพธ์ของสคริปต์ PowerShell ข้างต้นคือ:
ผลลัพธ์ของการดำเนินการกับงานที่กำหนดเวลาไว้ประกอบด้วยอาร์กิวเมนต์สำหรับงานที่กำหนดซึ่งเป็นพาธสคริปต์ PowerShell และคุณสมบัติ Execute มี powershell.exe เพื่อดำเนินการการกระทำเมื่อรันงาน
แสดงรายการรายละเอียดการดำเนินการตามกำหนดการใน PowerShell
คำสั่งเพื่อรับรายละเอียดการดำเนินการตามกำหนดการใน PowerShell คือ Get-ScheduledTask คำสั่งนี้จะดึงงานที่กำหนดเวลาไว้ที่มีอยู่และใช้คุณสมบัติ การดำเนินการ เพื่อรับการดำเนินการที่เกี่ยวข้องกับแต่ละงาน
( Get-ScheduledTask).Actions | Format-List *ในสคริปต์ PowerShell ข้างต้น cmdlet Get-ScheduledTask จะใช้คุณสมบัติ Actions คำสั่งนี้แสดงรายการงานและการดำเนินการที่กำหนดเวลาไว้
เอาต์พุตสำหรับแต่ละงานจะแสดงคุณสมบัติของงาน เช่น Id, Arguments, Execute Working Directory ฯลฯ...
PS C:\> ( Get-ScheduledTask).Actions | Format-List *
Id :
Arguments : /checkrecovery
Execute : %SystemRoot%\System32\dsregcmd.exe
WorkingDirectory :
PSComputerName :
CimClass : Root/Microsoft/Windows/TaskScheduler:MSFT_TaskExecAction
CimInstanceProperties : {Id, Arguments, Execute, WorkingDirectory}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
Id :
Arguments : wwan
Execute : %SystemRoot%\System32\WiFiTask.exe
WorkingDirectory :
PSComputerName :
CimClass : Root/Microsoft/Windows/TaskScheduler:MSFT_TaskExecAction
CimInstanceProperties : {Id, Arguments, Execute, WorkingDirectory}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
Id :
Arguments : standby
Execute : %windir%\System32\XblGameSaveTask.exe
WorkingDirectory :
PSComputerName :
CimClass : Root/Microsoft/Windows/TaskScheduler:MSFT_TaskExecAction
CimInstanceProperties : {Id, Arguments, Execute, WorkingDirectory}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
Id :
Arguments : do-task "308046B0AF4A39CB"
Execute : C:\Program Files\Mozilla Firefox\default-browser-agent.exe
WorkingDirectory :
PSComputerName :
CimClass : Root/Microsoft/Windows/TaskScheduler:MSFT_TaskExecAction
CimInstanceProperties : {Id, Arguments, Execute, WorkingDirectory}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemPropertiesเคล็ดลับเด็ด: วิธีลบงานที่กำหนดเวลาไว้ใน PowerShell!
บทสรุป
ฉันหวังว่าบทความข้างต้นเกี่ยวกับวิธีรับรายละเอียดการดำเนินการตามกำหนดเวลาและรายการการดำเนินการตามกำหนดเวลาใน PowerShell จะเป็นประโยชน์สำหรับคุณ
คุณสามารถเรียกรายละเอียด การดำเนินการ ของกำหนดการงานได้โดยใช้ cmdlet ScheduledTask เช่นกัน
(ScheduledTask -TaskName "UserAccountTests").Actionsคุณสามารถค้นหาหัวข้อเพิ่มเติมเกี่ยวกับคำสั่ง PowerShell Active Directory และพื้นฐาน PowerShell ได้ในหน้าแรกของ ShellGeek
