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

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 =Get - PNPGroup  foreach ( $Pgroup   in   $Pgroups )  {  $DLGP  =  ""   |   Select   "SiteUrl" , "GroupName" , "Permiss

Find and Delete Orphaned Users in SharePoint

Fuente: http://www.sharepointdiary.com/2012/09/find-and-delete-orphaned-users-in-sharepoint.html Orphaned User? Who are they? Orphaned users are those who have been disabled/removed from Active Directory, but still have permissions to sites, lists and items. Internally, SharePoint keeps them in " UserInfo " table of the content database for meta-data such as created/modified by fields. Its unavoidable in any organization where employees constantly on-boarding and off-boarding. Its really difficult to manage, when it comes to thousands of sub-sites, sites, libraries and lists with their own sets of permissions. Why we care about Orphaned users? It is a best practice to delete orphaned users to keep the farm clean & organized. Also this will solve the problem of deleted active directory users still appearing on the people picker which was discussed here  People Picker not showing users from Active Directory? . If you know the user base or criteria then you can use: Clea

Conexión desde casa a una VPN sin perder salida a internet

Solución, asumiendo que estas en Windows: Panel de Control, Conexiones de Red. Clic derecho en la VPN, dale a propiedades. Anda a la pestaña de "Funciones de Red" y selecciona Protocolo Internet TCP/IP y clic en el botón "Propiedades". Ahora hazle clic al botón "Opciones Avanzadas..."En la pestaña "General", desmarca la opción que dice "Usar la puerta de enlace predeterminada en la red remota". Dale a aceptar a todas las ventanitas de opción, y ahora conéctate a la VPN nuevamente. Con eso deberías entrar a la VPN sin perder la conexión local de tu red e internet.