'Get-SPUser –Web | Set-SPUser –SyncFromAD' return an error “Cannot get the full name or e-mail address of user” on leaver users

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/236335

문제

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
도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top