Bug in Get-UserProfiles

First off, I absolutely LOVE PSADT, thank you all for all of the hard work!

I believe there’s an issue with Get-UserProfiles not handling the error gracefully when accounts have been deleted from ActiveDirectory but not the machine.

I’ve tried using -ErrorAction SilentlyContinue and | Out-Null to suppress the errors but no dice.
Ideally the errors would be handled gracefully and maybe there’d be either a flag to include/exclude these accounts or an extra property indicating whether or it was able to convert the SID to an account name (as the profile folders and registry for these accounts still exist).

Here’s the error it returns:

[06-10-2024 11:19:47.377] [Post-Installation] [ConvertTo-NTAccountOrSID] :: Unable to convert the SID [S-1-5-21-1757505558-3676514810-1639332544-36536] to an NT Account name. It may not be a valid account anymore or there is some other problem.
Error Record:
-------------

Message        : Exception calling "Translate" with "1" argument(s): "Some or all identity references could not be translated."
InnerException : System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated.
                    at System.Security.Principal.SecurityIdentifier.Translate(IdentityReferenceCollection sourceSids, Type targetType, Boolean forceSuccess)
                    at System.Security.Principal.SecurityIdentifier.Translate(Type targetType)
                    at CallSite.Target(Closure , CallSite , Object , Type )

FullyQualifiedErrorId : IdentityNotMappedException
ScriptStackTrace      : at ConvertTo-NTAccountOrSID<Process>, \\wam\ict\Software\PSADT\3.10.1\Toolkit\AppDeployToolkit\AppDeployToolkitMain.ps1: line 6945
                        at <ScriptBlock>, \\wam\ict\Software\PSADT\3.10.1\Toolkit\AppDeployToolkit\AppDeployToolkitMain.ps1: line 7103
                        at <ScriptBlock>, \\wam\ict\Software\PSADT\3.10.1\Toolkit\AppDeployToolkit\AppDeployToolkitMain.ps1: line 7102
                        at Get-UserProfiles<Process>, \\wam\ict\Software\PSADT\3.10.1\Toolkit\AppDeployToolkit\AppDeployToolkitMain.ps1: line 7100
                        at <ScriptBlock>, <No file>: line 1

PositionMessage : At \\wam\ict\Software\PSADT\3.10.1\Toolkit\AppDeployToolkit\AppDeployToolkitMain.ps1:6945 char:25
                  + ...             $NTAccount = $NTAccountSID.Translate([Security.Principal. ...
                  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Error Inner Exception(s):
-------------------------

Message        : Some or all identity references could not be translated.
InnerException :

Looks like it’s a known issue: Get-UserProfiles freezes script if saved into variable and domain account has been removed · Issue #798 · PSAppDeployToolkit/PSAppDeployToolkit (github.com)

What version of PSADT as you using?

Interesting, thanks for linking that, I’ll modify my copy with the workaround.
I’m using 3.10.1

1 Like

Related issue here also:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.