Skip to content
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

Feature/function enhancements #5

Merged
merged 2 commits into from
Sep 12, 2024
Merged

Conversation

LarryWisherMan
Copy link
Owner

Pull Request

Pull Request (PR) description

Adds admin detection and fallback for non-admin profile retrieval in Get-UserProfilesFromRegistry, with Get-SIDProfileInfoFallback for non-admin users.

Added

  • New helper function Validate-SIDFormat to verify SID value upon retrieval
    in Get-ProfilePathFromSID

  • Admin Detection and Environment Variable: Added logic to detect whether the
    current user is an administrator and set an environment variable
    WinProfileOps_IsAdmin accordingly.

    • If the user is an administrator, $ENV:WinProfileOps_IsAdmin is set to
      $true. If not, it's set to $false.

    • The environment variable is automatically removed when the module is
      unloaded or when PowerShell exits.

    • Registered an OnRemove script block and a PowerShell.Exiting event to
      ensure cleanup of the environment variable on module removal or session exit.

  • Get-SIDProfileInfoFallback: Introduced a new fallback function
    Get-SIDProfileInfoFallback that retrieves non-special user profile
    information using the CIM/WMI method.

Changed

  • Get-UserProfilesFromRegistry: Updated the function to handle scenarios
    where the current user does not have administrative privileges.

    • The function now checks if the user is an administrator by evaluating the
      WinProfileOps_IsAdmin environment variable.

    • If the user has administrator privileges, the function retrieves user
      profiles from the registry using Get-SIDProfileInfo.

    • If the user lacks administrative privileges, the function falls back to the
      Get-SIDProfileInfoFallback method, which retrieves user profiles using
      CIM/WMI without requiring registry access.

    • A warning is logged when the fallback method is used, indicating that
      special system accounts are excluded.

@LarryWisherMan LarryWisherMan added the enhancement New feature or request label Sep 12, 2024
@LarryWisherMan LarryWisherMan self-assigned this Sep 12, 2024
@LarryWisherMan LarryWisherMan merged commit dd185f4 into main Sep 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant