WinProfileOps

0.2.0-preview0003

The WinProfileOps module provides a comprehensive toolkit for managing Windows user profiles across local and remote computers. This module automates profile management tasks such as detecting orphaned profiles, retrieving profile information, and auditing discrepancies between profile data in the file system and the registry. It handles both filesystem and registry o
The WinProfileOps module provides a comprehensive toolkit for managing Windows user profiles across local and remote computers. This module automates profile management tasks such as detecting orphaned profiles, retrieving profile information, and auditing discrepancies between profile data in the file system and the registry. It handles both filesystem and registry operations, leveraging its dependency on WinRegOps for registry-related tasks.

WinProfileOps integrates seamlessly with WinRegOps to query, validate, and manage user profile-related data from the Windows registry. This module is ideal for system administrators seeking to streamline profile management, especially in environments with many users and computers.

Dependencies:
- WinRegOps: WinProfileOps depends on WinRegOps for registry operations, such as querying, opening, and modifying registry keys related to user profiles.

Key features:
- Retrieve user profile information from both the registry and file system (local and remote).
- Detect orphaned profiles (e.g., missing profile folders or registry entries).
- Filter and exclude special accounts like system or service accounts.
- Remote profile management support for retrieving profiles from different systems.
- Robust error handling for permission issues or unreachable systems.
- Class-based profile objects for easy integration with automation tasks or scripts.

Typical use cases include:
- Cleaning up orphaned profiles after system migrations or user deactivations.
- Automating stale profile detection on local and remote systems to maintain system performance.
- Managing user profiles in large-scale, multi-user environments such as terminal servers and Citrix.
- Excluding critical system accounts from profile management tasks, ensuring important profiles remain unaffected.
- Providing profile management as part of system maintenance routines to enhance system health.

Upcoming Features:
- The `Remove-UserProfile` function is coming soon, offering safe removal of user profiles from both the file system and registry, with strong safeguards like `ShouldProcess`, `-WhatIf`, and `-Confirm` to prevent accidental deletions.
Show more

Minimum PowerShell version

5.1

This is a prerelease version of WinProfileOps.
There is a newer prerelease version of this module available.
See the version list below for details.

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name WinProfileOps -RequiredVersion 0.2.0-preview0003 -AllowPrerelease

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name WinProfileOps -Version 0.2.0-preview0003 -Prerelease

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2024 LarryWisherMan. All rights reserved.

Package Details

Author(s)

  • LarryWisherMan

Tags

WindowsProfiles ProfileManagement OrphanedProfiles RegistryOperations FilesystemOperations RemoteManagement UserProfiles ProfileCleanup WindowsRegistry SystemAdministration Automation ProfileValidation WindowsManagement ITAdministration UserProfileTools

Functions

Get-OrphanedProfiles Get-UserProfilesFromFolders Get-UserProfilesFromRegistry Invoke-UserProfileAudit

Dependencies

Release Notes

## [0.2.0-preview0003] - 2024-09-12

### Added

- Added core functions
- configured `WinRegOps` as a dependant module
- Updated build file for release

- Comment-based help documentation added for the following public functions:
 - `Get-AllUserProfiles`
 - `Get-OrphanedProfiles`
 - `Remove-OrphanedProfiles`
 - `Remove-SIDProfile`
 - `Get-UserProfileFolders`
 - `Get-RegistryUserProfiles`
 - `Get-UserFolders`

- Comment-based help documentation added for the following public functions:
 - `New-UserProfileObject`
 - `Remove-RegistryKeyForSID`
 - `Remove-ProfilesForSIDs`
 - `Get-RegistryKeyForSID`
 - `Get-SIDProfileInfo`
 - `Get-ProfilePathFromSID`
 - `Test-FolderExists`
 - `Test-OrphanedProfile`
 - `Test-SpecialAccount`

- Implemented and completed Unit Tests for private functions

- **`Get-UserFolders`**
 - Added error handling using a `try`/`catch` block to ensure that if `Get-ChildItem`
  fails (e.g., due to permission issues), the function logs an error message and
  returns an empty array instead of throwing an unhandled exception.

 - Implemented an `OutputType` attribute for better PowerShell function introspection
  and to clearly indicate that the function returns an array of `[PSCustomObject]`.

- **`Invoke-UserProfileAudit` Supporting Functions:**

 - These supporting functions are now utilized within `Invoke-UserProfileAudit`
  to audit user profiles from both the file system and registry sources.

   - **`Process-RegistryProfiles`**:
     - Processes profiles retrieved from the registry,
   compares them with folder profiles, and identifies orphaned profiles.

   - **`Process-FolderProfiles`**:
     - Processes user profiles from the folder system,
    identifies those without corresponding registry entries, and marks them as orphaned.

   - **`Test-ComputerReachability`**:
     - Encapsulates the common behavior of `Test-ComputerPing` to check if a computer
     is reachable before proceeding with operations like profile audits. This ensures
      consistent handling of unreachable computers across different functions.
 
### Changed

- Moved `Get-SIDProfileInfo` to the private functions folder. It will serve as
an internal function for `Get-RegistryUserProfiles`

- **`Get-SIDProfileInfo`**
 - Returns an empty array `@()` when no registry
 key or SIDs are found, improving handling for cases where there are no profiles.

 - Improved error handling to ensure proper error messages when the registry key
 or subkeys cannot be opened.

 - Enhanced handling of SIDs that are invalid or missing a `ProfileImagePath`,
 logging appropriate warnings or verbose messages.

 - Optimized function behavior to handle scenarios with no SIDs, invalid SID formats,
 and missing `ProfileImagePath` values gracefully.


- **`Get-UserFolders`**
 - The function now logs errors when folder retrieval fails, improving diagnostic
  feedback.

 - The default value for the `ComputerName` parameter is set to `$env:COMPUTERNAME`,
  ensuring local computer behavior by default without requiring the user to
  specify it manually.
 
 - Refined the `Get-DirectoryPath` call to ensure path conversion consistency
  across local and remote environments.

 - General code clean-up and improved resilience, returning an empty array when
  no folders are found or in case of failure, rather than proceeding
  without valid data.

- **`Get-UserProfilesFromRegistry`**
 - Added error handling using a `try-catch` block to capture and log errors
  during the retrieval of registry profiles.

 - Implemented a check using `Test-ComputerPing` to verify if the target computer
  is online or reachable before attempting to retrieve registry profiles.

 - Returns an empty array `@()` when the target computer is offline or unreachable,
  logging a warning in such cases.

 - Returns an empty array `@()` when an error occurs while accessing the registry
  profiles, logging an error message.

 - Integrated with the `-ErrorAction Stop` parameter when calling `Get-SIDProfileInfo`,
  ensuring that errors are caught and handled appropriately in the calling function.

- **`Get-UserProfilesFromFolders`**
 - Added error handling using a `try-catch` block to capture and log errors
  during the retrieval of user profile folders.

 - Implemented a check using `Test-ComputerPing` to verify if the target
  computer is online or reachable before attempting to retrieve user folders.

 - Returns an empty array `@()` when the target computer is offline or
  unreachable, logging a warning in such cases.

 - Returns an empty array `@()` when an error occurs while accessing the user
  folders, logging an error message.


- **`Invoke-UserProfileAudit`**
 - Renamed the previous `Get-AllUserProfiles` function to `Invoke-UserProfileAudit`.
 - Added `Get-AllUserProfiles` as an alias for `Invoke-UserProfileAudit`
 to maintain backward compatibility.

### Removed

- Removed the old `Get-AllUserProfiles` function and replaced it with the new
`Invoke-UserProfileAudit` function.

- Temporarily Removed functions (`Remove-OrphanedProfiles` and
`Remove-ProfilesForSIDs`) related to Removing Users Folders and registry
keys for further testing before implementing

FileList

Version History

Version Downloads Last updated
0.3.0-previe... 4 10/1/2024
0.3.0-previe... 4 10/1/2024
0.3.0-previe... 3 10/1/2024
0.3.0-previe... 4 9/24/2024
0.3.0-previe... 3 9/24/2024
0.3.0-previe... 3 9/16/2024
0.3.0-previe... 4 9/12/2024
0.2.0 13 9/12/2024
0.2.0-previe... (current version) 2 9/12/2024
0.2.0-previe... 2 9/11/2024
0.2.0-previe... 3 9/9/2024
Show less