Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null
- function Get-NormalizedString
- {
- [cmdletbinding()]
- param
- (
- [Parameter(Mandatory=$true)][string]$String
- )
- ($String.Trim() -replace '\uFF06', '&' ) -replace '\uFF02', '"'
- }
- function Get-TermPath
- {
- [cmdletbinding()]
- param
- (
- [Parameter(Mandatory=$true)][Microsoft.SharePoint.Taxonomy.Term]$Term
- )
- begin
- {
- }
- process
- {
- Write-Verbose -Message "Starting Term: $($Term.Name)"
- foreach( $t in $Term.Terms )
- {
- Write-Verbose -Message "Sub-Term: $($t.Name)"
- Get-TermPath -Term $t
- }
- Write-Verbose -Message "Ending Term: $($Term.Name)"
- New-Object PSCustomObject -Property @{
- Term = Get-NormalizedString -String $Term.Name
- Path = Get-NormalizedString -String $Term.GetPath().Replace(";", " > ")
- TermSet = $Term.TermSet.Name
- }
- }
- end
- {
- }
- }
- function Export-TermStoreGroup
- {
- [cmdletbinding()]
- param
- (
- [Parameter(Mandatory=$true)][Microsoft.SharePoint.SPSite]$Site,
- [Parameter(Mandatory=$true)][string[]]$GroupName
- )
- begin
- {
- $session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($Site)
- $results = @()
- }
- process
- {
- foreach( $termStore in $session.TermStores )
- {
- Write-Verbose -Message "TermStore: $($termStore.Name)"
- foreach( $group in $termStore.Groups | ? { $GroupName -contains $_.Name } )
- {
- Write-Verbose -Message "`tTermGroup: $($group.Id)"
- foreach( $termSet in $group.TermSets )
- {
- Write-Verbose -Message "`t`tTermSet: $($termSet.Name)"
- foreach( $term in $termSet.Terms )
- {
- Get-TermPath -Term $term
- }
- }
- }
- }
- }
- end
- {
- $results
- }
- }
- Export-TermStoreGroup -Group "TERM GROUP NAME" -Site (Get-SPSite -Limit 1 -WarningAction SilentlyContinue) |
- SORT TermSet, Term, Path |
- SELECT TermSet, Term, Path |
- Export-Csv -Path "C:\_temp\TermGroupExport.csv" -NoTypeInformation
Add Comment
Please, Sign In to add comment