Deleting an Office 365 Site Collection using PowerShell

In the last post I showed you how to remove a complete Office 365 SharePoint Online site collection via the web interface. Now I’ll show you to do it with PowerShell.

image

This time I want to remove a site collection whose URL is https://ciaops365.sharepoint.com/sites/bootcamp. You can see that it appears in the list of sites in the web interface.

image

You’ll need to connect to Office 365 PowerShell and SharePoint Online via PowerShell firstly.

Then you need to run the following command:

remove-sposite –identity –nowait

thus in my case:

remove-sposite –identity https://ciaops365.sharepoint.com/sites/bootcamp –nowait

You’ll then be prompted to confirm the deletion. Press Y to delete the site and send it to the recycle bin.

image

If you refresh the page with the list of site collections the deleted site collection no longer appears.

image

If you now got to the sites collection recycle bin you will see both sites that have been deleted. One via the web interface and the one just now via PowerShell.

image

PowerShell provides you an ability that the web interface doesn’t. You can delete the site from the recycle bin and remove it completely.

To do that you need to run the command:

remove-spodeletedsite –identity

thus in my case:

remove-spodeletedsite –identity https://ciaops365.sharepoint.com/sites/bootcamp

You need to confirm the permanent removal by pressing Y.

image

If you refresh the web page displaying the site collection recycle bin you will see that the site has been removed completely.

image

Since I don’t need the other site I deleted previously using the web interface I will use PowerShell again to remove it permanently.

image

If we check the site collection recycle bin in the web interface there are no more site collections in the recycle bin as expected.

PowerShell provides you with more options when it comes to managing Office 365 and that is why you should be using it if you aren’t already!

Deleting an Office 365 site collection

There comes a time in the life of every Office 365 tenant where you need to do some house cleaning. In this case we are going to delete whole SharePoint Online Site Collection.

This means all the sites, apps, sub site, web parts, everything is going to be deleted. Note, I’ll be showing you how to do this for an M and E plans. The P or Small Business Plans only have a single private site collection and in most cases you probably don’t want to delete that! However, given the flexibility of both M and E plans to create multiple private Site Collections it means that you may need to clean house now and again.

image

You’ll need to be an Office 365 administrator to do this and for this post we’ll do our deleting via the web console. Login to the Office 365 portal and select the Admin option in the top right of the window and then SharePoint from the drop down menu that appears.

image

This will take you to the SharePoint Admin Center as shown above where you can see a list of all your Site Collections.

image

From the list of Site Collections place a check to the left of the one you wish to delete. You should then find the Delete button is available on the Ribbon Menu at the top of the screen. Press the Delete button to remove the Site Collection.

image

You’ll receive the above warning asking you to confirm the deletion. You’ll see that the deleted Site Collection will remain in a Recycle Bin for 30 days allowing you to recover it if necessary. Beyond that it is gone for good.

Press the Delete button to proceed.

image

In the top right of the window you will see the message about the Site Collection being deleted and then a message when the process is complete.

The Site Collection will no longer appear the the list in the SharePoint Admin Center.

image

But if you now go to the Recycle Bin via the Ribbon Menu it should appear as you see above. You can from there recover it for up to 30 days if desired.

Getting Started with SharePoint Designer in Office 365

I get a lot of questions about workflows and SharePoint Designer. You will see that I did a series of blog posts on that topic:

Creating a SharePoint Workflow

You’ve read the blog posts now see the video:

https://www.youtube.com/watch?v=gw-P-4YR6dw

Hopefully, all these will show you how easy it is to get into workflows for SharePoint Online.

As with most areas with technology, the rabbit hole goes as deep as you want it. SharePoint Designer is a very, very powerful tool that can create some really amazing things when it comes to workflows and SharePoint site design. Best of all SharePoint Designer is free.

So if you have been meaning to get your feet wet with automation in SharePoint Online, hopefully all this material will get you off the blocks to a flying start.

My Lync for Mac returns

clip_image001

A while back the version of Lync I had installed on my Macbook started prompting to verify certificates and then wouldn’t connect to Office 365. I fiddled around a bit but couldn’t get it to work so I put it on the too hard pile for the time being.

Eventually got back to it and low and behold, once I apply this update:

Update 2963369 for Lync for Mac 2011 14.0.9

That was recently released it all works as you can see above.

Now all we need is a OneDrive for Business Mac desktop sync app (which I don’t think is far away).

Creating a SharePoint Workflow

I wrote two previous blog posts about creating workflows with SharePoint Designer:

What are SharePoint Workflows

and

SharePoint Workflows – first steps

This post follows on from those.

In this case we’ll create a simple workflow that sends an email when a document is added to the library.

clip_image002

Firstly give the workflow a name and a description and then select the platform type (which you normally leave set as SharePoint 2013 Workflow) and press the OK button to create the workflow.

SharePoint 2013 allows you to create either SharePoint 2010 or 2013 Workflows. Each has differences and the following:

What’s new in workflow in SharePoint 2013

Is the recommended place to start when it comes to understanding the differences between the versions. In most cases you will want to work with SharePoint 2013 Workflows.

clip_image004

This now takes you to a location where you can edit and create the workflow.

For a SharePoint 2013 Workflow you will see a stage box or “block” divided up into two sections. The upper box is for a set of Actions and the lower box (Transition to stage) which allows you to jump to other stages you may have created. This Transition to stage is a unique feature of SharePoint 2013 workflows and allows you to bypass code by ‘jumping’ to certain locations.

You should also see a blinking cursor under the top section as shown above. You position this cursor where you wish to insert a command in the workflow.

clip_image007

In the Ribbon Bar you should see a number of buttons contained in the Insert section as shown above. Press the Action button to insert an execute command.

clip_image010

When you press the Action button you will see a list of all the actions that can be taken, as shown above. Scroll through the list until you locate Send an Email and select it.

clip_image013

You should now see that command displayed in the workflow area below in the location where your cursor was as you can see above. The cursor now moves to the line just below what you inserted.

You will also note that the text these users is hyperlinked. This indicates that additional details are required for this command to complete. In this case you will need to specify the email address that you wish the email to be sent to. To do that simply press the hyperlinked text these users.

clip_image015

Now the additional settings for each Action will vary. In this case you should now see a dialog as shown above, basically asking you to complete the details for the email.

clip_image017

There are plenty of options that can be configured here (including data lookup) but we’ll keep this simple and plug in just an email address, subject and some text in the body.

When complete, press the OK button to save.

clip_image020

You should now see that the workflow action has updated with the email address you entered. You can modify these properties again at any time by simply clicking on the hyperlinked email address.

clip_image023

Although this is the only command that will be run by the workflow at this stage it is good practice to correctly terminate the workflow. To do this, click once in the Transition to stage area so the cursor appears there as shown above.

clip_image026

Select the Action button again from the Ribbon Menu. From the menu that appears select Go to a stage.

clip_image029

Once again, this will place the Action in the workflow window as shown above.

To complete the options for the Action select the hyperlinked text a stage.

clip_image032

From the drop down menu that appears select End of Workflow. Doing so will ensure that the workflow does not continue to run in the background consuming resources.

clip_image034

The completed workflow should now look like the above.

clip_image036

You now need to set the workflow so it runs whenever something new is added to the Document Library. To do this locate the Workflow Settings button in the Ribbon Menu in the Manage section and select it.

clip_image039

On the right hand side you will see a box called Start Options as shown above. Place a check in the Start workflow automatically when an item is created.

clip_image041

If you need to return to your workflow and edit it select the Edit Workflow button under the Edit section on the Ribbon Menu.

You can also Save your workflow if need be but in this case we are ready to Publish to the SharePoint site so we select the Publish button from the Ribbon Menu.

clip_image043

You should now see the workflow being Published to the SharePoint site. If there are any errors you will be notified and have to make changes.

If there are not errors, your workflow has been successfully Published to SharePoint.

You can check that your SharePoint element has a workflow attached to it by navigating to that location (in this case Documents).

clip_image046

If you then select the Library tab at the top of the page.

clip_image048

Then the Workflow Settings button on the very right of this.

clip_image051

You should then see the name of the Workflow you just created.

clip_image055

If you look closely at the SharePoint element that now has a workflow attached you will see an additional column has been added to the default view. This column is the same as the name of your workflow (in this case Send email workflow as shown above).

clip_image034[1]

When you trigger a workflow (in this case by uploading a new document) the new workflow column will report what stage the workflow is at. Remember, that each “block” of Actions and Transition to stage is designated by its name.

In this example, there is only one code “block” called Stage 1 as shown above. Thus, when the workflow is triggered by the addition of a new document to the element the workflow executes and start and ends on Stage 1. This status is then reported in the workflow column in the SharePoint element. This allows you to more easily debug your code since it allows you to easily see where a workflow is currently situated.

clip_image057

As you can see from the above, the workflow was completed and an email has been sent with the subject and text created in the workflow.

You can now return and edit the workflow and create additional Actions. You can create additional workflows for the same elements if you wish or you can create them for other elements.

Conclusions

SharePoint workflows provide the ability to automate processed in SharePoint. However, workflows are not like pure coding, they are more like constructing a flow chart. They are great for simple and straight forward processes but become quite cumbersome and difficult to create when the task gets complex or involved.

Best practice is always to map out your workflow prior to developing with SharePoint Designer. Keep your code as simple as possible and make sure you maintain good documentation elsewhere about what you have created because SharePoint Designer doesn’t provide for adding comments to your code.

If you ever need to debug a workflow, break it down and look at the stages that are reported in the SharePoint element to which the workflow is attached. Also, don’t overlook the workflow start conditions. If you set a workflow to commence when something changes, that means when ANYTHING changes. That may mean you have multiple workflows running at the same time causing confusion. That is why it is so important that you programmatically terminate your workflow upon completion, rather than simply letting the process end.

Use correctly, SharePoint Designer and workflow can be huge source of productivity improvements. Use incorrectly or poorly implemented they can be a huge source of frustration. Remember, SharePoint Designer is not the only tool that you can use to create workflows. You can use Visual Studio for far greater control, but for that there is a much greater investment in both time, material and knowledge. SharePoint Designer allows a balance to be struck and be used by people who aren’t software developers.

Smarter help when editing with Office Online

Here’s something I just learnt that I think is really, really helpful.

image

Click on a Microsoft Office document somewhere in SharePoint Online (Team Site or OneDrive for Business). It will then open that document in a browser using Office Online. If you then elect to edit that document in a browser you’ll see the familiar ribbon as shown above.

image

See that box at the top of the ribbon that says ‘Tell me what to do’?

image

If I type ‘create table’, as you can see that menu option immediately becomes available, allowing me to select and create a table.

image

If I instead type in the box ‘create grid’, Office Online works out that I probably mean table and again shows me the appropriate menu command right there so I can create my table.

This is very powerful as it allows people to find what they are after much quicker and reduces the needs for lots and lots of menus and buttons.

Use it, love it.

Office 365 email attachments into OneDrive

A little while ago I noted in a blog post how the ability to select an attachment that was already in your OneDrive for Business was being rolled out.

image

After watching the latest Garage Series video I note that you can elect to upload a file from your desktop machine and attach it to an email as you used to BUT NOW you can also upload it directly into your OneDrive for Business as you see with the top button above!

image

It then displays the file in the email as you see above but that is simply a pointer to the location in OneDive for Business where the file actually lives.

However, even better than that, all the people you send the email with the attachment to automatically have the appropriate rights set in OneDrive for Business. All the external sharing business is ‘automagically’ taken care of! Impressive.

It seems that this is only available via Outlook Web Access. It would be nice if it was also available via Outlook on the desktop but I wouldn’t expect that initially. Down the track? Yes, probably but for now whata great addition.

https://www.youtube.com/watch?v=SP_H4TUfzjg

As always, I recommend you watch the latest Garage Series video to learn about everything that is happening with Office 365.