Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates sample scripts to align with v10. Closes #6369 #6494

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"This script uses Azure Cognitive Service API and Microsoft 365 CLI to analyze user profile pictures and assess whether they meet the standards placed by the organization. It can be customized to ban content within an org channel or collaboration network where employees post pictures, memes, etc."
],
"products": [
"AAD"
"Entra"
],
"categories": [],
"tags": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Validate all your users against known breaches with the have I been pwned api. That way you can quickly scan if your users are part of any known breaches."
],
"products": [
"AAD"
"Entra"
],
"categories": [],
"tags": [
Expand Down
Adam-it marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Companies pursue to hasten profits growth or enter new marketplace through Mergers and Acquisitions (M&A). M&A typically fails during integration. This also applies to migrating users and data in Microsoft Teams and Groups. Partial acquisition can be pretty tricky. To help make the activity as charming as possible, I have created the following sample script to add/remove bulk users to/from Microsoft Teams team or Microsoft 365 group using CLI for Microsoft 365 commands."
],
"products": [
"AAD"
"Entra"
],
"categories": [],
"tags": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Note: Refactor the code as per your requirement.
}
}
ElseIf ($action -eq "remove") {
m365 entra m365group user remove --groupId $group.id --userName $user.mail --force
m365 entra m365group user remove --groupId $group.id --userNames $user.mail --force
Write-Host $user.mail " removed from " $group.mailNickname
}
Else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Another example how you can delete all Microsoft 365 Groups and SharePoint Online sites in your development environment."
],
"products": [
"AAD"
"Entra"
],
"categories": [],
"tags": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"There are so many different ways to create Microsoft 365 groups. Teams, Planner, SharePoint team sites, etc. — you can accumulate a lot of them very fast. Use this script below to delete the ones you no longer need."
],
"products": [
"AAD"
"Entra"
],
"categories": [],
"tags": [
Expand Down
Adam-it marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"This script can be used to replace the membership of a user for a selected list of Groups. It might be useful when a person changes role in an organization or is about to leave it."
],
"products": [
"AAD"
"Entra"
],
"categories": [],
"tags": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ This script can be used to replace the membership of a user for a selected list

try {
Write-Host "Removing $oldUser..."
m365 entra m365group user remove --groupId $groupId --userName $oldUser | Get-CLIValue
m365 entra m365group user remove --groupId $groupId --userNames $oldUser | Get-CLIValue
}
catch {
Write-Host $_.Exception.Message -ForegroundColor Red
Expand Down
Adam-it marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Find all the Microsoft 365 Groups that a user is an Owner of and replace them with someone else useful for when an employee leaves and ownership needs to be updated."
],
"products": [
"AAD"
"Entra"
],
"categories": [],
"tags": [
Expand Down
Adam-it marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Find all the Microsoft 365 Groups that a user is an Owner of and replace them wi

$hasOwner = $null
# verify if the old user is in the owners list
$hasOwner = m365 entra m365group user list --groupId $group.id --query "[?userType=='Owner' && userPrincipalName=='$oldUser'].[id]" | Get-CLIValue
$hasOwner = m365 entra m365group user list --groupId $group.id --role owner --query "[?userPrincipalName=='$oldUser'].[id]" | Get-CLIValue
if ($hasOwner -ne $null) {
Write-Host "Found $oldUser" -ForegroundColor Green
try {
Expand All @@ -80,7 +80,7 @@ Find all the Microsoft 365 Groups that a user is an Owner of and replace them wi

try {
Write-Host "Removing $oldUser permissions..."
m365 entra m365group user remove --groupId $group.id --userName $oldUser | Get-CLIValue
m365 entra m365group user remove --groupId $group.id --userNames $oldUser | Get-CLIValue
}
catch {
Write-Host $_.Exception.Message -ForegroundColor Red
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"We can use the group naming policy to enforce a consistent naming strategy for groups created by users in our organization. A naming policy can help us and our users identify the function of the group. We can use the policy to block specific words from being used in group names and aliases. But what if we need to find out the list of Microsoft 365 groups created with user’s givenName or surname as their mail? This sample script scans the Microsoft 365 groups that may contain user’s first or last name as the group mail."
],
"products": [
"AAD"
"Entra"
],
"categories": [],
"tags": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "7.7.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/sample-scripts/spo/add-ci-cd-pipeline/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Depending on what authentication method you chose, you will need to add the foll

For the application login method:

- `APP_ID` - client id of the registered AAD application
- `APP_ID` - client id of the registered Entra application
- `CERTIFICATE_ENCODED` - application's encoded certificate
- `CERTIFICATE_PASSWORD` - certificate password. This applies only if the certificate is encoded which is the recommended approach
- `TENANT` - Tenant ID
Expand Down Expand Up @@ -214,10 +214,10 @@ For the application login method you will need to fill in the following variable
}

if ($Scope -eq "tenant") {
m365 spfx project github workflow add --loginMethod $LoginMethod --name $Name --branchName $BranchName $ManuallyTriggerStr $SkipFeatureDeploymentStr --overwrite
m365 spfx project github workflow add --loginMethod $LoginMethod --name $Name --branchName $BranchName $ManuallyTriggerStr $SkipFeatureDeploymentStr
}
else {
m365 spfx project github workflow add --loginMethod $LoginMethod --name $Name --branchName $BranchName --scope "sitecollection" --siteUrl $SiteUrl $ManuallyTriggerStr $SkipFeatureDeploymentStr --overwrite
m365 spfx project github workflow add --loginMethod $LoginMethod --name $Name --branchName $BranchName --scope "sitecollection" --siteUrl $SiteUrl $ManuallyTriggerStr $SkipFeatureDeploymentStr
}

# show github guidance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "6.6.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Adam-it marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The following script shows how you can copy all library folders and contents to

# Copy everything (folders and files) to this target level 1 folder
Write-Host "Copying '$($Folder.ServerRelativeUrl)' to '$DestinationFolderUrl'" -ForegroundColor Cyan
m365 spo folder copy --webUrl $SiteURL --sourceUrl $Folder.ServerRelativeUrl --targetUrl $DestinationFolderUrl --allowSchemaMismatch
m365 spo folder copy --webUrl $SiteURL --sourceUrl $Folder.ServerRelativeUrl --targetUrl $DestinationFolderUrl
}

# Copy files from root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ When you delete Microsoft 365 groups, the modern group-connected team sites get
$progress++
write-host $progress / $total":" $site.Title
write-host $site.Url
m365 spo site remove --url $site.Url
m365 spo site remove --url $site.Url --force
}
```

Expand Down Expand Up @@ -74,7 +74,7 @@ When you delete Microsoft 365 groups, the modern group-connected team sites get
siteUrl=$(echo ${site} | jq -r '.Url')
echo "Deleting site..."
echo $siteUrl
m365 spo site remove --url $siteUrl
m365 spo site remove --url $siteUrl --force
done
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "6.3.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This script will retrieve all the checked out files in a particular site.
$resultsForSite = @()

foreach($library in $allLibs){
$allDocs = m365 spo file list --webUrl $siteURL --folder $library.Url --recursive -o json | ConvertFrom-Json
$allDocs = m365 spo file list --webUrl $siteURL --folder $library.RootFolder.ServerRelativeUrl --recursive -o json | ConvertFrom-Json

foreach($document in $allDocs){
if($document.CheckOutType -eq [int64]0){
Expand Down Expand Up @@ -122,7 +122,7 @@ Depending on the number of sites in your .csv file, the number of libraries as w
foreach($lib in $allLibraries){

#Get all the documents
$allDocs = m365 spo file list --webUrl $row.siteURL --folder $lib.Url --recursive -o json | ConvertFrom-Json
$allDocs = m365 spo file list --webUrl $row.siteURL --folder $lib.RootFolder.ServerRelativeUrl --recursive -o json | ConvertFrom-Json

foreach($docu in $allDocs){
if($docu.CheckOutType -eq [int64]0){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "6.3.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This script will retrieve all the files in a site that have a specific word (i.e
$i++
if ($ShowProgress) { Write-Host "Processing '$($lib.Title)' - ($i/$($allLibs.length))" }

$allFiles = m365 spo file list --webUrl $site --folder $lib.Url --recursive -o json | ConvertFrom-Json
$allFiles = m365 spo file list --webUrl $site --folder $lib.RootFolder.ServerRelativeUrl --recursive -o json | ConvertFrom-Json

foreach ($file in $allFiles) {
if ($ShowProgress) { Write-Host "Processing file '$($file.ServerRelativeUrl)'" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "6.3.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ List all Lists, the folders and sub folders in a given site, and output the item

foreach ($list in $allLists) {
if ($false -eq $list.Hidden -and $list.BaseTemplate -eq "101") {
Write-Output "Processing $($list.Url)"
[void]$results.Add([PSCustomObject]@{ Url = $list.Url; ItemCount = $list.ItemCount; Type = "List"; })
Write-Output "Processing $($list.RootFolder.ServerRelativeUrl)"
[void]$results.Add([PSCustomObject]@{ Url = $list.RootFolder.ServerRelativeUrl; ItemCount = $list.ItemCount; Type = "List"; })

Get-Folders $siteUrl $list.Url
Get-Folders $siteUrl $list.RootFolder.ServerRelativeUrl
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "6.4.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ This script helps you to list all sites in SharePoint Online, where a particular
Write-Host "Processing site $($site.Url)..."
$appInstance = m365 spo app instance list --siteUrl $site.Url --query $queryText | ConvertFrom-Json

if ($appInstance) {
if ($appInstance.count -gt 0) {
$results += [pscustomobject]@{
SiteURL = $site.Url
Title = $site.Title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "6.9.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The script loops through each document library in a site where the folder size s

foreach($library in $allLibs) {
Write-Host "Processing document library: $($library.Title)"
$allFolders = m365 spo folder list --webUrl $WebUrl --parentFolderUrl $library.Url --fields "Name,ServerRelativeUrl,TimeCreated,CreatedBy,TimeLastModified" --recursive --filter "ItemCount eq 0" -o json | ConvertFrom-Json
$allFolders = m365 spo folder list --webUrl $WebUrl --parentFolderUrl $library.RootFolder.ServerRelativeUrl --fields "Name,ServerRelativeUrl,TimeCreated,CreatedBy,TimeLastModified" --recursive --filter "ItemCount eq 0" -o json | ConvertFrom-Json

foreach($folder in $allFolders) {
$resultsEmptyFolders += [PSCustomObject]@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "6.3.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The following script will help you find every files in a specific SharePoint Onl
$i++
if ($ShowProgress) { Write-Host "Processing '$($lib.Title)' - ($i/$($allLibs.length))" }

$allFiles = m365 spo file list --webUrl $site --folder $lib.Url --recursive -o json | ConvertFrom-Json
$allFiles = m365 spo file list --webUrl $site --folder $lib.RootFolder.ServerRelativeUrl --recursive -o json | ConvertFrom-Json

foreach ($file in $allFiles) {
if ($ShowProgress) { Write-Host "Processing file '$($file.ServerRelativeUrl)'" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "6.3.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ This script helps you to list and export all site collection and their lists Sha
$results += [pscustomobject][ordered]@{
Type = "list"
Title = $list.Title
Url = $list.Url
Url = $list.RootFolder.ServerRelativeUrl
Template = $list.BaseTemplate
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Changing the URL of a site results in a new site type: a Redirect Site. However
}
If($body.StatusCode -eq "404"){
Write-Host -f Red " Target location no longer exists, should be removed"
m365 spo site remove --url $siteUrl
m365 spo site remove --url $siteUrl --force
}
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ Changing the URL of a site results in a new site type: a Redirect Site. However
siteUrl=$(echo ${site} | jq -r '.Url')
echo "Deleting site..."
echo $siteUrl
m365 spo site remove --url $siteUrl
m365 spo site remove --url $siteUrl --force
done
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "7.4.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function GetRetirementStatus {

foreach ($List in $Lists) {
$EventReveiversOnList = m365 spo eventreceiver list --webUrl $WebUrl --listId $List.Id --query "[?!contains(ReceiverAssembly,'Microsoft.')]" --output json | ConvertFrom-Json
$EventReceivers += GetEventReceiversDataToOutputList -EventReceivers $EventReveiversOnList -Location "List" -LocationUrl $List.Url
$EventReceivers += GetEventReceiversDataToOutputList -EventReceivers $EventReveiversOnList -Location "List" -LocationUrl $List.RootFolder.ServerRelativeUrl
}
return $EventReceivers
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "7.0.0"
"value": "10.0.0"
}
],
"thumbnails": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ This sample script shows you how to create a Team and add members and owners usi
# remove yourself from the owners group
if ($removeYourSelfFromOwners -and $owners.IndexOf($whoAmI.connectedAs) -eq -1) {
Write-Host "Removing $($whoAmI.connectedAs) from the owners list"
m365 entra m365group user remove --groupId $group.id --userName $whoAmI.connectedAs --force
m365 entra m365group user remove --groupId $group.id --userNames $whoAmI.connectedAs --force
}

Write-Host "Completed."
Expand Down