Hello,
I was wondering if there is a way to get a list of used managed metadata columns. I have tried using powershell script below in the SharePoint Online Management Shell;
$SiteCollURL="https://Mysite.sharepoint.com"
$ReportOutput="c:\MMS-Columns.csv"
$WebsColl = (Get-SPSite $SiteCollURL).AllWebs
#Array to hold Results
$ResultColl = @()
#Loop through each site, List and Fields
Foreach($web in $WebsColl)
{
Write-host "Scanning Web:"$Web.URL
Foreach($list in $web.Lists)
{
Foreach($Field in $list.Fields)
{
if($field.GetType().Name -eq "TaxonomyField")
{
$Result = New-Object PSObject
$Result | Add-Member -type NoteProperty -name "List Name" -value $List.Title
$Result | Add-Member -type NoteProperty -name "URL" -value "$($List.ParentWeb.Url)/$($List.RootFolder.Url)"
$Result | Add-Member -type NoteProperty -name "Field Name" -value $Field.Title
$ResultColl += $Result
}
}
}
}
#Export Results to a CSV File
$ResultColl | Export-csv $ReportOutput -notypeinformation
Write-Host "Managed Metadata columns usage Report has been Generated!" -f Green
However when I run the script I get the following error;
Get-SPSite : The term 'Get-SPSite' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:4 char:14
- $WebsColl = (Get-SPSite $SiteCollURL).AllWebs
- ~~~~~~~~~~
- CategoryInfo : ObjectNotFound: (Get-SPSite:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
So after some searches, Apparently I have to add the following line:
Add-PSSnap in Microsoft.SharePoint.Powershell
but when I run it, I get the following message: Add-PSSnapin: No snap-ins have been registered for Windows PowerShell version 5
Any idea of what I'm doing wrong?
Any help would be much appreciated
Reply