0

I have an Enterprise Wiki site collection inside my sharepoint on-premises farm 2013. now the site have been for around 4 years, and as we did not configure the User Profile service. so many of the user properties inside the userdisp.aspx page are not being updated, to reflect what is on Active Directory. so i decide to run the following command to update the user info:-

Get-SPUser –Web "http://servername/sites/WikiSite" | Set-SPUser –SyncFromAD

now the above script was able to update some of the users' info. but i got exceptions, on all the users who left the company, as follow:-

Set-SPUser : Cannot get the full name or e-mail address of user "i:0#.w|ad-****\****.****".
At line:1 char:60
+ Get-SPUser –Web "http://servername/sites/WikiSite" | Set-SPUser –SyncFromA ...
+                                                            ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletSetUser:SPCmdletSetUser) [Set-SPUser], SPException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletSetUser

so can i modify my script to avoid those exceptions?

Also beside the leavers i got exceptions on the following users:-

c:0(.s|true    
i:0#.w|ad-*****\fromeveryone    
c:0!.s|windows
NT AUTHORITY\LOCAL SERVICE    
SHAREPOINT\system

1 Answer 1

1

The -SyncFromAD switch has no additional parameters to skip inactive accounts or groups which do not exist in ActiveDirectory. Try to use the -ErrorAction SilentlyContinue switch:

Get-SPUser –Web "http://servername/sites/WikiSite" | Set-SPUser –SyncFromAD -ErrorAction SilentlyContinue
2
  • thanks for the update, now my worries is not about the exceptions, but i am not sure if the script will skip the remaining users when an exception is raised, or the script will work on all users and raise exceptions on the ones its can not find for a reason or another...
    – John John
    Feb 21, 2018 at 14:59
  • can you advice on my above comment please?
    – John John
    Feb 22, 2018 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.