Using PowerShell in SharePoint 2010 – First steps


Hello @all,

today i play a bit with our new powershell cmdlets in O14.

1) how to get a list of all available cmtlets?
Answer: get-help *
(i prefer to write the output into a text file by: get-help * > c:\o14_pws_cmdlet.txt)

As next step how to create new contentdbs, attach, detach and remove them

2) How to create new contentdb for a web application:
Answer: New-SPContentDatabase

image

e.g: New-SPContentDataBase –webapplication http://o14-4514 –Name o14_4514_WSS_Content_3

image

3) enumerate all contentdbs of one WebApplication:
Answer: GET-SPContentDatabase –webapplication http://o14-4514

image

4) how to detach a contentdb?
Answer: Dismount-SPcontentdatabase –identity <GUID>

image

Note: the contentdb exist still in SQL server.
image

5) how to attach a contentdb?
Answer: mount-SPcontentdatabase –name o14_4514_WSS_content_3 –webapplication <url>

image

The next command is new, please be careful with
6) how to delete a database on SQL server?
Answer: Remove-SPcontentdatabase –identify <guid>

image

image

Now , take a  look on SQL Server: *RIP for “o14_4514_WSS_content_3”, it’s deleted on SQL server
image

Regards

Patrick

Comments (3)

  1. Mai Omar says:

    Patrick, your blog did the trick for me...

    i migrated and it workedddddddddddddd.... voilaaaaaaaaaaaaaaaaaaaa

    thanks u.

    with my regards;

    Mai Omar.

  2. mv says:

    Hi, how to remove-spcontentdatabse without confirm ? thanks

  3. How to confirm remove-spcontentdatabase says:

    hello Mai, hello MV,

    it took me some time to get it running 🙂 the trick is the following...

    "There are two confirmations here. The confirmation level is high but you also need -Force to bypasses this second warning."

    the command will be: "remove-spcontentdatabase -identify $db -confirm:$false -force"

    Regards

    Patrick

Skip to main content