Using Powershell to delete all users from the Portal

Summary
This script will delete all users from the Portal except for Administrator and the Built-In Sync account.
Based on Markus's "Delete a User" script.
Useful when developing your system if you want to quickly clear out the data and start again.
set-variable -name URI -value "http://localhost:5725/resourcemanagementservice' " -option constant
function DeleteObject
PARAM($objectType, $objectId)
END
$importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
$importObject.ObjectType = $objectType
$importObject.TargetObjectIdentifier = $objectId
$importObject.SourceObjectIdentifier = $objectId
$importObject.State = 2
$importObject | Import-FIMConfig -uri $URI
if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}
$allobjects = export-fimconfig -uri $URI `
–onlyBaseResources `
-customconfig "/Person"
$allobjects | Foreach-Object {
$displayName = $_.ResourceManagementObject.ResourceManagementAttributes | `
Where-Object {$_.AttributeName -eq "DisplayName"}
if([string]::Compare($displayName.Value, "Administrator", $True) -eq 0)
{write-host "Administrator NOT deleted"}
elseif([string]::Compare($displayName.Value, "Built-in Synchronization Account", $True) -eq 0)
{write-host "Built-in Synchronization Account NOT deleted"}
else {
$objectId = (($_.ResourceManagementObject.ObjectIdentifier).split(":"))[2]
DeleteObject -objectType "Person" `
-objectId $objectId
write-host "`nObject deleted`n" $displayName.Value }
Go to the FIM ScriptBox
http://www.wapshere.com/missmiis

The DeleteObject function opens and closes a connection for each object.  This approach is faster:
http://social.technet.microsoft.com/wiki/contents/articles/23570.how-to-use-powershell-to-delete-fim-users-that-have-a-null-attribute-name.aspx
Mike Crowley | MVP
My Blog --
Planet Technologies

Similar Messages

  • I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I

    I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I try to launch it, I get a screen headed Photoshop CS5 Extended Trial.  It asks for the serial number and says that my trial has expired.  It rejects the serial number from the Adobe case saying "This Serial Number is not valid for this product".  It thinks that I still have the expired Trial Version installed.  How do I convince it (the program) that the Trial Version is long gone and the currently installed product was installed with a valid and accepted serial number????

    Let me know how it goes. Go into your Adobe account and register your serial number asap.
    https://www.adobe.com/account/my-products-services.html
    That way, should you lose it or you need support, it is on record that it's yours and you can fetch your s/n it from anywhere.
    There are too may sad stories here, where people forgot and the box is buried or lost.
    Gene

  • Delete all entries from the following tables - Follow-up Activities (oracle)

    Hello,
    I performed a homogeneous system copy of our development BW system with the database (oracle 11.2.0.3) from the BW production system!
    I already start the oracle database and the SAP system in the target system/server (development BW system) and I´m doing some follow-up activities. One of this activities is (at the system copy guide 6.2.3.2 Activities at Database Level) is to delete all entries from the following tables:
    DBSTATHORA, DBSTAIHORA, DBSTATIORA, DBSTATTORA
    I tried to delete them using SQL Plus:
    sqlplus /nolog
    SQL> connect /as sysdba
    SQL> delete from DBSTATTORA;
    delete from DBSTATTORA
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ... and it show me that error message.
    This is strange because when I go to transaction SE14 and check the DBSTATTORA I see that table exist and contain a lot of entries!
    Why this is happened in SQL Plus!? I´m running the correct SQL statement for doing this type of task or not?
    How can I delete the entries of that tables? Can I do that using the transaction SE14?
    Can you help me please?
    Thank you,
    samid raif

    Hello
    sqlplus /nolog
    SQL> connect /as sysdba
    SQL> delete from DBSTATTORA;
    delete from DBSTATTORA
    ERROR at line 1:
    ORA-00942: table or view does not exist
    It doesn't surprise me as you are not mentioning the schema name here. Instead it should be
    delete from SAPSR3.DBSTATTORA;
    Assuming the schema owner is SAPSR3. if the owner is different then replace that with the correct one.
    Regards
    RB

  • How to Use PowerShell to Delete FIM Users That Have a Null attribute name

    FIM Community Information Center Article
    Wiki Page:
    How to Use PowerShell to Delete FIM Users That Have a Null <attribute name>
    Go to the FIM Community Information Center
    Mike Crowley | MVP
    My Blog --
    Planet Technologies

    Have you run side-by-side metrics on this?
    I've run the Delete Object method and your script against similar data sets and yours appears to take a fair bit longer. I'd have to re-run in identical circumstances, a few times, to really say for sure, but my initial impression is that it will take hours
    longer.
    I guess the point is somewhat moot anyway, as for me the bit that generally takes longest is the actual query, rather than the deletions.
    Boy how I wish I could just enter something into the FIM Portal directly that would blast out a bunch of users matching a query. One day...
    FIMSpecialist.com | MCTS: FIM 2010 | Now Offering
    ECMA1->ECMA2 Upgrade Services

  • How to retrieve all users in the portal with UME API

    Hi everybody,
    I would like to know how to retrieve all the users from a portal, which uses LDAP as a source (there are users created in the portal as well)
    My code snippet is :
    IUserFactory userFactory = UMFactory.getUserFactory();
    UserSearchFilter searchFilter = userFactory.getUserSearchFilter();
    searchFilter.setDisplayName("*", ISearchAttribute.LIKE_OPERATOR, false);
    ISearchResult searchResult = userFactory.searchUsers(searchFilter);
    My problem is that with the code above, only the users created in the portal are displayed, and no LDAP users.
    Does someone know how to retrieve all the users whatever is the source?
    Regards
    Renaud

    prakash's code should work.
    however, mine code below doesn't user a search filter. it retrieves everyuser including users like indexadmin etc. Note:
    result.next().toString();
    returns a weird uniqueID used in the portal world.
    getUniqueName()
    gives your the usernames (sAMAccountName in Microsoft AD) people use to logon to the portal.
    try {
      IUserFactory uf = UMFactory.getUserFactory();
      ISearchResult result = uf.getUniqueIDs();
      while (result.hasNext()) {
        String uniqueid = result.next().toString();
        IUser user = uf.getUser(uniqueid);
        String userid = user.getUniqueName();
    } catch(Exception e) {
      //systemout

  • How to get all users from the server....?

    Hi all,
    in my application i want to get all possible users present in the PORTAL-EP Server
    and set them into the drop down.
    is there need to login in the portal as a admin or other user to get the all users present in the Server.
    Regards,
    Deepak

    Hi! Deepak,
       you can use UME API to get all the users of EP in WebDynpro appl.
    Herewith i am giving you the UME API link --
    <a href="http://help.sap.com/javadocs/NW04/current/um/index.html">http://help.sap.com/javadocs/NW04/current/um/index.html</a>
    i am giving the code also to get all the users from LDAP.
       IPublic<ComponentName>.IUserIDElement userIDNodeElement = null;
    IUserAccountFactory accountFact = UMFactory.getUserAccountFactory();
    MessageManager msgMgr = (MessageManager)wdThis.wdGetAPI().getComponent().getMessageManager();
    try {     
    IUserAccountSearchFilter accountSearchFilter  =  accountFact.getUserAccountSearchFilter();
    accountSearchFilter.setLogonUid("*",ISearchAttribute.LIKE_OPERATOR,false);
    ISearchResult srchRslt = accountFact.search(accountSearchFilter);
       while(srchRslt.hasNext()) {                    
                    userIDNodeElement = wdContext.createUserIDElement();          String uniqueID = (String)srchRslt.next();
         IUserAccount userAccount = accountFact.getUserAccount(uniqueID);
         String LogonUid = userAccount.getLogonUid();
         userIDNodeElement.setCtx_UserID(LogonUid);
         wdContext.nodeUserID().addElement(userIDNodeElement);
        } catch(Exception exc) {
                  msgMgr.reportWarning(umException.toString());
    regards,
    Mithilehwar

  • How do I delete all photos from the iPhone?

    Hi,
    I want to delete all the photos from my iPhone4 running iOS5. I have copied all the photos on my HDD. I cant use the individual delete process as i have almost 2500 images.
    Thanks and Regards,
    SatyajeetB

    Delete the pictures in the "camera roll" using computer.
    On Windows:
    Open up the DCIM folder from "My computer", select all the pictures/videos (Ctrl + A) and hit delete.
    You could have selected the option "erase after importing" while importing the pictures on to your HDD.

  • Jar file is not working after deleting all packages from the same directory

    hello
    i have created a jar file named as server.jar in the same directory in which i have all the packages(for which i have created this jar file).This jar file was working correctly when i had all the packages in the same directory.But after deleting all the packages from the same working directory, this jar file is neither working nor giving any error message..
    Please tell me what may be the reason???
    thanks in advanced

    hello
    i have created a jar file named as server.jar in the same directory in which i have all the packages(for which i have created this jar file).This jar file was working correctly when i had all the packages in the same directory.But after deleting all the packages from the same working directory, this jar file is neither working nor giving any error message..
    Please tell me what may be the reason???
    thanks in advanced

  • Is there an app that lets me delete all images from the camera roll at once?

    It is unbelievably ******** that apple doesn't offer an intuitive way of selecting all photos in the camera roll to facilitate deleting them. Is there an app that provides this funtionality?
    Think about how common the task of deleting images can be... I take multiple pictures of a moment, object, scene etc because I know the focus will be wrong on a few and the colors or lighting will be different even for photos taken consecutively within a short period of time (because of differences in how the camera is held and other constantly changing variables.) I only want to keep one of the many photos I take and don't want to waste storage on the other bad pictures. Additionally I would prefer to not have them lingering around such that they can be forgotten and then inadvertantly shared or whatever.
    If Apple won't do the right thing and add this functionality then I assume someone else has written an app and fixed it for them...so is my intution correct? And if so what is the name of this app?

    The iPhoto app provides the capability to delete all the photos in the Camera Roll.
    See https://itunes.apple.com/us/app/iphoto/id497786065?mt=8

  • How to delete all books from the iTunes library which no longer exist on my iPod?

    I was looking through my iTunes libraries today, and I realised that my "books" library was absolutely chock full of old books that I had previously downloaded and deleted years ago, as well as all the books I still currently own/use.
    How can I delete (within iTunes) all of the books that are no longer on my iPod, without going through them all one by one?
    I know for apps you can just delete them all in iTunes and then choose "import purchases" to perfectly replicate apps between the iPod and iTunes, but I don't think you can do that with books.

    After cleaning the library you can connect the device and use the transfer purchases option to copy over those still on the iPod.
    I should add that it is probably a good idea to use Edit > Preferences > Devices and tick Prevent iPods, iPhones, and iPads from syncing automatically.
    tt2

  • Unable to find any record with GUID/Deleting old users from the Proxy DB

    It seems that I have old users in my proxy db that need removing as per the below post.
    http://discussions.apple.com/thread.jspa?messageID=8062329&#8062329
    The problem, I have is that after I have ran the python script as per this link:
    http://trac.calendarserver.org/wiki/ProxyCleanup
    I get the following response:
    +diary:~ root# sudo python /Users/admin/Desktop/proxyclean+
    +CalendarServer proxy DB clean-up tool+
    =====================================
    +Parsed: /etc/caldavd/caldavd.plist+
    +Found DS Node: /Search+
    +Found proxy DB path: /Library/CalendarServer/Calendar Files/principals/.db.calendaruserproxy+
    +Loading /Users records from OD: /Search+
    +Found 104 /Users records+
    +Reading proxy DB: /Library/CalendarServer/Calendar Files/principals/.db.calendaruserproxy+
    +Found 1 proxy DB records+
    +Failed: need more than 1 value to unpack+
    Could this have something to do with the fact that I have my iCal Server bound to my ODM?

    Additionally, can you confirm that all server components are running the latest updates, as are the clients / phones involved in the conference?
    I've seen this exact behavior when the invite / adding of additional participants was being performed ad-hoc on a CX3000. It transpired that a firmware upgrade on that device rectified the problem.
    Kind regards
    Ben
    Blog:www.gecko-studio.co.uk/ 
    Twitter:
      LinkedIn:
      Facebook:
    Note: If you find a post informative, please mark it so using the arrow to the left. If it answers a question you've asked, please mark the thread as answered to aid others when they're looking for solutions to similar problems
    or queries.

  • How do you delete all contacts from the iPod

    When I sync a new iPod it pulls all of the contacts that my iPhone has.  How do I delete them from just the iPod?

    Are you using the same iCloud ID on both devices?
    Is Contacts turned on in Settings>iCloud?
    If so then you will have the same contacts.
    Are you syncing contacts fro other services like Google contacts?

  • I deleted all songs from the iPad multiple times.  Each time I reconnect and sync all of these songs sync instead of the chosen playlist. Settings on Summary page are Sync Only Selected Songs and Videos. Music only the playlist is checked.

    How to I stop iTunes from reloading what was on the iPad instead of what I have selected?  Summary screen shows "Sync only checked songs and videos"  Music has only the selected playlist.  All songs were deleted from iPad by swiping them to the left and hitting delete (very time consuming).  Sync is set to manual.  However whenever I hit Sync, the old music gets put back on the iPad.  I have had this happen at least 6 times.

    Solved it.  "Automatically fill free space with songs" was checked on the Music page.  Worked perfectly once this was unchecked.

  • Some of the albums in the Beatles package I downloaded from itunes will not sync with my iPhone 5. Some songs won't play. They did sync to my iPad and they all play on my iPad. What can I do? I've already deleted all songs from the iPhone and re-synced.

    I downloaded the entire Beatles collection from iTunes in 2011. Some songs skip and won't play. Some albums won't sync to the phone but they sync to my iPad. I've deleted the entire music library from my iPhone, shut the phone down, turned the phone on and synced again to add the music but now 2 albums won't even sync (Rubber Soul and Revolver). I've tried dragging the songs to the iPhone, no luck. Any thoughts?

    Sounds like you may need to re-download the entire albums from iTunes. See this KB article for how to download past purchases: http://support.apple.com/kb/HT2519.
    I'd suggest doing it one album at a time. Delete one, download it from your purchase histor, then the next, etc.

  • How do you delete all apps from the purchased category on your iPad?

    How do you delete the purchased category from your ipad2?

    That's not possible. Your purchased apps are also available on your computer in iTunes / View My Account / Purchase History.

Maybe you are looking for

  • Dropdowns in Adobe Acrobat XI Pro

    Is there coding that I can use to have a dropdown expand so the items are shown when the user tabs to the dropdown?

  • Can we use exceptions and conditions at the same time?

    can we use exceptions and conditions at the same time? Are there any dependencies between exceptions an conditions?

  • Javascript: Can't get background source

    I'm trying to create script that will allow the user (on mouse over) to choose from one of a several banners to appear while they are on site. First I'm not sure if my logic is correct, and that is a simpler way. but here is what I got the CSS loads

  • Mxmlc / compc: automatically link in all source files?

    In the standard configuration, compc and mxmlc only link in classes actually used by your project. We're using code generation to get ActionScript classes from our Java classes for AMF serialization. We deal with most of these generically, so we don'

  • Photoshop (and other suite programs) freeze up continually (OSX)

    Hey people, I thought I'd ask here before contacting support. I've bought the Adobe Web Premium CS4 package a while back (when they just released CS5) and I'm having huge issues now. Basically all my Adobe applications freeze up directly or do so whe