Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make someSystemPolicy APIs visible but non-op on Unix so that they can be included inPowerShellStandard.Library#25051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
daxian-dbw merged 3 commits intoPowerShell:masterfromdaxian-dbw:asmi-apis
Mar 4, 2025

Conversation

daxian-dbw
Copy link
Member

@daxian-dbwdaxian-dbw commentedFeb 19, 2025
edited
Loading

PR Summary

SomeSystemPolicy APIs are useful outside of PowerShell, for example, theThreadJob module depends on them to determine when to block a thread job from running. However, they are not included in thePowerShellStandard.Library package because they are Windows-only API so far. So, it's hard for a module to use it -- it has to invoke those method with reflection.

In order to include them in thePowerShellStandard.Library package, those APIs need to be available on both Windows and Unix platforms, so this PR make them visible but non-op on Unix, so that they can be included inPowerShellStandard.Library the next time we update that package.

classSystemPolicy{publicstaticSystemEnforcementModeGetSystemLockdownPolicy();publicstaticSystemEnforcementModeGetLockdownPolicy(stringpath,SafeHandlehandle);publicstaticSystemScriptFileEnforcementGetFilePolicyEnforcement(stringfilePath,FileStreamfileStream);}

[Update] As pointed out in#25051 (comment), theGetFilePolicyEnforcement method is not available in Windows 5.1 on Win10 or Windows Server 2022. So, we probably should only includeGetSystemLockdownPolicy andGetLockdownPolicy inPowerShellStandard.Library for the short/middle term. After Windows 10 and Windows Server 2022 reach EOL (or when the method becomes available on them) we can then add theGetFilePolicyEnforcement method to the package.

PR Checklist

0xfeeddeadbeef reacted with thumbs up emoji
@daxian-dbwdaxian-dbw added the CL-GeneralIndicates that a PR should be marked as a general cmdlet change in the Change Log labelFeb 19, 2025
@daxian-dbw
Copy link
MemberAuthor

@SeeminglyScience Where shall we open issues to track the changes needed forPowerShellStandard.Library package? The old repohttps://github.com/[PowerShell/PowerShellStandard](https://github.com/PowerShell/PowerShellStandard) was archived. Maybe we should remove it from the archived state?

@iSazonov
Copy link
Collaborator

Perhaps we could annotate them with SupportedOSPlatformAttribute.

@jborean93
Copy link
Collaborator

How will this work across the Windows versions? TheGetFilePolicyEnforcement method is not present in the baseline PowerShell 5.1 install and seems to have been introduced with Windows 11/Server 2025. What will happen if I am running on Server 2022 or Windows 10 and call that API?

@daxian-dbw
Copy link
MemberAuthor

daxian-dbw commentedFeb 21, 2025
edited
Loading

That's a very good point. I wasn't aware of it.
Then I think we only includeGetSystemLockdownPolicy andGetLockdownPolicy to thePowerShellStandard.Library package for now. When Win10 and Windows Server 2022 reach EOL, we can create a new version of the package to include theGetFilePolicyEnforcement API.

[update] Opened the issuePowerShell/PowerShellStandard#103 to track the change toPowerShellStandard.Library.

jborean93 reacted with thumbs up emoji

Copy link
Member

@TravisEz13TravisEz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Approved, but waiting on@SeeminglyScience to verify one thing.

Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Copy link
Member

@TravisEz13TravisEz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Reviewed with@SeeminglyScience

@daxian-dbwdaxian-dbw merged commit0e6ffc5 intoPowerShell:masterMar 4, 2025
32 checks passed
@daxian-dbwdaxian-dbw deleted the asmi-apis branchMarch 4, 2025 01:21
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@TravisEz13TravisEz13TravisEz13 approved these changes

@SeeminglyScienceSeeminglyScienceAwaiting requested review from SeeminglyScience

Assignees
No one assigned
Labels
CL-GeneralIndicates that a PR should be marked as a general cmdlet change in the Change Log
Projects
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@daxian-dbw@iSazonov@jborean93@TravisEz13

[8]ページ先頭

©2009-2025 Movatter.jp