-
Notifications
You must be signed in to change notification settings - Fork 375
Add PSVersionUtility to retrieve PowerShell version and update cmdlets for admin checks #4788
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s for admin checks
…ion and remove deprecated PSVersionUtility class
@@ -94,6 +94,11 @@ public class RegisterAzureADApp : BasePSCmdlet, IDynamicParameters | |||
|
|||
protected override void ProcessRecord() | |||
{ | |||
if (PSUtility.IsUserLocalAdmin()) | |||
{ | |||
WriteWarning("Running this cmdlet in requires you to run PowerShell as an administrator due to a regression in .NET 9."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use the word bug instead of regression? More (non dev) people will understand that better, I would think?
src/Commands/Utilities/PSUtility.cs
Outdated
{ | ||
return new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent()).IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator); | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be a return null as it cannot be defined in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only impacts Windows , for the rest , it works fine.
}); | ||
|
||
#pragma warning disable CA1416 // Validate platform compatibility | ||
public static bool IsUserLocalAdmin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a nillable bool? See comment below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only impacts Windows , for the rest , it works fine.
…refine local admin verification in PSUtility
… permissions needed
…rtificate generation
Before creating a pull request, make sure that you have read the contribution file located at
https://github.com/pnp/powerShell/blob/dev/CONTRIBUTING.md
Type
Related Issues?
Fixes #X, partially fixes #Y, mentioned in #Z, etc.
What is in this Pull Request ?
Please describe the changes in the PR.
Guidance