1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
##############################################################################################
## Script qui liste tous les termes utilisés sur Sharepoint
################################################################################################
param(
[Parameter( Mandatory = $false, HelpMessage = "The name of the file")]
[alias("file")]
[string]$outputfile = "sites.csv", #mettre le fichier qui contient les collections de sites
[string]$username = "XXXXX@YYYYY.com",
[string]$password = "MonMotdePasse",
[string]$logsFile = "logNotUsedTermes.csv",
[string]$tableauTermesutilises = New-Object System.Collections.ArrayList; #$Array.add(value)
)
# Reference Pnp Client Type (not use SPO nor SDK)
# Check path to PnP Module please
$pnpModule = Get-Module SharePointPnPPowerShell* -ListAvailable
$pnpPath = $pnpModule.ModuleBase
Add-Type -Path "2.15.1705.0\Microsoft.SharePoint.Client.dll"
Add-Type -Path "2.15.1705.0\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "2.15.1705.0\Microsoft.SharePoint.Client.UserProfiles.dll"
Add-Type -Path "2.15.1705.0\Microsoft.Online.SharePoint.Client.Tenant.dll"
################################################################
## Main ##
################################################################
# log file
$logsFile = ".\$logsFile"
Out-File -FilePath $logsFile -InputObject "Terme"
# open CSV file
$outputfile = ".\$outputfile"
$csv = import-csv $outputfile -delimiter ";"
#Parcourt tous les sites présents dans le CSV
$csv | ForEach-Object {
$url = $_.Url
#skip wrong url from file
if ($url.StartsWith("*")) { return } # use return instead of continue inside foreach-object
write-host "************************************************" -foregroundcolor Gray
write-host "Site $($_.Title)" -foregroundcolor Gray
write-host "************************************************" -foregroundcolor Gray
# SharePoint Online with PNP
# Connexion a Sharepoint
$psCredential = New-Object System.Management.Automation.PSCredential($username, $securePassword)
$spCredential = Get-Credential -Credential $psCredential
# PnP Connect
Connect-PnPOnline -Url $url -Credentials $spCredential
# Permet de recup tous les sites contenus dans les collections de sites
$allWebs = [System.Collections.ArrayList]@()
$allWebs += Get-PnPSubWebs -Recurse
$allWebs += Get-PnPWeb
# Enum Webs
foreach ($web in $allWebs) {
Write-Host ********* Proceed $web.Url -ForegroundColor Yellow
$lists = Get-PnPList -Web $web #lists contient alors toutes les listes et bibliothèqes du site en cours
# Enum Lists
$views = $null
foreach ($list in $lists) {
}
}
} |
Partager