diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagement.ps1 b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagement.ps1 index 37e989a0..00cec4ef 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagement.ps1 +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagement.ps1 @@ -1,60 +1,47 @@ - # # Created by Arleta Wanat, 2015 # -function Set-SPOListsContentTypesEnabled -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SPOListsContentTypesEnabled{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [bool]$ContentTypesEnabled -) + ) -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) $ctx.ExecuteQuery() -$Lists=$ctx.Web.Lists -$ctx.Load($Lists) -$ctx.ExecuteQuery() + $Lists=$ctx.Web.Lists + + $ctx.Load($Lists) + $ctx.ExecuteQuery() -Foreach($ll in $Lists) -{ - $ll.ContentTypesEnabled = $ContentTypesEnabled - $ll.Update() - + Foreach($ll in $Lists){ + $ll.ContentTypesEnabled = $ContentTypesEnabled + $ll.Update() - try - { - $ctx.ExecuteQuery() - Write-Host $ll.Title " Done" -ForegroundColor Green - } + try{ + $ctx.ExecuteQuery() + Write-Host $ll.Title " Done" -ForegroundColor Green + } + catch [Net.WebException]{ + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } - catch [Net.WebException] - { - - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red - } - -} + } } - - - - - - - # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" @@ -68,4 +55,4 @@ $ContentTypesEnabled=$true -Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled \ No newline at end of file +Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled diff --git a/Content Types/Get/Get All Detailed Properties of All Content Types/description.md b/Content Types/Get/Get All Detailed Properties of All Content Types/description.md index 2ac31789..a7ed8f94 100644 --- a/Content Types/Get/Get All Detailed Properties of All Content Types/description.md +++ b/Content Types/Get/Get All Detailed Properties of All Content Types/description.md @@ -28,7 +28,7 @@ How to use? -PowerShell +```PowerShell # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" @@ -37,7 +37,7 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens $Username="admin@tenant.onmicrosoft.com" $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" - +``` a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths b) Instead of "admin@tenant.onmicrosoft.com" enter you username c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types diff --git a/Content Types/Get/Get Content Types Derived From One Parent 2/GetSingleContentTypeLoopParentName.ps1 b/Content Types/Get/Get Content Types Derived From One Parent 2/GetSingleContentTypeLoopParentName.ps1 deleted file mode 100644 index 1d76fc6a..00000000 --- a/Content Types/Get/Get Content Types Derived From One Parent 2/GetSingleContentTypeLoopParentName.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -function Get-SPOContentType -{ - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] - [string]$Url, -[Parameter(Mandatory=$true,Position=4)] - [string]$Parent - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.ExecuteQuery() - - $ctx.Load($ctx.Web) - - $ctx.Load($ctx.Web.ContentTypes) - $ctx.ExecuteQuery() - - - foreach($cc in $ctx.Web.ContentTypes) - { - $ctx.Load($cc.Parent) - $ctx.ExecuteQuery() - - - if($cc.Parent.Name.ToString().Trim() -eq $Parent) - { - Write-Host $cc.Name - } - } - - } - - - - - # Paths to SDK. Please verify location on your computer. -Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" -Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" - -# Insert the credentials and the name of the admin site -$Username="admin@tenant.onmicrosoft.com" -$AdminPassword=Read-Host -Prompt "Password" -AsSecureString -$AdminUrl="https://tenant.sharepoint.com/sites/powie1" -$Parent="Audio" - - - - -Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -Parent $Parent - diff --git a/Content Types/Get/Get Content Types Derived From One Parent 2/description.md b/Content Types/Get/Get Content Types Derived From One Parent 2/description.md deleted file mode 100644 index 95676fef..00000000 --- a/Content Types/Get/Get Content Types Derived From One Parent 2/description.md +++ /dev/null @@ -1,61 +0,0 @@ -The script below is described in the article SharePoint Online content types in Powershell: Get and is part of various options on retrieving a single Content Type. -It is also available on Technet Gallery: [Get Content Types Derived From One Parent 2](https://gallery.technet.microsoft.com/office/Get-Content-Types-Derived-a0e749de) - - -It retrieves the content types that derive from specific a specific content type, in the example below it is Audio. In this script the content type is recognized by its name. If you need a script where the parent content type will be recognized by its ID, view this link. - -For 50+ other scripts refering to various content type functions, please view other scripts in this repository. - -Before running the script, you need to open the file and edit the following lines, entering the Admin username, the site where you want to retrieve the content types, and the id of the content type. Do not enter the password - you will be prompted for it during the script execution. - - - -```PowerShell - # Paths to SDK. Please verify location on your computer. -Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" -Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" - -# Insert the credentials and the name of the admin site -$Username="admin@tenant.onmicrosoft.com" -$AdminPassword=Read-Host -Prompt "Password" -AsSecureString -$AdminUrl="https://tenant.sharepoint.com/sites/powie1" -$Parent="Audio" -``` - - - -For other scripts related to Content Types, you can refer to the article Wiki: SharePoint Online content types in Powershell: Add (en-us) - -#### Adding -SharePoint Online: Create a content type using Powershell -Create content type and add directly to SPO list using Powershell -Create and add content type to a content type hub SharePoint Online -Create content type and add it to all lists in one site -Add Content Type to Task Lists -Add Content Type to Lists with Workflows -Add existing content type directly to SPO list using Powershell - -#### Content Type Management -Allow content type management for all lists in site collection using Powershell -Allow content type management for all lists in a site using Powershell -Set content type management setting for SharePoint Online list using Powershell -Custom Powershell cmdlet Set-SPOList -ContentTypesEnabled - -#### Related Scripts -SharePoint Online: Check content types added to your lists -SharePoint Online: Check content types added to your lists (recursive) -Get a report on lists where a given content type is added -SharePoint Online: Remove a content type from all lists in a site collection - -Get all properties of all content types in a SharePoint site -Get All Properties of All Content Types (Detailed) -Get All Properties of All Content Types in All Lists (Detailed) across one site -Get properties of a single content type by its ID - - - - - - - -If you have any questions, please open an issue! diff --git a/File Management/Get SPO Files from a folder/description.md b/File Management/Get SPO Files from a folder/description.md index a46fd288..9ee52858 100644 --- a/File Management/Get SPO Files from a folder/description.md +++ b/File Management/Get SPO Files from a folder/description.md @@ -52,9 +52,6 @@ Get-SPOFolderFiles -Username trial@trialtrial123.onmicrosoft.com -Url https://tr ``` - - - --- @@ -69,10 +66,6 @@ Get-SPOFolderFiles -Username trial@trialtrial123.onmicrosoft.com -Url https://tr - - - - --- If you want to get all files from all the folders, you can use Get-SPOFolder cmdlet to retrieve the folders and then for each folder retrieve the files. diff --git a/Licensing/Check User Licenses using plan type/Capture14.PNG b/Licensing/Check User Licenses using plan type/Capture14.PNG new file mode 100644 index 00000000..7fdd3d63 Binary files /dev/null and b/Licensing/Check User Licenses using plan type/Capture14.PNG differ diff --git a/Licensing/Check User Licenses using plan type/Capture15.PNG b/Licensing/Check User Licenses using plan type/Capture15.PNG new file mode 100644 index 00000000..2daf38e4 Binary files /dev/null and b/Licensing/Check User Licenses using plan type/Capture15.PNG differ diff --git a/Licensing/Check User Licenses using plan type/CheckingLicensesWithPlanType.ps1 b/Licensing/Check User Licenses using plan type/CheckingLicensesWithPlanType.ps1 new file mode 100644 index 00000000..e2cc800b --- /dev/null +++ b/Licensing/Check User Licenses using plan type/CheckingLicensesWithPlanType.ps1 @@ -0,0 +1,63 @@ +<# +This script works only in limited number of scenarios. If you have more than one subscription, use another script 'CheckLicensesWithServiceName' also published on Technet Gallery +((Get-Msoluser -UserPrincipalName test2@trial765.onmicrosoft.com).licenses.servicestatus | where {$_.ServicePlan.ServiceType -eq "Exchange"}) + +#> + +$PlanToCheck="Exchange" +$CSVPath="" #E:\technet\UsersWithDisabledEXO.csv Enter only if you want to export to csv +$ChecksWhetherThePlanIs="Disabled" #Disabled, Success or PendingActivation + + +<#Plans to choose from. Please enter only one value above +ProjectWorkManagement +Sway +SCO +YammerEnterprise +RMSOnline +MicrosoftOffice +MicrosoftCommunicationsOnline +Exchange + + + +With SharePoint you may prefer to use ServiceName property and SharePointEnterprise and SharePointWAC values +#> + +#connects to MSOL +Connect-MsolService + + +#Gets the users +$Users = Get-MSolUser -All + +if($Users -ne $null) +{ +Write-Host "Loaded all users." +} +else +{ +Write-Host "Couldn't get the users." +} + + +if($CSVPath) +{ + Write-Host "Users will be saved to" $CSVPath +} + +foreach($user in $users) +{ + #returns ServicePlan and ProvisioningStatus + $serviceStatus=((Get-Msoluser -UserPrincipalName $user.userPrincipalName).licenses.servicestatus | where {$_.ServicePlan.ServiceType -eq $PlanToCheck}) + if($serviceStatus.ProvisioningStatus -eq "Disabled") + { + Write-Host $user.UserPrincipalName + if($CSVPath) + { + Export-Csv -InputObject $user -LiteralPath $CSVPath -Append + } + } +} + + diff --git a/Licensing/Check User Licenses using plan type/description.md b/Licensing/Check User Licenses using plan type/description.md new file mode 100644 index 00000000..cbd2846c --- /dev/null +++ b/Licensing/Check User Licenses using plan type/description.md @@ -0,0 +1,78 @@ +A script to check user licenses by the plan type. + + + +The plan type is the same for multiple subscriptions, e.g. + +EXCHANGE_S_STANDARD available in Office 365 Business and EXCHANGE_S_ENTERPRISE available in Enterprise 3 are of the same type - Exchange. + + + +If you have multiple subscriptions in your tenant and would like to check a particular service, e.g. only Exchange_S_Enterprise, use the Check user licenses using Service Name script here: + +https://gallery.technet.microsoft.com/Check-user-licenses-using-461b317c + + + +How to use? + +1. Make sure you have installed Azure AD module available here: https://msdn.microsoft.com/en-us/library/azure/jj151815(v=azure.98).aspx + +2. Download the script and open it (in Notepad, ISE, whatever you prefer). + +3. In the first lines you see: + + + +PowerShell +$PlanToCheck="Exchange" +$CSVPath="" #E:\technet\UsersWithDisabledEXO.csv Enter only if you want to export to csv +$ChecksWhetherThePlanIs="Disabled" #Disabled, Success or PendingActivation + + +<#Plans to choose from. Please enter only one value above +ProjectWorkManagement +Sway +SCO +YammerEnterprise +RMSOnline +MicrosoftOffice +MicrosoftCommunicationsOnline +Exchange + + + +In $PlanToCheck="Enter the name of the plan you want to check" + +In $CSVPath leave as it is if you don't want a csv report, or if you do, enter path in inverted commas like in the example below: + + + +PowerShell +$CSVPath="E:\technet\UsersWithDisabledEXO.csv" + + + +$ChecksWhetherThePlanIs if set to "Disable" (as it is) will check for all disabled plans. If you want to check successfully provisioned or pending activation, enter "Success" or "PendingActivation". Important! Disabled are only the services where you assigned the license but not all services are active (e.g. E3 is assigned, but Exchange Online is unmarked). See example below: + + + +Here the license is disabled: + + + + + + + +Here it is NOT: + + + + + + + + + +4. Save the script and drag&drop it to Powershell. It will ask you for credentials and display a list of users on the screen. diff --git a/Licensing/Check user licenses using Service Name/Capture14.PNG b/Licensing/Check user licenses using Service Name/Capture14.PNG new file mode 100644 index 00000000..7fdd3d63 Binary files /dev/null and b/Licensing/Check user licenses using Service Name/Capture14.PNG differ diff --git a/Licensing/Check user licenses using Service Name/Capture15.PNG b/Licensing/Check user licenses using Service Name/Capture15.PNG new file mode 100644 index 00000000..2daf38e4 Binary files /dev/null and b/Licensing/Check user licenses using Service Name/Capture15.PNG differ diff --git a/Licensing/Check user licenses using Service Name/CheckLicensesWithServiceName.ps1 b/Licensing/Check user licenses using Service Name/CheckLicensesWithServiceName.ps1 new file mode 100644 index 00000000..74594b95 --- /dev/null +++ b/Licensing/Check user licenses using Service Name/CheckLicensesWithServiceName.ps1 @@ -0,0 +1,68 @@ + + +<# Possible serviceNames: +PROJECTWORKMANAGEMENT +SWAY +INTUNE_O365 +OFFICE_BUSINESS +YAMMER_ENTERPRISE +EXCHANGE_S_STANDARD +MCOSTANDARD +SHAREPOINTSTANDARD +RMS_S_ENTERPRISE +OFFICESUBSCRIPTION +MCOSTANDARD +SHAREPOINTWAC +SHAREPOINTENTERPRISE +EXCHANGE_S_ENTERPRISE +#> + +<# +If you think a service name is missing from the list above, you can use the following cmdlet on a user with ASSIGNED license to check for the internal servicename +((Get-Msoluser -UserPrincipalName test2@trial765.onmicrosoft.com).licenses.servicestatus.serviceplan.servicename) + +#> + +$PlanToCheck="Exchange_S_ENTERPRISE" +$CSVPath="" #Enter only if you want to export to csv, e.g. E:\technet\UsersWithDisabledEXO.csv +$ChecksWhetherThePlanIs="Disabled" #Disabled, Success or PendingActivation + + + +#connects to MSOL +Connect-MsolService + + +#Gets the users +$Users = Get-MSolUser -All + +if($Users -ne $null) +{ +Write-Host "Loaded all users." +} +else +{ +Write-Host "Couldn't get the users." +} + + +if($CSVPath) +{ + Write-Host "Users will be saved to" $CSVPath +} + +foreach($user in $users) +{ + #returns ServicePlan and ProvisioningStatus + $serviceStatus=((Get-Msoluser -UserPrincipalName $user.userPrincipalName).licenses.servicestatus | where {$_.ServicePlan.ServiceName -eq $PlanToCheck}) + if($serviceStatus.ProvisioningStatus -eq "Disabled") + { + Write-Host $user.UserPrincipalName + if($CSVPath) + { + Export-Csv -InputObject $user -LiteralPath $CSVPath -Append + } + } +} + + diff --git a/Licensing/Check user licenses using Service Name/description.md b/Licensing/Check user licenses using Service Name/description.md new file mode 100644 index 00000000..a0ff785c --- /dev/null +++ b/Licensing/Check user licenses using Service Name/description.md @@ -0,0 +1,106 @@ +Powershell script to check user licenses by the service name. + + + +Possible service names: + +PROJECTWORKMANAGEMENT + +SWAY + +INTUNE_O365 + +OFFICE_BUSINESS + +YAMMER_ENTERPRISE + +MCOSTANDARD + +RMS_S_ENTERPRISE + +OFFICESUBSCRIPTION + +SHAREPOINTSTANDARD + +SHAREPOINTWAC + +SHAREPOINTENTERPRISE + +EXCHANGE_S_STANDARD + +EXCHANGE_S_ENTERPRISE + + + + + + + +How to use? + +1. Make sure you have installed Azure AD module available here: https://msdn.microsoft.com/en-us/library/azure/jj151815(v=azure.98).aspx + +2. Download the script and open it (in Notepad, ISE, whatever you prefer). + +3. In the first lines you see: + +PowerShell +<# Possible serviceNames: +PROJECTWORKMANAGEMENT +SWAY +INTUNE_O365 +OFFICE_BUSINESS +YAMMER_ENTERPRISE +EXCHANGE_S_STANDARD +MCOSTANDARD +SHAREPOINTSTANDARD +RMS_S_ENTERPRISE +OFFICESUBSCRIPTION +MCOSTANDARD +SHAREPOINTWAC +SHAREPOINTENTERPRISE +EXCHANGE_S_ENTERPRISE +#> + +<# +If you think a service name is missing from the list above, you can use the following cmdlet on a user with ASSIGNED license to check for the internal servicename +((Get-Msoluser -UserPrincipalName test2@trial765.onmicrosoft.com).licenses.servicestatus.serviceplan.servicename) + +#> + +$PlanToCheck="Exchange_S_ENTERPRISE" +$CSVPath="" #Enter only if you want to export to csv, e.g. E:\technet\UsersWithDisabledEXO.csv +$ChecksWhetherThePlanIs="Disabled" #Disabled, Success or PendingActivation + +In $PlanToCheck="Enter the name of the plan you want to check" + +In $CSVPath leave it as it is if you don't want a csv report, or if you do want a report, enter the path in inverted commas like in the example below: + +PowerShell +$CSVPath="E:\technet\UsersWithDisabledEXO.csv" + +$ChecksWhetherThePlanIs if set to "Disable" (as it is) will check for all disabled plans. If you want to check successfully provisioned or pending activation, enter "Success" or "PendingActivation". + +Important! Disabled are only the services where you assigned the license but not all services are active (e.g. E3 is assigned, but Exchange Online is unmarked). See example below: + + + +Here the license is disabled: + + + + + + + +Here it is NOT: + + + + + + + + + +4. Save the script and drag&drop it to Powershell. It will ask you for credentials and display a list of users on the screen. diff --git a/Managed Metadata/Create a new SharePoint Online taxonomy term/description.md b/Managed Metadata/Create a new SharePoint Online taxonomy term/description.md index 1c880dde..fc86a989 100644 --- a/Managed Metadata/Create a new SharePoint Online taxonomy term/description.md +++ b/Managed Metadata/Create a new SharePoint Online taxonomy term/description.md @@ -1,5 +1,5 @@ A short script to create a single term in a specific term set of the default taxonomy store. The script applies to SharePoint Online tenants. - + You need to open the file and specify the following data: diff --git a/Managed Metadata/Taxonomy cmdlets module to manage your term store in SharePoint Online/TaxonomyModule.psm1 b/Managed Metadata/Taxonomy cmdlets module to manage your term store in SharePoint Online/TaxonomyModule.psm1 new file mode 100644 index 00000000..3956fa98 --- /dev/null +++ b/Managed Metadata/Taxonomy cmdlets module to manage your term store in SharePoint Online/TaxonomyModule.psm1 @@ -0,0 +1,437 @@ +function New-SPOTerm +{ +param ( + #[Parameter(Mandatory=$true,Position=4)] + #[string]$TermSetGuid, + [Parameter(Mandatory=$true,Position=5)] + [string]$Term, + [Parameter(Mandatory=$true,Position=6)] + [string]$TermLanguage + ) + + + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + $ctx.Load($termstore) + $ctx.ExecuteQuery() + + Write-Host "Termstore" -ForegroundColor Green + Write-Host "Term1" + $set=$termstore.GetTermSet($TermSetGuid) + $ctx.Load($set) + $ctx.Load($set.GetAllTerms()) + $ctx.ExecuteQuery() + $guid = [guid]::NewGuid() + Write-Host $guid + $term=$set.CreateTerm($Term, $TermLanguage,$guid) + + $termstore.CommitAll() + + $ctx.ExecuteQuery() + + } + + +function Get-SPOTermGroups +{ + + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + $ctx.Load($termstore) + $ctx.ExecuteQuery() + + $groups=$termstore.Groups + $ctx.Load($groups) + + $ctx.ExecuteQuery() + + foreach($group in $groups) + { + $ctx.Load($group) + $ctx.Load($group.TermSets) + $ctx.ExecuteQuery() + Write-Output $group + + } + + } + + +function Get-SPOTermSets +{ +param ( + [Parameter(ParameterSetName="groupName",Mandatory=$true)] + [string]$TermGroupName="", + [Parameter(ParameterSetName=’groupId’, Mandatory=$false)] + [string]$TermGroupId="" + ) + + + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + $ctx.Load($termstore) + $ctx.ExecuteQuery() + if($TermGroupName -eq "" -and ($TermGroupId -eq "")) + { + $groups=$termstore.Groups + $ctx.Load($groups) + $ctx.ExecuteQuery() + + foreach($group in $groups) + { + $ctx.Load($group) + $ctx.Load($group.TermSets) + $ctx.ExecuteQuery() + foreach($termset in $group.TermSets) + { + $ctx.Load($termset) + $ctx.Load($termset.Terms) + $ctx.ExecuteQuery() + Write-Output $termset + + } + + } + } + else + { + $group; + if($TermGroupName -ne ""){ + $group=$termstore.Groups.GetByName($TermGroupName) + } + elseif($TermGroupId -ne ""){ + $group=$termstore.Groups.GetById($TermGroupId) + } + else{ + $group=$termstore.Groups[0] + } + $ctx.Load($group) + $ctx.Load($group.TermSets) + $ctx.ExecuteQuery() + foreach($termset in $group.TermSets) + { + $ctx.Load($termset) + $ctx.Load($termset.Terms) + $ctx.ExecuteQuery() + Write-Output $termset + + } + + } + + + } + + + function Get-SPOTermStore + { + + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + $ctx.Load($termstore) + $ctx.Load($termstore.Groups) + $ctx.ExecuteQuery() + + Write-Output $termstore + + } + + function Get-SPOHashTagsTermSet + { + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + $ctx.Load($termstore) + $ctx.Load($termstore.HashTagsTermSet) + $ctx.Load($termstore.HashTagsTermSet.Terms) + $ctx.ExecuteQuery() + Write-Output $termstore.HashTagsTermSet + } + +function Get-SPOHashTagsTerms + { + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + $hashtagtermset=$termstore.HashTagsTermSet + $ctx.Load($termstore) + $ctx.Load($hashtagtermset) + $ctx.Load($hashtagtermset.Terms) + $ctx.ExecuteQuery() + foreach($term in $hashtagtermset.Terms) + { + $ctx.Load($term) + $ctx.Load($term.Terms) + $ctx.Load($term.TermSets) + $ctx.Load($term.Labels) + $ctx.Load($term.ReusedTerms) + $ctx.ExecuteQuery() + Write-Output $term + } + } + + function Get-SPOKeyWordsTermSet + { + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + $keywordsTermStore=$termstore.KeywordsTermSet + $ctx.Load($termstore) + $ctx.Load($keywordsTermStore) + $ctx.Load($keywordsTermStore.Terms) + $ctx.ExecuteQuery() + Write-Output $keywordsTermStore + } + + + + function New-SPOTermGroup + { + param( + [Parameter(Mandatory=$true)] + [string]$Name, + [Parameter(Mandatory=$false)] + [string]$GUID="" + ) + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + if($GUID -eq ""){$GUID = [guid]::NewGuid()} + $group=$termstore.CreateGroup($Name,$GUID) + try + { + $ctx.ExecuteQuery() + Write-Host "Group " $Name " created successfully." + + } + catch [Net.WebException] + { + + Write-Host "Couldn't create a group "$Name $_.Exception.ToString() -ForegroundColor Red + } + + } + + function Set-SPOTermGroup + { + param( + [Parameter(ParameterSetName="ByGUID",Mandatory=$true)] + [string]$GUID="", + [Parameter(ParameterSetName="FromPipeline", ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] + $group=$null, + [Parameter(Mandatory=$false)] + [string]$Description + ) + BEGIN{ + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + $termstore = $session.GetDefaultSiteCollectionTermStore(); + } + PROCESS{ + if($group -eq $null) + { + $group=$termstore.GetGroup($GUID) + $ctx.Load($termstore) + $ctx.Load($group) + $ctx.ExecuteQuery() + } + $group.Description=$Description + $ctx.ExecuteQuery() + } + } + + function New-SPOTermSet + { + param( + [Parameter(ParameterSetName="ByName",Mandatory=$true)] + [string]$TermGroupName="", + [Parameter(ParameterSetName="ByID",Mandatory=$true)] + [string]$TermGroupID="", + [Parameter(ParameterSetName="ByGroup",Mandatory=$true,ValueFromPipeline=$true)] + $TermGroup="", + [Parameter(Mandatory=$true)] + [string]$TermSetName, + [Parameter(Mandatory=$false)] + [int]$LanguageID=1033, + [Parameter(Mandatory=$false)] + $GUID="" + + ) + + BEGIN{ + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + } + PROCESS{ + $termstore = $session.GetDefaultSiteCollectionTermStore() + if($TermGroupName -ne "") + { $group=$termstore.Groups.GetByName($TermGroupName)} + elseif($TermGroupID -ne "") + { $group=$termstore.Groups.GetById($TermGroupID)} + elseif($group -ne "") + { + $group=$TermGroup + } + else + { + Write-Host "Could not retrieve the group. Missing parameters" + } + + $ctx.Load($group) + $ctx.Load($group.TermSets) + $ctx.ExecuteQuery() + if($GUID -eq ""){$GUID = [guid]::NewGuid()} + + $termSet=$group.CreateTermSet($TermSetName, $GUID, $LanguageID) + $ctx.ExecuteQuery() + return $termset + } + + + } + + function Set-SPOTermSet + { + param( + [Parameter(Mandatory=$true, Position=1)] + [Microsoft.SharePoint.Client.Taxonomy.TermSet]$TermSet, + [Parameter(Mandatory=$false)] + [string]$Description="", + [Parameter(Mandatory=$false)] + [bool]$IsOpenForTermCreation, + [Parameter(Mandatory=$false)] + [bool]$IsAvailableForTagging, + [Parameter(Mandatory=$false)] + [string]$Name, + [Parameter(Mandatory=$false)] + [string]$Owner, + [Parameter(Mandatory=$false)] + [string]$StakeholderToAdd, + [Parameter(Mandatory=$false)] + [string]$StakeholderToRemove + ) + if($Description -ne "") + { + $TermSet.Description=$Description + } + if($PSBoundParameters.ContainsKey("IsOpenForTermCreation")) + { + $TermSet.IsOpenForTermCreation=$IsOpenForTermCreation + } + if($PSBoundParameters.ContainsKey("IsOpenForTermCreation")) + { + $TermSet.IsAvailableForTagging=$IsAvailableForTagging + } + if($PSBoundParameters.ContainsKey("Name")) + { + $TermSet.Name=$Name + } + if($PSBoundParameters.ContainsKey("Owner")) + { + $TermSet.Owner=$Owner + } + if($PSBoundParameters.ContainsKey("StakeholderToAdd")) + { + $TermSet.AddStakeholder($StakeholderToAdd) + } + if($PSBoundParameters.ContainsKey("StakeholderToRemove")) + { + $TermSet.DeleteStakeholder($StakeholderToRemove) + } + + try + { + $ctx.ExecuteQuery() + } + catch [Net.WebException] + { + Write-Host "Could not update the termset. " $_.Exception.ToString() -ForegroundColor Red + } + + } + + function Get-SPOTerm + { + param( + [Parameter(Mandatory=$true, Position=1)] + [GUID]$Guid + ) + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + $termstore = $session.GetDefaultSiteCollectionTermStore(); + $term=$termstore.GetTerm($Guid) + $ctx.Load($termstore) + $ctx.Load($term) + $ctx.Load($term.Terms) + $ctx.Load($term.TermSets) + $ctx.ExecuteQuery() + Write-Output $term + + } + + + + + function Connect-SPOCSOM +{ + +<# + .link + http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx + + #> + + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=3)] + [string]$Url + + +) + + $password = Read-Host "Password" -AsSecureString + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.ExecuteQuery() +$global:ctx=$ctx +} + + +$global:ctx + + + + + + +# Paths to SDK. Please verify location on your computer. +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll" + diff --git a/Managed Metadata/Taxonomy cmdlets module to manage your term store in SharePoint Online/description.md b/Managed Metadata/Taxonomy cmdlets module to manage your term store in SharePoint Online/description.md new file mode 100644 index 00000000..7282ec8e --- /dev/null +++ b/Managed Metadata/Taxonomy cmdlets module to manage your term store in SharePoint Online/description.md @@ -0,0 +1,97 @@ +A module with new cmdlets for Taxonomy written in an easily-modifiable Powershell file + + + +The cmdlets include: + +New-SPOTerm + +Get-SPOTermGroups + +Get-SPOTermSets + +Get-SPOTermStore + +Get-SPOHashTagsTermSet + +Get-SpoHashTagsTerms + +Get-SPOKeyWordsTermSet + +New-SPOTermGroup + +Set-SPOTermGroup + +New-SPOTermSet + +Set-SPOTermSet + +Get-SPOTerm + +Connect-SPOCSOM + + + +Exact syntax and cmdlet descriptions with examples will be available here at SharePoint Online SPOMod cmdlets & resources. + + + + + +One of the cmdlets: + + + +PowerShell + function New-SPOTermSet + { + param( + [Parameter(ParameterSetName="ByName",Mandatory=$true)] + [string]$TermGroupName="", + [Parameter(ParameterSetName="ByID",Mandatory=$true)] + [string]$TermGroupID="", + [Parameter(ParameterSetName="ByGroup",Mandatory=$true,ValueFromPipeline=$true)] + $TermGroup="", + [Parameter(Mandatory=$true)] + [string]$TermSetName, + [Parameter(Mandatory=$false)] + [int]$LanguageID=1033, + [Parameter(Mandatory=$false)] + $GUID="" + + ) + + BEGIN{ + $session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx) + $ctx.Load($session) + $ctx.ExecuteQuery() + + } + PROCESS{ + $termstore = $session.GetDefaultSiteCollectionTermStore() + if($TermGroupName -ne "") + { $group=$termstore.Groups.GetByName($TermGroupName)} + elseif($TermGroupID -ne "") + { $group=$termstore.Groups.GetById($TermGroupID)} + elseif($group -ne "") + { + $group=$TermGroup + } + else + { + Write-Host "Could not retrieve the group. Missing parameters" + } + + $ctx.Load($group) + $ctx.Load($group.TermSets) + $ctx.ExecuteQuery() + if($GUID -eq ""){$GUID = [guid]::NewGuid()} + + $termSet=$group.CreateTermSet($TermSetName, $GUID, $LanguageID) + $ctx.ExecuteQuery() + return $termset + } + + + } + diff --git a/OTHER/Get all event receivers on your lists in a site/description.md b/OTHER/Get all event receivers on your lists in a site/description.md index a2597365..3c098dc4 100644 --- a/OTHER/Get all event receivers on your lists in a site/description.md +++ b/OTHER/Get all event receivers on your lists in a site/description.md @@ -8,7 +8,7 @@ A short solution to find event receivers on your SPO lists. 3. Scroll down to these lines -PowerShell +```PowerShell # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" @@ -20,6 +20,7 @@ $Url="https://tenant.sharepoint.com/sites/teamsitewithlibraries" Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url $Url +``` 4. Check if the 2 libraries are in the same location on your computer. If yes, proceed on. If no, change the paths in the file. Usually you will be required to change folder name "15" into "16". 5. Instead of admin@tenant.onmicrosoft.com, enter the name of your site collection admin. diff --git a/README.md b/README.md index ea72a85a..113e80b1 100644 --- a/README.md +++ b/README.md @@ -37,5 +37,29 @@ You can find here script samples to: Their new home at GitHub is still relatively recent, so if you find any issues, please do let me know. I appreciate every comment and every feedback. - +## Full index +* Content Types + * Create + * Add Content Type to Lists with Workflows + * Add Content Type to Task Lists + * Add existing content type directly to SPO list + * Create a content type + * Create and add content type to a content type hub + * Create content type and add directly to SPO list + * Create content type and add it to all lists in one site + * Get + * All Content Types from a Content Type Hub and their DisplayFormTemplate + * Compare Web.AvailableContentTypes vs Web.ContentTypes + * Find content types added to your lists (recursive) + * Find content types added to your lists + * Get All Detailed Properties of All Content Types + * Get All Hidden Content Types added to the site + * Get All Properties of All Content Types in All Lists (Detailed) across one site + * Get Content Types Derived From One Parent 2 + * Get Content Types Derived From One Parent + * + * Set + * Delete + * Display Forms + * Modules diff --git a/Remove SPO subsite.ps1 b/Remove SPO subsite.ps1 index 6854e7d0..53869cc4 100644 --- a/Remove SPO subsite.ps1 +++ b/Remove SPO subsite.ps1 @@ -1,46 +1,46 @@ -function GetAllSubsitesAndDelete($urelek) +function GetAllSubsitesAndDelete($SiteUrl) { - $ctx2 = New-Object Microsoft.SharePoint.Client.ClientContext($urelek) -$ctx2.Credentials= New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) -$rootWeb2 = $ctx2.Web -$sites2 = $rootWeb2.Webs - -$ctx2.Load($rootWeb2) -$ctx2.Load($sites2) -$ctx2.ExecuteQuery() -if($sites2.Count -gt 0) - { - for($i=0;$i -lt $sites2.Count ;$i++) - { - GetAllSubsitesAndDelete($sites2[$i].Url) - } - try + $ctx2 = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) + $ctx2.Credentials= New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) + $rootWeb2 = $ctx2.Web + $sites2 = $rootWeb2.Webs + + $ctx2.Load($rootWeb2) + $ctx2.Load($sites2) + $ctx2.ExecuteQuery() + + if($sites2.Count -gt 0) { - $rootWeb2.DeleteObject() - $ctx2.ExecuteQuery() - Write-Host "Subsite " $rootWeb2.Url " has been removed" - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() + for($i=0;$i -lt $sites2.Count ;$i++) + { + GetAllSubsitesAndDelete($sites2[$i].Url) + } + + try + { + $rootWeb2.DeleteObject() + $ctx2.ExecuteQuery() + Write-Host "Subsite " $rootWeb2.Url " has been removed" + } + catch [Net.WebException] + { + Write-Host $_.Exception.ToString() + } } - } - else - { - try + else { - $rootWeb2.DeleteObject() - $ctx2.ExecuteQuery() - Write-Host "Subsite " $rootWeb2.Url " has been removed" + try + { + $rootWeb2.DeleteObject() + $ctx2.ExecuteQuery() + Write-Host "Subsite " $rootWeb2.Url " has been removed" + } + catch [Net.WebException] + { + Write-Host $_.Exception.ToString() + } } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - } - - - + } #paths to SDK (copied from Victor's comment) diff --git a/Versioning/Enable versioning for all lists in OneDrive sites/Capture204.PNG b/Versioning/Enable versioning for all lists in OneDrive sites/Capture204.PNG new file mode 100644 index 00000000..3b613cd6 Binary files /dev/null and b/Versioning/Enable versioning for all lists in OneDrive sites/Capture204.PNG differ diff --git a/Versioning/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 b/Versioning/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 new file mode 100644 index 00000000..eb9532c5 --- /dev/null +++ b/Versioning/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 @@ -0,0 +1,93 @@ +function Set-SPOListVersioning($EnableVersioning, $Urelek) +{ + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $Adminpassword) + $ctx.Load($ctx.Web.Lists) + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.Webs) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + foreach( $ll in $ctx.Web.Lists) + { + $ll.EnableVersioning = $EnableVersioning + $ll.Update() + $csvvalue= new-object PSObject + $listurl=$null + if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url+$ll.Title} + else {$listurl=$ctx.Url+"/"+$ll.Title} + $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) + $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" + try + { + $ErrorActionPreference="Stop" + $ctx.ExecuteQuery() + Write-Host $listurl -ForegroundColor DarkGreen + $csvvalue.Status="Success" + $Global:csv+= $csvvalue + } + + catch + { + $Global:csv+= $csvvalue + Write-Host $listurl -ForegroundColor Red + } + finally + {$ErrorActionPreference="Continue"} + + + } + + if($ctx.Web.Webs.Count -gt 0) + { + for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++) + { + Set-SPOListVersioning -EnableVersioning $EnableVersioning -Urelek ($ctx.Web.Webs[$i].Url) + } + + } + + + +} + + + + + + + # Paths to SDK. Please verify location on your computer. +Add-Type -Path "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.dll" +Add-Type -Path "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client.Runtime\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Runtime.dll" + +# Insert the credentials and the name of the admin site +$Username="t@trial765.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +Connect-SPOService https://trial765-admin.sharepoint.com -Credential $Username +$myhost="https://trial765-my.sharepoint.com" + +# If you do not want to target all users, enter the target user names in the line below instead of Get-SPOUser cmdlet: +$users=get-SPOUser -Site $myhost +$EnableVersioning=$true +$Global:csv=@() + +foreach($user in $users) +{ + + + if($user.LoginName.Contains('@')) + { + $persweb=$user.LoginName.Replace(".","_").Replace("@","_") + $persweb=$myhost+"/personal/"+$persweb + Write-Host $persweb + + $AdminUrl=$persweb + + #Add the following line if you want to assign yourself, administrator or another user access to other users' personal sites + #Set-SPOUser -Site $AdminUrl -IsSiteCollectionAdmin $true -LoginName t@trial765.onmicrosoft.com + Set-SPOListVersioning -EnableVersioning $EnableVersioning -Urelek $AdminUrl + } +} + +# Specify the path where the log file will be published +$Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv \ No newline at end of file diff --git a/Versioning/Enable versioning for all lists in OneDrive sites/description.md b/Versioning/Enable versioning for all lists in OneDrive sites/description.md new file mode 100644 index 00000000..efa5e103 --- /dev/null +++ b/Versioning/Enable versioning for all lists in OneDrive sites/description.md @@ -0,0 +1,26 @@ +Powershell script that enables versioning for all the libraries and lists in all personal sites (OneDrive for Business). + +It requires SharePoint Online Management Shell and SharePoint SDK installed: + +http://technet.microsoft.com/en-us/library/fp161372(v=office.15).aspx + +http://www.microsoft.com/en-us/download/details.aspx?id=30722 + + + +It uses recurrence to find all sites in all site collections and then goes through all the lists. + +For some lists, enabling version may not be possible and you will receive a notification of that. + +At the end, a csv file is generated with the lists' urls and the status whether enabling was successful or not. + + + +As the script runs you will see green lists' titles for which the enabling succeeded and red for those which failed (not all lists support versioning). + + + + +You can customize the script by using the commented out tips. + + diff --git a/Versioning/PS Enable versioning for all SharePoint Online lists/description.md b/Versioning/PS Enable versioning for all SharePoint Online lists/description.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Versioning/PS Enable versioning for all SharePoint Online lists/description.md @@ -0,0 +1 @@ +.