Fix StrictMode error on COM-handler task actions in Get-GmsaScheduledTask #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/comhandler-action-strictmode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What does this PR do?
Fixes a
Set-StrictMode -Version Latestfailure inGet-GmsaScheduledTask.ps1when aScheduled Task uses a COM-handler action.
Scheduled Task actions come in two CIM types:
MSFT_TaskExecAction- exposesExecute,Arguments,WorkingDirectory.MSFT_TaskComHandlerAction- exposesClassId,Data(noExecute).The Actions block read
.Executeunconditionally. Under StrictMode, accessing a propertythat does not exist is a terminating error, so any host with a COM-handler task (for example
the built-in
.NET Framework NGENtasks) failed with:This adds a StrictMode-safe
Get-CimPropertyValuehelper that probesPSObject.Propertiesbefore reading, and reports
ActionTypeplusComClassId/ComDataalongside the existingexec fields.
Fixes #
How was this tested?
.ps1file-Recurse). Before: threw on the first COM-handler task. After: all tasks report withouterror, COM-handler actions show their
ActionTypeandComClassId.Checklist
behavior note covered by the new
ActionType/ COM fields)