This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Example on how to retrieve the Known Folder Move Directories from a OneDrive site | |
### This script is using PNP PowerShell to perform the activity | |
$url = "OneDriveUrl" | |
Connect-PnPOnline $url | |
function Get-FolderUrl ($context, $list, $valueToCheck) { | |
if ($list.RootFolder.Properties.FieldValues.ContainsKey($valueToCheck)) { | |
$item = $list.GetItemByUniqueId($list.RootFolder.Properties.FieldValues[$valueToCheck]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$userToAdd = "<upnOfUserToAdd>" | |
$userToRemove = "<upnOfUserToRemove>" | |
$webUrl = "<spoUrl>" | |
$m365Status = m365 status | |
Write-Host $m365Status | |
if ($m365Status -eq "Logged Out") { | |
# Connection to Microsoft 365 | |
m365 login | |
$m365Status = m365 status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script replaces an owner with a different person in all Microsoft 365 Groups | |
$oldUser = "oldUserUpn" | |
$newUser = "newUserUpn" | |
# Parameters end | |
$m365Status = m365 status | |
if ($m365Status -eq "Logged Out") { | |
# Connection to Microsoft 365 | |
m365 login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script replaces the membership of a user with another with another for a given list of Microsoft 365 Groups | |
# The input file should contain the IDs of the Microsoft 365 Groups / Teams | |
## id | |
## b48b89cf-35be-441c-b290-853318dce42a | |
## b48b89cf-35be-441c-b290-853318dce42d | |
## babd731a-85e7-48e8-89c6-f96e565ee68c | |
## 3ebd3caf-efdd-4958-bbbf-1dd43e8c1493 | |
## bd341f68-4f98-41e9-901a-d5a14dff49c8 | |
$fileInput = "<PUTYOURPATHHERE.csv>" | |
$oldUser = "upnOfOldUser" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assuming you are in the folder of your locally cloned fork.... | |
git checkout main | |
# assuming you have a remote named `upstream` pointing to the official **office365-cli** repo | |
git fetch upstream | |
# update your local main branch to be a mirror of what's in the main repo | |
git pull --rebase upstream main | |
# switch to your branch where you are working, say "issue-xyz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ensures current branch is master | |
git checkout main | |
# pulls all new commits made to upstream/master | |
git pull upstream main | |
# this will delete all your local changes to master | |
git reset --hard upstream/main | |
# take care, this will delete all your changes on your forked master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script provisions a Group with owners and members and Teamifies it | |
# The owners and members can be specified using a CSV file following this format | |
## upn,type | |
## pla@expertsinside.com,owner | |
## eba@expertsinside.com,member | |
## szu@expertsinside.com,member | |
# The CLI will provision the Group adding the current user as owner. You can remove this user from the owners list by using the $removeYourSelfFromOwners parameter | |
$importFile = "<putyourcsvhere.csv>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fileExportPath = "<PUTYOURPATHHERE.csv>" | |
# process teams that you have joined only | |
$joined = $false | |
$m365Status = m365 status | |
if ($m365Status -eq "Logged Out") { | |
# Connection to Microsoft 365 | |
m365 login | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Warning. Use with caution. This script deletes all M365 Groups and SPO Sites in your tenant | |
$devAccount = "<putyourupnhereforsecuritycheck>" | |
### Deletes the resources from the recyclebin. The CLI does not support this feature yet | |
$skipRecycleBin = $true | |
$m365Status = m365 status | |
Write-Host $m365Status | |
if ($m365Status -eq "Logged Out") { | |
# Connection to Microsoft 365 | |
m365 login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$tenant = "<PutYourTenantIdHere>" | |
$env:ClientId = "<PUTYourAppIdHere>" | |
$env:ClientSecret = "<PUTYourAppSecretHere>" | |
$fileExportPath = "<PUTYOURPATHHERE.csv>" | |
Connect-PnPOnline https://$tenant-admin.sharepoint.com -ClientId $env:ClientId -ClientSecret $env:ClientSecret | |
$results = @() | |
$sites = Get-PnPTenantSite | |
$sites | ForEach-Object { |
NewerOlder