0

Introduction to Powershell for SharePoint Online -1


<#
.SYNOPSIS
#Basic command lets for SharePoint online

.DESCRIPTION
# This powershell script is generated just to get
very basic understanding
# of how you can connect with SharePoint Online and
execute basic GET Commands
# The scripts generates output in two formats CSV and
HTML to two folder on the system

.NOTES
#Author: Susheel Dakoju.
#Generated on: 04-12-2015 19:28
#Generated by:
#Organization: Windows Powershell Host v 3.0

#>

#Import-Module Microsoft.Online.Sharepoint.PowerShell

<#
1.Connect-SPOService
Description: Shows how a SharePoint Online global administrator with a user name and password connects to a SharePoint Online Administration Center that
has the URL http://contoso-admin.sharepoint.com/.
#>

$URL = "https://contoso.sharepoint.com/"
$AdminURL = "https://contoso-admin.sharepoint.com/"
$AdminUser = "usernam@contoso.onmicrosoft.com"
$csvurlprefix = "C:PowershellOutputcsv"
$htmlurlprefix = "C:PowershellOutputhtml"

Connect-SPOService -Url $AdminURL -credential $AdminUser
#-----------------------------------------------------------------------------------------------#
<#
2.Get-SPOSite
Description: Lists the site collection with detailed properties.
#>

# Export to CSV
Get-SPOSite $URL -Detailed | select * | Export-CSV -path "$($csvurlprefix)GetSPOsite_CSV.csv"

# Export to HTML
Get-SPOSite $URL -Detailed | select * | ConvertTo-Html | Set-Content "$($htmlurlprefix)GetSPOsite_HTML.html"

#-----------------------------------------------------------------------------------------------#

<#
3. Get-SPOTenant
Description: Returns the organization-level site collection properties such as
StorageQuota, StorageQuotaAllocated, ResourceQuota,ResourceQuotaAllocated, and SiteCreationMode.
#>
# Export to CSV
Get-SPOTenant | Export-CSV -path "$($csvurlprefix)GetSPOTenat_CSV.csv"

# Export to HTML
Get-SPOTenant | ConvertTo-Html | Set-Content "$($htmlurlprefix)GetSPOTenant_HTML.html"

#-----------------------------------------------------------------------------------------------#

<# 4. Get-SPOUser

Description: Returns one user or security group account inside group Team Site Members from the site collection #>

# Export to CSV
Get-SPOUser -Site $URL | Export-CSV -path "$($csvurlprefix)GetSPOUser_CSV.csv"

# Export to HTML
Get-SPOUser -Site $URL| ConvertTo-Html | Set-Content "$($htmlurlprefix)GetSPOUser_HTML.html"
<# 5. Get-SPOSiteGroup #>

#Gets all the groups on the specified site collection.

# Export to CSV
Get-SPOSiteGroup -Site $URL | Export-CSV -path "$($csvurlprefix)SPOSiteGroup_CSV.csv"

# Export to HTML
Get-SPOSiteGroup -Site $URL | ConvertTo-Html | Set-Content "$($htmlurlprefix)SPOSiteGroup_HTML.html"

Leave a Reply