Ir al contenido principal

PowerShell - SharePointOnline - Queries the active site collections in O365 tenant to generate reports based on template type used by the site collection



# Requires Windows PowerShell version 3
$tenant=""
<#
  Description:

    Queries the active site collections in O365 tenant to generate reports based on template type used
    by the site collection. And will generate report with all site collections in tenant.
    Details of the discovered sites are written to a .csv file for each template type.
    The .csv files will be found in the directory the script is ran from.

  Requirements:

    SharePoint Online Management Shell - Current build
    http://www.microsoft.com/en-us/download/details.aspx?id=35588

==============================================================
#>

# Set tenant values
$SPOAdminCenter = "https://$tenant-admin.sharepoint.com"
$AdminCredential = ""

#Report Files Names
$reportNameGroups = "GroupsSiteInfo_$((Get-Date).ToString("yyyy-MM-dd_hh.mm.ss")).csv"
$reportNameOD4B = "OneDriveForBusinessSiteInfo_$((Get-Date).ToString("yyyy-MM-dd_hh.mm.ss")).csv"
$reportNameClassic = "ClassicSiteInfo_$((Get-Date).ToString("yyyy-MM-dd_hh.mm.ss")).csv"
$reportNamePWA = "PWASiteInfo_$((Get-Date).ToString("yyyy-MM-dd_hh.mm.ss")).csv"
$reportNameBlog = "BlogSiteInfo_$((Get-Date).ToString("yyyy-MM-dd_hh.mm.ss")).csv"
$reportNameComm = "CommunicationsSiteInfo_$((Get-Date).ToString("yyyy-MM-dd_hh.mm.ss")).csv"
$reportNameNoOD4B = "AllSiteInfoNoOD4B_$((Get-Date).ToString("yyyy-MM-dd_hh.mm.ss")).csv"
$reportName = "AllSiteInfo_$((Get-Date).ToString("yyyy-MM-dd_hh.mm.ss")).csv"

#Connect to tenant. You will be prompted to enter your password.
Import-Module -WarningAction SilentlyContinue Microsoft.Online.SharePoint.PowerShell
try {
  Write-Host "Connecting to tenant..."
  Connect-SPOService -Url $SPOAdminCenter -Credential $AdminCredential
}
catch {
  Write-Host "Failed to connect to tenant."
}

#Get all site collections using Office 365 Groups Modern Team Site template
Write-Host "Obtaining list of sites using Groups Modern Team Site template..." -ForegroundColor Green
Write-Host "Writing site list and properties to export file." -ForegroundColor Blue
Get-SPOSite -Template GROUP#0 -Limit All | Export-Csv -Path $reportNameGroups -NoTypeInformation -Append
Write-Host "Groups Modern Sites information has been written to $reportNameGroups." -ForegroundColor Green
Write-Host ""

#Get all site collections using One Drive for Business Modern Site template
#Possible templates used are SPSPERS, SPSPERS#8, SPSPERS#10 but using SPSPERS should get all.
Write-Host "Obtaining list of OneDrive for Business site collections..." -ForegroundColor Green
Write-Host "Writing site list and properties to export file." -ForegroundColor Blue
Get-SPOSite -Template SPSPERS -Limit All -IncludePersonalSite:$true | Export-Csv -Path $reportNameOD4B -NoTypeInformation -Append
Write-Host "One Drive for Business sites information has been written to $reportNameOD4B." -ForegroundColor Green
Write-Host ""

#Get all site collections using Classic Team Site template
#Possible templates used are STS#0 & EHS#1 but using STS#0 should get all.
Write-Host "Obtaining list of sites using Classic Team Site collections..." -ForegroundColor Green
Write-Host "Writing site list and properties to export file." -ForegroundColor Blue
Get-SPOSite -Template STS#0 -Limit All | Export-Csv -Path $reportNameClassic -NoTypeInformation -Append
Write-Host "Classic Team sites information has been written to $reportNameClassic." -ForegroundColor Green
Write-Host ""

#Get all site collections using Project Web Application template
Write-Host "Obtaining list of sites using Project Web Application template..." -ForegroundColor Green
Write-Host "Writing site list and properties to export file." -ForegroundColor Blue
Get-SPOSite -Template PWA#0 -Limit All | Export-Csv -Path $reportNamePWA -NoTypeInformation -Append
Write-Host "Project Web Application sites information has been written to $reportNamePWA." -ForegroundColor Green
Write-Host ""

#Get all site collections using Classic Blog Site template
Write-Host "Obtaining list of sites using Classic Blog Site template..." -ForegroundColor Green
Write-Host "Writing site list and properties to export file." -ForegroundColor Blue
Get-SPOSite -Template BLOG#0 -Limit All | Export-Csv -Path $reportNameBlog -NoTypeInformation -Append
Write-Host "Classic Blog Sites information has been written to $reportNameBlog." -ForegroundColor Green
Write-Host ""

#Get all site collections using Communication Site template
Write-Host "Obtaining list of sites using Communication Sites template..." -ForegroundColor Green
Write-Host "Writing site list and properties to export file." -ForegroundColor Blue
Get-SPOSite -Template SitePagePublishing#0 -Limit All | Export-Csv -Path $reportNameComm -NoTypeInformation -Append
Write-Host "Communication Sites information has been written to $reportNamePWA." -ForegroundColor Green
Write-Host ""

#Get all site collections excluding OneDrive For Business using any site template
Write-Host "Obtaining list of all site collections excluding OneDrive for Business sites..." -ForegroundColor Green
Write-Host "Writing site list and properties to export file." -ForegroundColor Blue
Get-SPOSite -Limit All | Export-Csv -Path $reportNameNoOD4B -NoTypeInformation -Append
Write-Host "All site collection information has been written to $reportNameNoOD4B." -ForegroundColor Green
Write-Host ""

#Get all site collections including OneDrive For Business using any site template
Write-Host "Obtaining list of all site collections..." -ForegroundColor Green
Write-Host "Writing site list and properties to export file." -ForegroundColor Blue
Get-SPOSite -Limit All -IncludePersonalSite:$true | Export-Csv -Path $reportName -NoTypeInformation -Append
Write-Host "All site collection information has been written to $reportName." -ForegroundColor Green
Write-Host ""




Comentarios

Entradas populares de este blog

O365 - Forms - Transferir la propiedad de un formulario

Fuente :  https://support.office.com/es-es/article/transferir-la-propiedad-de-un-formulario-921a6361-a4e5-44ea-bce9-c4ed63aa54b4 Si ha creado una encuesta, una prueba o un sondeo, puede moverlos fácilmente a un grupo para que todos los miembros del grupo se conviertan en propietarios de ese formulario. Transferir el formulario a un grupo En el explorador Web, vaya a  Forms.Office.com . En la pestaña  mis formularios  , busque el formulario que desea transferir. Haga clic en  más acciones de formulario    y, a continuación, seleccione  mover . Nota:  Solo puede mover el formulario si es el propietario de ese formulario. No puede transferir la propiedad de un formulario que está compartido con usted. Seleccione el grupo al que desea transferir el formulario y, a continuación, haga clic en  mover . El formulario que ha movido aparecerá en la pestaña  formularios de grupo  . ¿Qué ocurre con el libr...

Event ID 8031 The uri endpoint information may be stale

An exception occurred while updating addresses for connected app {6783ce5e-c88h-4021-8d5b-12614875cbfa_b79f19ab-1d40-4824-9911-3466cf8b070a}. The uri endpoint information may be stale. System.InvalidOperationException: The requested application could not be found.    at Microsoft.SharePoint.SPTopologyWebServiceApplicationProxy.ProcessCommonExceptions(Uri endpointAddress, String operationName, Exception ex, SPServiceLoadBalancerContext context)    at Microsoft.SharePoint.SPTopologyWebServiceApplicationProxy.ExecuteOnChannel(String operationName, CodeBlock codeBlock)    at Microsoft.SharePoint.SPTopologyWebServiceApplicationProxy.GetEndPoints(Guid serviceId)    at Microsoft.SharePoint.SPConnectedServiceApplicationAddressesRefreshJob.Execute(Guid targetInstanceId) After de-commissioning some SharePoint servers, you might notice the above error on other WFEs /Application server’s event viewer . It appears that the SharePoint still has a reference...

Get SharePoint Online Site and SubSites permission using PowerShell

The below PowerShell script retrieves the following for the given SharePoint Online Site All the Sub-site's URL Security group attached with each Sub-site with their permission level Prerequisites: This PowerShell script uses the latest version of SharePoint Online PnP Module. Download the installer from https://github.com/SharePoint/PnP-PowerShell/releases  Install-Module SharePointPnPPowerShellOnline  Install-Module - Name ' SharePointPnP.PowerShell.Commands.Files.Recurse ' function  connect - site( $webs , $creds ){    Connect - PNPonline  - Url  $webs   - Credentials  $cred     }    function  get - sitepermission( $web , $cred ){    $rec =@()    connect - site  - webs  $web   - creds  $cred     if ( $web   - eq  $parentsitename )  {  #Write-Host "Parent site permission" $web   $Pgroups =G...