Hogyan lehet SharePoint felhasználói profilt törölni a PowerShell segítségével?
Általában a SharePoint felhasználói profilok törlődnek, ha az alábbi események bármelyike bekövetkezik:
- A felhasználói fiók törlődik az Active Directoryból
- A fiók le van tiltva
- Felhasználói profil szolgáltatás Alkalmazás kapcsolat módosult vagy újra létrejött
- A fiókot újra létrehozták az AD-ben, vagy áthelyezték egy olyan szervezeti egységből, amely nem része a SharePoint felhasználói profil szinkronizálási kapcsolatának
Időnként előfordulhat, hogy manuálisan kell törölnie a SharePoint felhasználói profilokat. Ez a blogbejegyzés bemutatja, hogyan használhatja a PowerShellt felhasználói profilok SharePointban való törlésére.
PowerShell felhasználói profil törléséhez a SharePointban:
Íme a PowerShell a SharePoint felhasználói profiljának törléséhez:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration Variables
$SiteURL = "https://mypage.crescent.com"
$AccountName="Crescent\Sherif"
#Get Objects
$ServiceContext = Get-SPServiceContext -site $SiteURL
$UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
#Get the User Profile
$UserProfile = $UserProfileManager.GetUserProfile($AccountName)
#remove user profile
$UserProfileManager.RemoveUserProfile($AccountName);
Az összes felhasználói profil törlése a SharePointban a PowerShell segítségével
Egy forgatókönyv szerint meg kell tisztítanom a felhasználói profilok tárolóját. Bár sok profil létezik a felhasználói profilok tárolójában, ezek nem jelentek meg a SharePoint 2013 központi felügyeletében. Tehát az árva/sérült felhasználói profilok törlése a központi adminisztrációból nem lehetséges. Az összes felhasználói profil eltávolításához használja ezt a PowerShell-szkriptet:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration Variables
$SiteURL = "https://mypage.crescent.com"
#Get Objects
$ServiceContext = Get-SPServiceContext -site $SiteURL
$UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
#Ger all User Profiles
$UserProfiles = $UserProfileManager.GetEnumerator()
# Loop through user profile
Foreach ($Profile in $UserProfiles)
{
write-host Removing User Profile: $Profile["AccountName"]
#Remove User Profile
$UserProfileManager.RemoveUserProfile($profile["AccountName"])
}
Lekérhetem az összes felhasználói profilt egy adott domainről, és törölhetem őket? Biztos:
$DomainPrefix = "Crescent"
$UserProfiles = $UserProfileManager.GetEnumerator()| Where-Object {$_.Accountname -like "$($DomainPrefix)\*"}
