You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First-Time-IssueEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues
Get-ScheduledTask returns task trigger info, but Get-Service does not return service trigger info. How are we supposed to get this information in Powershell?
It appears that WMI's Win32_Service object needs to have the trigger info added
PRASOON KARUNAN V (@kvprasoon) it's been a while since you commented so hopefully it was safe to assume you aren't looking at this? If you are then I'm sorry for treading on your toes, but hopefully the questions below are useful. :)
If not Ilya (@iSazonov) could I be assigned to this please?
I've got a working implementation that retrieves the triggers, but before I submit a PR I'd like some guidance on how we should add them to the output, please.
Firstly, any outputs that aren't already properties on the ServiceController object are added as NoteProperties to the PSObject. So far, all additional outputs are just single values, triggers would need to be an array of PSObjects. Is this acceptable? I did have a look at Get-ScheduledTask which returns the triggers as an array of CimInstance objects, but I don't think that helps us here.
Should we return the TriggerType as an integer or its string representation? I'm currently using the enum below to map to the string value. Another question is if we return the string value, should we trim the "SERVICE_TRIGGER_TYPE" prefix? My preference would be to return the string as defined in the docs, but I'm not sure if there is a precedent already set elsewhere.
If the TriggerType is SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL or SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT this is a string.
If the TriggerType is SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT this is a multi-string containing the port, protocol and potentially the executable path and service name.
Finally, if the TriggerType is SERVICE_TRIGGER_TYPE_CUSTOM then the data is defined by the ETW provider.
Excluding the CUSTOM TriggerType (I'm not sure what to do with this yet and I don't have a service to test), one approach is to return a custom PSObject whose properties depend on the TriggerType, for example:
SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL would have a single property called "DeviceId"
SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT would have "Port", "Protocol", "ExecutablePath" and "ServiceName" properties.
SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT could have a "NetworkEndpoint" property.
To be honest, I don't really like this as it isn't user-friendly, especially if you're trying to script something and the output changes constantly. However I can't think of a way to standardise it. I'm open to suggestions.
Also, should we support returning the data items for TriggerType SERVICE_TRIGGER_TYPE_CUSTOM? I think the answer to this may depend on what we do with the others.
I'm not fully acquainted with the finer details of what you're working with there Blake (@BlakeWills) but regarding the enum naming specifically, I think it'd be much more usable for PowerShell folks if you drew up the enum without the prefix and in PascalCase to match the majority of property/enum naming in .NET; $trigger.ServiceTriggerType.Custom where the ServiceTriggerType just becomes the property name, and the individual trigger types have a PascalCased name. Same for the Action ones.
The disparity in naming between that and the interop naming can be laid out in docs if it's important, but it feels more on the level of an implementation detail to me at least on the surface. (Definitely at least until folks can use this information to actually set service triggers in future, if that ever happens.)
Blake (@BlakeWills) I started working on this, looks like I'm not gonna finish this soon. It's your now :-) and AFAIK, it need not to be assigned to you to work on this.
For #1 & #3, I think it would be helpful to return both the enum and the string, or a method to return a string given the enum; otherwise, most implementations will be required to implement an conversion, which is pointless.
For #4, it seems to me that a different object for each trigger type is needed. Please ensure it is easy to determine the object’s type.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
First-Time-IssueEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues
Activity
iSazonov commentedon Jun 23, 2020
We use QueryServiceConfig2W in https://github.com/PowerShell/PowerShell/blob/master/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs#L657.
The function can be used to get the trigger info.
kvprasoon commentedon Jul 2, 2020
Ilya (@iSazonov) thanks for the tip, I'm in for this.
BlakeWills commentedon Jul 26, 2020
PRASOON KARUNAN V (@kvprasoon) it's been a while since you commented so hopefully it was safe to assume you aren't looking at this? If you are then I'm sorry for treading on your toes, but hopefully the questions below are useful. :)
If not Ilya (@iSazonov) could I be assigned to this please?
I've got a working implementation that retrieves the triggers, but before I submit a PR I'd like some guidance on how we should add them to the output, please.
Firstly, any outputs that aren't already properties on the ServiceController object are added as NoteProperties to the PSObject. So far, all additional outputs are just single values, triggers would need to be an array of PSObjects. Is this acceptable? I did have a look at
Get-ScheduledTaskwhich returns the triggers as an array of CimInstance objects, but I don't think that helps us here.Each trigger has four properties: TriggerType, Subtype, Action and SpecificDataItems. (https://docs.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_trigger)
Questions:
Not so much of a question, but I think we can just return the guid for the subtype.
Same question as Q1 but for the action, should we return the integer value or string representation? Again, mapping enum below:
Excluding the CUSTOM TriggerType (I'm not sure what to do with this yet and I don't have a service to test), one approach is to return a custom PSObject whose properties depend on the TriggerType, for example:
To be honest, I don't really like this as it isn't user-friendly, especially if you're trying to script something and the output changes constantly. However I can't think of a way to standardise it. I'm open to suggestions.
Also, should we support returning the data items for TriggerType SERVICE_TRIGGER_TYPE_CUSTOM? I think the answer to this may depend on what we do with the others.
Thank You
vexx32 commentedon Jul 26, 2020
I'm not fully acquainted with the finer details of what you're working with there Blake (@BlakeWills) but regarding the enum naming specifically, I think it'd be much more usable for PowerShell folks if you drew up the enum without the prefix and in PascalCase to match the majority of property/enum naming in .NET;
$trigger.ServiceTriggerType.Customwhere theServiceTriggerTypejust becomes the property name, and the individual trigger types have a PascalCased name. Same for the Action ones.The disparity in naming between that and the interop naming can be laid out in docs if it's important, but it feels more on the level of an implementation detail to me at least on the surface. (Definitely at least until folks can use this information to actually set service triggers in future, if that ever happens.)
kvprasoon commentedon Jul 26, 2020
Blake (@BlakeWills) I started working on this, looks like I'm not gonna finish this soon. It's your now :-) and AFAIK, it need not to be assigned to you to work on this.
BrianCatlin commentedon Jul 26, 2020
iSazonov commentedon Jul 27, 2020
You could look
sc.exe qtriggerinfooutput to get more experience.Because we want only information (not full trigger management) I'd start only with top level.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.