More functionality scenarios for Office 365 PowerShell

Use these PowerShell scenarios to set Skype for Business Online policy and manage SharePoint Online site collections.

Configure Skype for Business Online policy

Skype for Business Online policies control global settings and are examples of Office 365 settings that can only be configured with PowerShell.

If your organization regularly invites external users to a meeting (also called conferences), you can modify the meeting configuration settings to allow users external to your organization (anonymous users) to join a conference session.

To begin, you need to connect to Skype for Business Online with either an account name and password or with multifactor authentication (MFA). For the instructions, see Connect to Skype for Business Online.

The following command updates the Skype for Business Online policy to ALLOW users outside of your organization to join your organization's conference sessions:

Set-CsMeetingConfiguration -AdmitAnonymousUsersByDefault $True

The following command updates the Skype for Business Online policy to DENY users outside of your organization from joining your organization's conference sessions:

Set-CsMeetingConfiguration -AdmitAnonymousUsersByDefault $False

Skype for Business Online provides the functionality to record meeting audio and content so that it can be stored for future use or shared with those who did not attend the meeting. You can configure the Skype for Business Online policy to prevent or allow all users from your organization to record a Skype for Business meeting. By default users are granted the ability to record meetings.

This command ALLOWS attendees to record Skype for Business Online meetings:

Set-CsMeetingConfiguration -AllowConferenceRecording $True

This command DENIES the ability of attendees to record Skype for Business Online meetings:

Set-CsMeetingConfiguration -AllowConferenceRecording $False

It is important to consider who can be a presenter during your Skype for Business Online meetings. Allowing attendees to share their content makes collaboration during meetings easier. In this scenario, you can configure the Skype for Business Online policy to allow all users from your organization to be designated as presenters when they join a meeting.

This command designates ALL attendees as presenters:

Set-CsMeetingConfiguration  -DesignateAsPresenter "Everyone"

This command designates ONLY ORGANIZATION ATTENDEES as presenters:

Set-CsMeetingConfiguration  -DesignateAsPresenter "Company"

This command DISABLES the automatic designation of attendees as presenters:

Set-CsMeetingConfiguration  -DesignateAsPresenter "None"

Delete a SharePoint Online site collection and its subsites

In the Office 365 admin center, when you delete a SharePoint Online site collection, it is moved to the SharePoint Site Collection Recycle Bin where it will remain and can be restored for the next 30 days. To permanently delete a SharePoint Online site collection and all of its subsites without the use of the Recycle Bin, you need to use PowerShell. This scenario shows you how to immediately and permanently delete a SharePoint Online site collection.

To begin, you must connect to SharePoint Online. See Connect to SharePoint Online PowerShell for instructions.

To immediately and permanently delete a site collection, fill in the site collection's URL between the double-quotes, removing the instruction text and the < and > characters.

$siteCollURL="<URL of the SharePoint Online site collection>"
Remove-SPOSite -Identity $siteCollURL -NoWait
Start-Sleep -s 20
Remove-SPODeletedSite -Identity $siteCollURL

Run the resulting block of commands at the SharePoint Online Management Shell prompt.

Create SharePoint site collections

PowerShell allows you to quickly create site collections in SharePoint Online. You can also assign permissions to user accounts through the default SharePoint groups created for SharePoint Online site collection, making the entire process simple and efficient.

In this scenario you will create a single site with one defined owner. Then, you will bulk-add multiple SharePoint sites using a CSV file. Finally, you bulk-add permissions to a SharePoint site.

To create a new site collection using the minimum required values, fill in the site collection's URL, the Universal Principal Name (UPN) of the owner, and the storage quota, and then run the resulting commands:

$newSiteURL="<URL of the new SharePoint Online site collection>"
$ownerUPN="<UPN of the site owner, example: belindan@contoso.com>"
$storage=<number of megabytes of storage for the site>
New-SPOSite -Url $newSiteURL -Owner $ownerUPN -StorageQuota $storage

To create a single new site collection with additional properties, fill in the variables, and then run the resulting commands.

$newSiteURL="<URL of the new SharePoint Online site collection>"
$ownerUPN="<UPN of the site owner, example: belindan@contoso.com>"
$storage=<number of megabytes of storage>
$siteName="<title of the site collection>"
New-SPOSite -Url $newSiteURL -Owner $ownerUPN -StorageQuota $storage -Title $siteName -CompatibilityLevel 15 -LocaleID 1033 -ResourceQuota 300 -Template "STS#0" -NoWait

If you have to create multiple site collections, you can automate their creation by using a CSV file with the following fields:

  • Name,URL,Owner,StorageQuota,ResourceQuota,Template

When your CSV file is complete, fill in the path and name of your CSV file, and then run the resulting commands.

$fileName="<path and name of your CSV file, example: c:\O365scripts\sitecollections.csv>"
Import-Csv $fileName | % {New-SPOSite -Owner $_.Owner -StorageQuota $_.StorageQuota -Url $_.Url -NoWait -ResourceQuota $_.ResourceQuota -Template $_.Template -Title $_.Name}

By default, each site created from a standard template, such as the one for a team site (STS#0), gets assigned permissions using three SharePoint groups: Owners (full control), Members (contribute), and Visitors (view only). To assign permissions for a user account to access a SharePoint Online site collection, you add it to the SharePoint group with the appropriate level of access.

To assign a user account permissions to a SharePoint Online site collection, fill in the site URL, the SharePoint group name, and the UPN of the account, and then run the resulting commands.

$siteURL="<URL of the SharePoint Online site collection>"
$siteGroup="<name of the SharePoint Online group name>"
$accountUPN="<UPN of the account to add to the SharePoint group>"
Add-SPOUser -Site $siteURL -Group $siteGroup -LoginName $accountUPN

To do a bulk-add of user account permissions to SharePoint Online site collections, create a CSV file with the following fields:

  • SiteURL,GroupName,AccountUPN

When your CSV file is complete, fill in the path and name of your CSV file, and then run the resulting commands.

$fileName="<path and name of your CSV file, example: c:\O365scripts\sitepermissions.csv>"
Import-Csv $fileName | % {Add-SPOUser -Site $_.SiteURL -Group $_.GroupName -LoginName $_.AccountUPN}

See Also

PowerShell for Office 365 administrators

Office 365 PowerShell scenarios

Setup scenarios for Office 365 PowerShell

User management scenarios for Office 365 PowerShell

Reporting scenarios for Office 365 PowerShell

More functionality scenarios for Office 365 PowerShell

Office 365 PowerShell community resources

Connect with an expert
Contact us
Expand your skills
Explore training

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×