Remove SP User from SharePoint subsite

Hello All,
I am trying to remove a user account form all sub sites except few.
I am making use of following command.
Remove-SPUser "Contoso\jdoe" -web http://webapp/sites/site1/web1/
 But this command is removing the user from all the sub sites including the site collection.
Can anybody please help to delete the user from specific subsite only.
Thanks & Regards
MD Liakath Ali
MD.Liakath ali

Hi,
You can try to delete user from specific SharePoint group at sub site level using Power shell script as below .
#Remove
user from SP Group
    $theGroup.RemoveUser($theUser);
Fine
more details on below blog
http://markimarta.com/sharepoint/add-remove-user-to-sharepoint-groups-with-powershell/
Regards
Soni
K

Similar Messages

  • Unable to remove user from SharePoint Group using PowerShell

    I am trying to remove a user from a SharePoint Group using PowerShell.
    I can see the user in the Site Collection as part of the SharePoint Group, however, when I attempt to run the script, I get an error message stating "Can not find the user with ID: 10"
    Below is the PowerShell script that I am using:
    $url = "https://sharepointdev.spfarm.spcorp.com/sites/desitecoll"
    $userName = "spfarm\sp2013_svc"
    #$userName = "spfarm\spprofileimport";
    $site = New-Object Microsoft.SharePoint.SPSite($url)
    $web = $site.OpenWeb()
    $siteGroups = $web.SiteGroups;
    Clear-Host
    $mySiteGroups = @();
    foreach($group in $siteGroups)
    Write-Host $group
    $mySiteGroups += $group;
    }#foreach
    $members = $web.SiteGroups[$mySiteGroups[0]];
    $owners = $web.SiteGroups[$mySiteGroups[1]];
    $visitors = $web.SiteGroups[$mySiteGroups[2]];
    #Remove the user from the specified SharePoint Group
    $spUser = Get-SPUser -Identity $userName -Web $url
    Write-Host $spUser.ID
    Remove-SPUser -Identity $spUser -Web $url -Group $owners
    $web.Update();
    $web.Dispose();
    Write-Host "User " $userName "removed from " $owners
    Please advise.

    I had to update the code to the following because Get-SPUser was not working properly:
    $url = "https://sharepointdev.spfarm.spcorp.com/sites/desitecoll"
    $userName = "spfarm\spprofileimport";
    $site = New-Object Microsoft.SharePoint.SPSite($url)
    $web = $site.OpenWeb()
    $siteGroups = $web.Groups;
    Clear-Host
    $mySiteGroups = @();
    foreach($group in $siteGroups)
    Write-Host $group
    $mySiteGroups += $group;
    }#foreach
    $members = $web.Groups[$mySiteGroups[0]];
    $owners = $web.Groups[$mySiteGroups[1]];
    $visitors = $web.Groups[$mySiteGroups[2]];
    #Convert the user name to an SPUser account
    $spUser = $web.Site.RootWeb.EnsureUser($userName);
    Write-Host $spUser.ID
    Remove-SPUser -Identity $spUser -Web $url -Group $owners
    $web.Update();
    $web.Dispose();
    Write-Host "User " $userName "removed from " $owners
    Was I not using Get-SPUser correctly?

  • Remove users from Sharepoint site security group

    I have to close a share point 2007 site for all users for an update. I don't have access to CA. the easiest approach is to remove the users from security group and add them back when the site modification is done. All users all under "NT/Aunthenticated
    users" and they are in Members group. I'm just wondering will it cause any issues when adding them back or it can be done in 1 click. Do i need any tweaks from CA side to add them back?
    Any response is appreciated.
     Thanks!

    Once you add the users back to the site, it should work as expected.
    >>Do i need any tweaks from CA side to add them back?
    No i believe, because you are changing the permissions at site level.
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

  • Trouble removing a user from creative cloud for teams

    I am trying to remove a user from my team, however the X does not show the pop up menu with the option to remove them.  Also, when I click on any item on the left hand menu, nothing happens.

    Sorry... This is an open forum, not Adobe support... You need Adobe support to cancel a subscription
    -start here https://forums.adobe.com/thread/1703848
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html
    --and two links which may provide more details, if the above links don't help you
    -http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html

  • Shared Services 11.1.2 Unable to remove assigned user from a security group

    In Shared Services 11.1.2 - trying to remove a user from the assigned users list of a security group. Initially, I am able to remove the user and the assigned users total decreases by one - but when I relaunch the group properties - this user is still in there? The change does not hold. Any suggestions would be appreciated - thanks,
    Paul

    Hello Paul,
    Not sure if this is related to yours, but it might be worth having a look at the following articles on Oracle support --
    External users in EPM Shared Services (e.g. MSAD users) cannot be removed from Native groups if they have multiple IDs in the external user directory. [ID 1526569.1]
    Users from External User Directories Cannot be Removed from Native Groups [ID 1272309.1]
    Thanks,
    hyperionEPM
    Please mark answers as correct or helpful for others to find them easily.

  • Remove a User from Catalog

    can anyone provide some sample code for removing a user from the BI Beans catalog?
    thanks
    Julian

    Users are maintained using PL/SQL scripts in the JDEV_HOME/bibeans/bin. There are two scripts
    REMOVEUSER.SQL
    REMOVEGROUP.SQL
    Business Intelligence Beans Product Management Team
    Oracle Corporation

  • I just deleted a license on accident when I thought I was removing a user from a seat.  How do I get that license back?

    I just deleted a license on accident when I thought I was removing a user from a seat.  How do I get that license back?

    Adobe contact information - http://helpx.adobe.com/contact.html may help

  • Removing a User From SAP and Webtools

    I have recently removed a user from SAP which was a user from webtools
    i removed their license and removed them from webtools
    My issue is that i now have a Sync Error
    -10:Selected user was deleted
       at NetPoint.SynchSBO.WebToolsChildObjects.AccountUser.SynchOUSR(NPUser u)
       at NetPoint.SynchSBO.WebToolsChildObjects.AccountUser.NetPointToSBO(NPQueueObject qData)
       at NetPoint.SynchSBO.SynchObjectBase.Synch()
    What can i do to remove this error?
    Please notify.
    all answers and suggestions will be greatly appreciated

    User probably still exists in WebTools. Try to find & remove it.
    If this doesn't help, you can remove user from synchronization queue:
    1. run SynchManager
    2. on page Synchronization click on tab Web tools Queue
    3. find row with 'Name' equal NPUser; click on number in column 'Fail'
    4. select row containing error message
    5. press <Delete>
    6. run synchronization

  • Cannot remove deleted user from people picker - SharePoint Foundation 2010

    So I think I've read all the people picker articles here and I can't find a solution so I thought I'd start a new thread. Here is the issue:
    A user was deleted from Active Directory and removed from SharePoint Foundation 2010. The user was still showing in the People Picker within the site collection, so we have performed a few things to try and get rid of this user.
    User is deleted from AD
    User is deleted from SharePoint Site Collection
    Have tried stsadm -o deleteuser
    Have removed all mention of this user from UserInfo table
    User does NOT show in
    https://<SiteCollectionURL/_layouts/people.aspx?MembershipGroupId=0
    Cannot find any mention of this user anywhere.
    Ran a full crawl as we read on a forum somewhere that it might help.
    If I try and add the user back to SharePoint I get "The user does not exist or is not unique"
    If I try "stsadm -o deleteuser -userlogin DOMAIN\USER -url https://<sitecollectionurl>" I get "The user does not exist or is not unique"
    I am not sure what else I can try now. Can anyone help?
    Thanks,
    Vinny
    Vinny

    No other domain trusts that this user could be in.
    Just so everyone can stop with the warnings, we do NOT regularly delete users from the UserInfo table and fully are aware of the problems behind it, which is why it is so rarely done. But at times, you have to do what you have to do to help a customer, you
    know? This one user is the only one that was removed from the UserInfo table, but there are a few other users that are also deleted (from SharePoint, not manually from UserInfo) that are still showing as well. This one user included.
    There MUST be another place that the people picker gets it's information from. ALL of the user's old information still shows in the people picker (username, email address, display name), and yet none of that information exists anywhere other than in the
    People Picker. Mailbox is gone from Exchange, User deleted from SharePoint, User deleted from Active Directory. Is there no cache someone could point me towards that People Picker might store information in.
    Vinny

  • Adding and removing current user from one SharePoint group to another with event receiver

    hi friends
    i need to change current user from one SharePoint group to another with list item adding event receiver.
    please help me

    Hi Malli,
    Greetings. Its nt possible
    http://sharepoint.stackexchange.com/questions/42286/event-receivers-on-add-remove-users
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Powershell script for removing some users from a particular Site Collection

    Hi,
    I am looking for a PowerShell script to delete a few users from a particular Site Collection. I am unable to delete them from/_catalogs/Users/simple.aspx page therefore need some other medium to
    delete users from the site collection.
    My ultimate aim is to have no user profile with "tp_deleted" field's value as 0 in the USERINFO table. Currently there are about 40 odd users with this field's value as 0 and this is affecting my crawling of this content database.

    Thanks for the reply Alex & eHaze,
    I have a content source of root site which crawls all the site collections under it. Out of the 9 site collections, only 8 are getting crawled and 1 doesn't get crawled at all. The error in the crawl logs is 
    The SharePoint item being crawled returned an error when requesting data from the web service. ( Error from SharePoint site: Value does not fall within the expected range. )
    I tried a lot of things, searched over the net and finally found
    this which helped me solve the same issue in my development environment. I deleted these users from userInfo table and ran a full crawl. And the issue was fixed.
    Now since I cannot delete the users from userInfo table directly from PROD environment, I used .../_catalogs/Users/simple.aspx list
    to delete users from this site collection. While some of the users I could delete, quite a few I could not. Clicking on the profile redirected me to the home page rather than the info page of the profile. 
    This
    is why I have to delete these users from the site collection.
    Alex - the link you shared, I guess it is for a web application level.
    eHaze - the script you shared throws this error:
    Get-SPSite : Cannot find an SPSite object with Id or Url: http://dev-apps/divisions/BT. At C:\PowerShell Scripts\DeleteUserFromSiteCollection1.ps1:4 char:19
    + $site = get-spsite <<<< $siteURL
    + CategoryInfo : InvalidData: (Microsoft.Share...SPCmdletGetSite:
    SPCmdletGetSite) [Get-SPSite], SPCmdletPipeBindException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite
    You cannot call a method on a null-valued expression.
    At C:\PowerShell Scripts\DeleteUserFromSiteCollection1.ps1:9 char:27
    + $site.SiteUsers.Remove <<<< ($LoginName)
    + CategoryInfo : InvalidOperation: (Remove:String) [], RuntimeExc
    eption
    + FullyQualifiedErrorId : InvokeMethodOnNull
    hope this info helps.

  • Looking for Help with Active Directory Script to Remove a User from msExchDelegateListLink

    I'm struggling to put together an Active Directory Powershell script that will remove a specific user from the msExchDelegateListLink.
    It looks like Set-AdUser would do the trick. I would want to remove a user in the format of
    {CN=Wood\, Sandy,OU=Networking,OU=IT,DC=my,DC=domain,DC=com}
    Has anyone succeeded in doing this before?
    Orange County District Attorney

    I use this:
    $user = '<user name>'
    $userDN = Get-ADUser $user | select -ExpandProperty DistinguishedName
    $delegates = Get-ADUser $user -Properties msExchDelegateListBL |
    select -ExpandProperty msExchDelegateListBL
    foreach ($delegate in $delegates)
    Set-ADUser $delegate -Remove @{msExchDelegateListLink = "$UserDN"}
    Never quite got around to putting it into a function.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • How to remove one user from SSO in ESS

    Hello Team,
    We  have configured ESS with sso and working fine but onw user wants to remove his user id from sso as he shares his pc with others too. Please let me know can this be done and how?
    Best Regards,
    Tushar.

    Hi Tushar ,
    what raghavendra suggested is correct.
    if user wants to share with PC to some other person . He need not to login to portal . without having ESS role how he access ESS applications .  except logging to portal he can share with PC to others .
    and ESS point of view 1 to 1 mapping , no user mapping .
    Surekha.

  • Adding Users from sharepoint into Active Directory Groups

    I have a requirement for Approval Workflow where the Approved User gets added   to AD group directly,i think 2 way sync is possible.plz help

    Out of the box, I really doubt that this is possible BUT it can more than likely be achieved via the Object Model.  A good discussion and some attached code can be seen here.
    https://social.technet.microsoft.com/Forums/office/en-US/a1905a01-e7a7-458b-a7a6-d24cd4e19e09/action?threadDisplayName=add-a-user-in-ad-group-from-sharepoint
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • HT204266 how do I remove a user from app store

    The app store will not allow me to update my apps without updating a user that was the previous owner of the laptop. How do I remove this person from the computer etc.

    If you mean an iTunes store id then Settings > Store - touch the id on the right and select sign-out from the popup. You can also do it via the bottom of the Feature tab in the App Store app. If you have any apps on the iPad that were downloaded/installed via that id then you may want to delete them - if updates for them ever appear in the App Store then you will only be able to update them via the id that was used to buy them (apps are linked to the account id, not to the device that they are on)

Maybe you are looking for

  • Gmail Syncing Problem

    My 2G iPod Touch is giving me a headache. For the past few days my Gmail account which is set up for the mail.app isn't working right. When I send an email or delete an email all the messages are put in the default "All Mail" folder the app creates a

  • START UP ERROR;  Please upgrade your video display drivers.

    I recently updated to the latest version of Premiere Pro CC (2014) and when I opened it I got the message about updating the video drivers as it could not find any capable play modules. I have looked everywhere on how to update the drivers but have f

  • Need explanation

    hi,i have 3 jsp pages a login.jsp, authenticate.jsp and portal.jsp. authenticate checks the users name and password and if correct forwards to the portal page with details. so if i am in the portal page, and i hit the back button, and return to the l

  • Panel rendering problem

    HI, What is the difference between the 2 following pieces of code: 1)            UIPanel tab= new UIPanel();           tab.setRendererType("javax.faces.Grid");           tab.getAttributes().put("border","1"); tab.getAttributes().put("columns","4"); 2

  • Controlling the Windows cursor?

    Hi, I have a motion capture system, which I can read coordinates of markers from using LabVIEW 2009. I'd like to use that to control the Windows cursor (for a bit of fun). I've had a quick play with ActiveX and .NET, but I am no expert. How should be