Oct 17 2023 06:28 AM
Hi,
How can I read SharePoint online site collection taxonomy values in Azure Runbook PowerShell and store those values in array variable ?
Regards,
Pratik
Oct 18 2023 04:28 AM
Hi @pratikdarak21,
To read SharePoint Online site collection taxonomy values in Azure Runbook PowerShell and store those values in an array variable, you can use the following steps:
The following PowerShell code shows how to read SharePoint Online site collection taxonomy values in Azure Runbook PowerShell and store those values in an array variable:
# Connect to SharePoint Online
Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Credentials $myCredentials
# Get the term store
$termStore = Get-PnPTermStore
# Get the term set that you want to read the values from
$termSet = Get-PnPTermSet -TermStore $termStore -TermSetName "My Term Set"
# Get all the terms in the term set
$terms = Get-PnPTerm -TermSet $termSet
# Store the terms in an array variable
$termArray = @()
foreach ($term in $terms) {
$termArray += $term.Name
}
# Disconnect from SharePoint Online
Disconnect-PnPOnline
# Output the terms in the array variable
foreach ($term in $termArray) {
Write-Host $term
}
You can then use the $termArray variable in your Azure Runbook to perform other tasks, such as logging the terms to a file or sending them in an email.
Here are some documentation links:
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)
Oct 18 2023 06:16 AM