Powershell script for deleting sitecollection and its content db

 want to know whether any powershell script is avlble for deleting the sitecollection and its content db at oneshot!
i have created sitecollection specific content db and i wanna delete the same.

Hi,
Below link will help to delete site collection
http://technet.microsoft.com/en-us/library/cc262392(v=office.15).aspx
Thanks
Somnath Matere

Similar Messages

  • Is it possible to recover a deleted folder and its contents as opposed to an individual file?

    When I turned on my computer today, a folder located on my desktop is no longer there.  Astounded I could have accidentally deleted it, the folder having been trashed is the only illogical logical possibility I can think of - and is a first for me in my 30 years of Mac use.  My father is in the process of dying and the folder contains all the information coming to me on the subject.  The last backup of this folder is about a week old and much has been added since for which I've no record.
    Not having a master document or table of contents listing what was in the folder leaving me unable to search for and recover individual files/documents by name, my question is this:  Is it possible to recover a "FOLDER", and its contents after that folder has been moved from the desktop to the trash, the trash emptied, and the computer having been shut down?
    If anyone has any ideas of how to recover anything about what items that folder contained, I'd really appreciate whatever thoughts you might have.
    Thanks in advance -
    The computer this folder is missing from is a early 2008 MacPro, running 10.7.5.

    I'm not sure what you can do beyond trying to restrict the types of files you search for. These apps normally have ways to select the file types or to add example files. That allows them to carve out only those types, but you still may end up with GB's of data, especially if the types are somewhat generic. I don't know of any tools that can undo changes to the disk catalog over time.
    I guess you could also search for specific text if you know that these files contained something that is 'almost unique'. Spotlight can do that, or grep, egrep are command line tools that may help ask if you want to go that route, they may help you gather lists to move files around to whittle them down.
    Sorry I can't think of a way around this it's a difficult task at a difficult time. Good luck with it, ask if you think we could help.
    I do wonder if Apples 'Versions' could help?
    OS X Lion: About Auto Save and Versions - Apple Support
    @Tony T1, do you know how to restore files from that system? I think it is part of Time Machine, but the copies are saved locally.
    It is not entirely clear how it works (at least from my memory of Lion) with regards to how you could get files back in this situation. The database should be at the base of the disk in a hidden folder ".DocumentRevisions-V100", but I don't think you can just pull files out of there. Personally I'd consider making a full disk backup before you attempt to restore files. Then you could try the 'Enter Time Machine' UI to see if it can browse back to the older Desktop.

  • Powershell script for security groups and users for multiple share folders

    Hi scripting team,
    I need your help with powershell script for the below queries 
    1. List out the security groups for more than one server share path and output it to a file ( csv ) 
    For eg.
    If the are are two share paths 
    \\servername\foldermain\folder1
    \\servername\foldermain\folder2
    So I needs the list of security groups for each share path
    And the output needs to be under each any every path.
    2. Grab the users belongs to main security groups and it nested groups for more than one security group and listed the users under each and every group. No need to display nested groups. Just users belongs to main group and users under nested.
    Your teams help is much appreciated 
    Thank you.
    Thilochana kumararatne

    Hi Braham,
    Thanks for your quick reply.
    Are we able to do this on two stage method
    1. grab the security groups from the share paths
    if can grab the share path from a separate txt file than copying it to the <your path> location
    so i can modify the txt file
    once run the script
    if can the output like below to a CSV file
    \\servername\foldermain\folder1group 1group 2group 3\\servername\foldermain\folder2group 1group 2group 3then i know which groups belongs to which share paththen i can remove the duplicate groups and keep the common groups to grab the users belongs to itso with the second script same as the first copy the security groups to a txt file and the out put as below.what I needs is the users full name and the samaccount name ( user id )group 1user1user2user3
    group 2user1user2user3looking forward your help on thisThank you.Thilo

  • Deleting directory and its contents recursively

    File clearDir = new File(dirname);
    String farr [] = clearDir.list();
    for(int i = 0 ; i<farr.length; i++){
    new File(farr).delete();
    new File(dirname).delete();
    above code only deletes directory files and directory.
    say if the there are some other directories inside,how to handle it to delete them also??

    better version with stack implementation. (not a recursive function)
    public void deleteDir(File dir){
       Stack<File> dirStack = new Stack<File>();
       dirStack.push(dir);
       boolean containsSubFolder;
       while(!dirStack.isEmpty()){
          File currDir = dirStack.peek();
          containsSubFolder = false;
          String[] fileArray = currDir.list();
          for(int i=0; i<fileArray.length; i++){
             String fileName = currDir.getAbsolutePath() + File.separator + fileArray;
    File file = new File(fileName);
    if(file.isDirectory){
    dirStack.push(file);
    containsSubFolder = true;
    }else{
    file.delete(); //delete file
    if(!containsSubFolder){
    dirStack.pop(); //remove curr dir from stack
    currDir.delete(); //delete curr dir

  • Deleting a directory and its content

    Hi, I'm trying to delete a series of directories like this batch file does
    @echo Removing "%CD%\a"
    @rmdir /s /q "%CD%\a"
    @echo Removing "%CD%\b"
    @rmdir /s /q "%CD%\b"
    @echo Removing "%CD%\c"
    @rmdir /s /q "%CD%\c"looking at the api i found that it doesn't seem to have the option to delete a dir and its content, should i use a function like the one in thread:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=188034
    or would it be better to call the batch script with Runtime.exec()? The system is windows only so i don''t need to have compatibility with *nix shells ect.
    What do you think?

    Try this
    // CLASS:    FileUtil
    // FUNCTION: An extension of File which allows various file manipulations
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class FileUtil
        extends File {
       public FileUtil(File parent, String child) throws NullPointerException {
          super(parent, child);
       public FileUtil(String pathname) throws NullPointerException {
          super(pathname);
       public FileUtil(String parent, String child) throws NullPointerException {
          super(parent, child);
       public FileUtil(URI uri) throws IllegalArgumentException, NullPointerException {
          super(uri);
       public void deleteTree() throws Exception {
          ArrayList contents = new ArrayList();
          listContents(contents);
          File f;
          for (int i = contents.size() - 1; i >= 0; i--) {
          f = new File( (String) contents.get(i));
          f.delete();
       private void listContents(ArrayList files) throws Exception {
          listContents(files, this);
       private void listContents(ArrayList files, File dir) throws Exception {
          System.out.println(dir.getAbsolutePath());
          File[] newFiles = dir.listFiles();
          File newFile;
          if (newFiles != null) {
          for (int i = 0; i < newFiles.length; i++) {
             newFile = new File(newFiles.getAbsolutePath());
         files.add(newFiles[i].getAbsolutePath());
         if (newFile.isDirectory()) {
         listContents(files, newFile);

  • Looking for help with PowerShell script to delete folders in a Document Library

    I'd like to create a PowerShell script to delete old folders in a Document library that are over 30 days old. Has anyone created something like this?
    Orange County District Attorney

    Hello Sid:
    I am trying to do the same and Iam running the script to delete the subfolders inside a folder  but I have some errors. 
    Could you please take a look?
    _______Script________
    $web = Get-SPWeb -Identity https://myportal.mydomain.com
    $list = $web.GetList("ar_mailingactivity")
    $query =  New-Object Microsoft.SharePoint.SPQuery 
    $camlQuery = '<Where><And><Eq><FieldRef Name="ContentType" /><Value Type="Computed">Folder</Value></Eq><Leq><FieldRef Name="Created" /><Value Type="DateTime"><Today OffsetDays="-30" /></Value></Leq></And></Where>'
    $query.Query = $camlQuery
    $items = $list.GetItems($query)
    for ($intIndex = $items.Count - 1; $intIndex -gt -1; $intIndex--)
       $items.Delete($intIndex);
    ________Errors_______
    Unable to index into an object of type System.Management.Automation.PSMethod.
    At C:\Script.ps1:2 char:22
    + $list =$webGetList <<<< "ar_mailingactivity"]
    + CategoryInfo
    :InvalidOperation: (ar_mailingactivity:String) [], RuntimeException
    + FullyQualifiedErrorID
    :CannotIndex
    You cannot call a method on  a null-valued expression.
    At c:\Script.ps1:6 char:24
    + $items = $list.GetItems <<<< ($query)
    + CategoryInfo
    :InvalidOperation: (GetItems:String) [], RuntimeException
    + FullyQualifiedErrorID
    :InvokeMethodOnNull

  • Mac OS 10.5 /  I deleted the " Private" folder ... and emptied the trash. So the folder and its contents no longer exists on my computer at all !!!  I do have the OS dvd that i purchased years ago...  But my computer will not start from it on its own. My

    Mac OS 10.5 /
    I deleted the " Private" folder ... and emptied the trash. So the folder and its contents no longer exists on my computer at all !!!
    I do have the OS 10.5 dvd that i purchased years ago...
    But my computer will not start from it on its own.
    My question is what is the open source or terminal language code used to tell my mac to look in the DVD rom drive for startup info?  I know that im not the only person in this world who has deleted the "PRIVATE" folder and emptied the trash so it no longer exists on their machine...
    That said theres gotta be a common fix for a Power PC G4 that has the OS X dvd in the rom drive but wont look to it to reinstall the vital contents of the PRIVATE folder.
    Once again there is not a copy of this file or its contents in the recycle bin...
    Also rebooting the machine , pressing and holding the letter C does not prompt the machine to look to the dvd rom drive.
    I was reinstalling pro tools and figured I would make some room by cleaning my computers HD...
    Lol It was a bad choice to delete this file ...
    Thanks guys

    Okay sorry it took forever to respond... But for a while there I gave up on this computer!!!!
    Money's been tight lately , so taking it in to a professional was not yet an option... though I did consider it eventhough.
    Anyway long story short im glad I didnt spend any money because I already had all the tools necessary to fix this issue but was going about it in the wrong way. Okay so here is my scenario and the breakdown... Though this may not fix the issue for everyone :( which *****... But I know we all will have different circumstances.
    Anyway here we go...
    Okay so first things first....  Years ago I purchased the OS 10.5.1 disk ... So that has always been in my possession!!!!
    I realize that some may not have a disk to reflash your OS to your hard drive... but if you do your in luck.
    2ndly ... I had an external harddrive with all of my itunes downloaded music so it was more than okay with me to delete my primary HD because all the important stuff could either be copied over or repathed to be located.
    -------If you dont want to read through the whole story the fix is summed up in the bottom section-------
    Okay so now the SOLUTION!!!!
    By trial and error , and pure boredom I opened up my computer to clean the inside...
    AND
    "Disconnected the primary HD"
    and just because ....... REBOOTED my computer. Just to see what it would do.
    Upon restart and though it looked like it would repeat its usual cycle...
    About 1 minute in to that process my computer froze for about 2 seconds and flashed to the OS installation screen.
    Mind you I havent seen this screen yet... Probably hasnt been since I installed the OS years ago.
    After a bit of trial and error...
    I decided to tell my computer to startup from the OS 10.5 disk located in my dvd rom drive and restarted once again...
    this setting is under
    Utilities / startup disk
    After a little more trial and error ... I realized that I could reconnect the primary HD , restart the machine and return to the OS installation menu.
    So upon this discovery
    I went to the Disk Utility located under Utilities
    Highlighted my primary HD located in the left hand column
    Once highlighted ...
    In the heading section on the right I selected the option
    Erase
    in which I erased My current OS on my primary HD ...
    I used the first option in the list under security... Because it seemed like the least invasive and would take the least amount of time to see if this process would actually work.
    I FORGOT to add something... 
    Another reason why I deleted my primary HD!!!!!
    I forgot to say that it WOULD NOT!!!!! Show up in the STARTUP list as an option...Even After multiple reboots....
    But like clockwork... Once I deleted its name IT SHOWED UP as an option!!!!
    So back to the next step...
    I returned to the STARTUP option under utilities ... And was then able to see MY primary HD now as a startup option...
    But ofcourse it had no name because it we previously erased it.
    So when Clicking my newly erased HD ... I was almost immediately prompted to REINSTALL the OS ...
    Which said it would take about 57 minutes ... But I believe was alot less...
    My issue was resolved ... My computer then stated the install was SUCCESSFUL!!!!!!! :))))))))))) lol ;)
    It was like I was setting up for the first time ;) asking for my registration info...
    The dilemma of deleting the private folder and emptying the trash is finally over resolved. Done ... and no extra money spent!!!!!!!!! 
    Its really crazy that the information for such a simple thing is not readily available. Especially being such a simple fix.
    I know im not the only person who's had this issue , because i've seen numerous posts with similar wording.
    I also know I wont be the last person to have this issue... So I hope this synopsis makes sense.
    -------One more time the fix------
    *Insert your OS dvd into your dvd rom drive.
    *Unplug your primary HD or corrupted startup disk
    *Reboot your machine...
    Upon restart your primary HD will not be recognized...
    * you will then be prompted to select your language.
    Once selected
    *Click Utilities/startup... Highlight the the selection that refers to the OS dvd located in the dvd rom drive.
    * Click restart...
    !!!!!!!!!!Be sure to reconnect your Primary HD Before your computer restarts and you hear the chime!!!!!!!!
    If you do not replug your HD before the chime it will not be recognized.
    In that case restart again.
    Upon restart once again
    *Choose your language...
    *Click Utilities / disk utility
    In the left column select and
    *Highlight your HD ...
    Then towards the top portion / center of the page
    *Click the heading Erase
    Then on the page toward the bottom
    *Click security options
    This will then provide erase options.
    I USED THE FIRST OPTION
    "Dont erase data"...
    *click OK
    * click erase...
    Once erased which should take a few seconds
    *Cancel the disk utility...
    * Click Utilities / startup
    And your newly erased HD should now appear in the list.
    * Select your drive from the list by highlighting
    It should no longer have a name.
    *Once selected, you will then be prompted to restart and install the OS to your newly erased HD...
    Thats it!!!!
    Once everything reinstalls re-add your personal info or registration info and you are up and running.
    Goodluck ;)

  • Help me Friends - How to Delete a Folder and its contents in java

    Hi Friends
    I want to delete a folder and its contents by passing the folderpath.
    Can any one help me in this..
    Thanks in Advance
    Regards
    Krishna

    * Delete a directory including all of its content.
    * @param directory Directory path to delete.
    public static void deleteDirectory(String directory) {
    if (directory != null) {
    File file = new File(directory);
    if (file.exists() && file.isDirectory()) {
    //1. delete content of directory:
    File[] files = file.listFiles();
    int count = files.length;
    for (int i = 0; i < count; i++) { //for each file:
    File f = files;
    if (f.isFile()) {
    f.delete();
    } else if (f.isDirectory()) {
    deleteDirectory(f.getAbsolutePath());
    }//next file
    file.delete(); //finally delete (empty) input directory
    }//else: input directory does not exist or is not a directory
    }//else: no input value
    }//deleteDirectory()

  • TS1702 some how my phone deleted an app --- My Secret Folder from my iPhone  How do I restore it and its contents  Thanks

    soem how my iphone deleted an app.  can I retore it and its contents?  How?  thanks

    Redownload it from the app store.

  • 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.

  • Executing a powershell script for checking duplicate users while creating a AD user throug ADUC console.

    Hi,
    I have a text file in which some SamAccountNames are present.I need to check the file while creating a new users through ADUC console.If a username that is going to create through ADUC console is present in the file, then it should prompt a message
    that the user is already present in the text file.
    Is there any possibility of contacting the powershell script from the ADUC console.If so, then while creating a new user through ADUC console, what is the proceedure for executing that powershell script.
    please provide me the approriate solutions.
    Thanks
    Prasanthi k

    Run the below Powershell Script for users are exist or not in AD. Later you can create the users.
    #Find Users exist in AD or Not?
    #Biswajit Biswas
    $users = get-content c:\users.txt
    foreach ($user in $users) {
    $User = Get-ADUser -Filter {(samaccountname -eq $user)}
    If ($user -eq $Null) {"User does not exist in AD ($user)" }
    Else {"User found in AD ($user)"}
    Active Directory Users attributes-Powershell
    http://gallery.technet.microsoft.com/scriptcenter/Getting-Users-ALL-7417b71d
    Regards~Biswajit
    Disclaimer: This posting is provided & with no warranties or guarantees and confers no rights.
    MCP 2003,MCSA 2003, MCSA:M 2003, CCNA, MCTS, Enterprise Admin
    MY BLOG
    Domain Controllers inventory-Quest Powershell
    Generate Report for Bulk Servers-LastBootUpTime,SerialNumber,InstallDate
    Generate a Report for installed Hotfix for Bulk Servers

  • How to create new .dat file and its contents?

    Hi There
    Can anybody let me know the procedure of how to create new .ctl or .dat file to load data to tables.
    i working on 2day dba chapter 8. it shows me how to creat table and use .dat file to load data. but doesnot giv any clue how new .dat file and its contents can be created. please help.
    thanks in advance.

    Thanks for ur help
    I ve created txt file in notepad and saved it as dat file. tried to load that data thru Enterprise manager. used load data from User files everything went well and job was showing suceeded but dont know why that data is not showing in the table. i ve tried it now for three four times. used right table and pathe but dont know. has anybody got idea why that ll be?
    Thanks

  • PSE9: How do I move/copy an Album and its contents from my PC to my laptop?

    I am using Windows 7 and PSE 9 on my PC and want to get a copy of the album and its contents to my Vista laptop running PSE 9 without changing anything on the source PC. Anyone know how to do this? I know I can move the files through Windows Explorer on my network but I have already gone through the trouble of putting the best photos into an Album and would like to simply move the Album over and not have to go through the trouble of recreating it.

    You will need to copy the files.
    1. Make a new folder on your laptop
    2. Open Organizer, select your Album then press Ctrl+A to select all photos
    3. Click the Fix tab and choose Full Photo Edit to open the album contents in the editor
    4. Click File >>Process Multiple Files
    5. From the drop down menu (Process files From) choose Opened Files
    6. For destination click the browse button and navigate to your new folder on your network and click OK
    7. Make sure Rename and Resize is unchecked but check Convert files To and choose Jpeg Max quality or whatever you prefer then click OK and wait for Elements to finish.
    8. Go to your laptop folder to see your images.

  • How to move some xml element and its content to a new frame

    Hi All,
    How to move some xml element and its content to a new frame.

    Hi Chinnadk,
    Sorry my code its comment some lines. Now only I check the forum thread, you just try one more time.
    #target InDesign;
    #include "/Program Files (x86)/Adobe/Adobe InDesign CS5.5/Scripts/XML Rules/glue code.jsx"
    var myDoc = app.activeDocument;
    //____________________ XML RULE SET
    var myRuleSet = new Array (new margintag);
    with(myDoc){
        var elements = xmlElements;
        __processRuleSet(elements.item(0), myRuleSet);
    function margintag(){
        this.name = "margintag";
        //this.xpath = "//margintag[@type='mn2']";
        this.xpath = "//margintag";
        this.apply = function(myElement, myRuleProcessor){
            with(myElement){
                app.select(myElement);
                try{
                    var myPrePara = app.selection[0].paragraphs[-1].parentTextFrames[0].paragraphs.previousItem(app.selection[0].paragraphs[-1]);
                    if(myPrePara.characters[-1].contents=="\r"){
                        myPrePara.characters[-1].remove();
                    var myTextframe = myElement.placeIntoInlineFrame(["7p9","6p"]);
                    myTextframe.appliedObjectStyle= myDoc.objectStyles.item("MN1");
                    myTextframe.fit(FitOptions.FRAME_TO_CONTENT);
                    myTextframe.parentStory.paragraphs.everyItem().appliedParagraphStyle = app.activeDocument.paragraphStyles.itemByName("MN1");
                    }catch(e){}
                app.selection = null;
            return true;
    thx,
    csm_phil

  • PowerShell: Script to delete files older than X days

    Hi All,
    I am testing a script to delete files and I have it written down in my notepad as below:
    $foldername = $args[0]
    $maxage =      $args[1]
    gci $foldername | Where-object {($_-is [io.fileinfo]) -and ($_.lastwritetime -lt (get-date).AddDays(-$maxage) ) } |
    remove-item -whatif
    Question: When i try to run the script and  pass the parameters $foldername and 30 it doesn't return anything. I am expecting it to return with -Whatif
    To execute the script I wrote:
    .\myscipts\del.ps1  cmd2 30
    cmd2 is the name of the folder in my drive and 30 is ($maxage)  number of days old.
    Thank-you
    SQL 75

    Thansks jrv, looks good! One more thing I wanted to ask do you know what it means by the error:
    "An Empty Pipe Element is not Allowed" I altered my script a bit but it gives me this error. and I am passing no parameters when i call the script. My Script I created is below:
    $name = $args[0]
    $chew = $args[1]
    IF ( $args.count -lt 2)  { Write-host "Please provide 2 parameters for this to work"
                    exit 1 }
    GCI $name | Where-object { $_-is [io.fileinfo]  -and ($_.lastwritetime -lt (get-date).AddDays(-$chew))}
     | remove-item -whatif
    Thank-you
    SQL 75

Maybe you are looking for

  • Is there a way to find out how long my child has been playing with my ipad

    Is there a way to find out how long my child has been playing with my ipad???  He has been getting up before me in the morning and in the evening he is super tired and I'm wondering how early he has been getting up????

  • Is it possible to have a oversea's number which ca...

    I need to set up a skpe phone number for an oversea's country but it then needs to be answered in the UK which out the caller knowing - is this possible and if so how do i go about doing it

  • AIR Native extensions Hello World Example for iphone ios

    I need help as i am having runnable code library for Hello world which i took from the url, "http://akabana.info/2011/08/11/air-native-extension-10-try-air-for-ios-ane/" in which we are making static library in Xcode by using ADOBE AIR.framework so t

  • Cancelling a duplicate Order

    While pacing an order of  $60, for 12 months, Skype Number, something unknown  issue happend and two orders are placed showing two orders each for $60 on my account as well as my card. I want to cancel one of the orders and want to keep only one. Can

  • About the idoc(DEBMAS) inbound, contact info, need help!

    Hi everyone, we have SAP and SIEBEL system, and crate/update customer info(or say account) at SIEBEL first, then send account info to SAP via IDOC, message type is DEBMAS06. Now there is a bug. create/update contact info at siebel, it always create n