0

I want to remove a user from SharePoint from all Web applications in SharePoint Farm. Like the user has never existed! is ti possible? I see there many users that don't exists in AD anymore. But I still see them into SharePoint.

other thing: how will Sp Manage this situation? When it will find a Document created by a User that will disappear from SharePoint ?

0

Couple of things.

Funcations:

 Function RemoveUser($LoginName,$SiteUrl) 
    { 
        #Get site 
        $Site = Get-SPSite | where {$_.url -eq $SiteUrl} 
        If($Site) 
        { 
            $Web = $Site.openweb() 
            Try 
            { 
                #Get user 
                $user = $web.SiteUsers  | where {$_.UserLogin -like "*$LoginName"} 
                #Remove user 
                if($user) 
                { 
                    $web.SiteUsers.Remove($user) 
                    write-host "Remove user $LoginName from site '$SiteUrl' successfully." 
                } 
                Else 
                { 
                    write-Warning "User $LoginName not found on site '$SiteUrl'." 
                } 
            } 
            Catch 
            { 
                Write-Error $_ 
            } 



    } 
}

then run the command like this:

 RemoveuserFromwebapplication.ps1  -LoginName "user1" -SiteUrl "http://win-chu4c2rckti:8080/sites/project"

How to remove certain user from a SharePoint site (PowerShell)

  • When a user removed from SharePoint and all the documents or items created or modified by it, assign to system account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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