Skip to content

Commit

Permalink
Aligns script sample command options with v6.3 release. Closes pnp#4441
Browse files Browse the repository at this point in the history
  • Loading branch information
milanholemans committed Feb 24, 2023
1 parent 82f99fc commit 94bf1f9
Show file tree
Hide file tree
Showing 135 changed files with 268 additions and 276 deletions.
Expand Up @@ -5,7 +5,7 @@
"title": "Analyze User Profile Photos using Azure Computer Vision API",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/aad/analyze-user-profile-photos",
"creationDateTime": "2020-11-05",
"updateDateTime": "2020-11-05",
"updateDateTime": "2023-02-28",
"shortDescription": "This script uses Azure Cognitive Service API and Microsoft 365 CLI to analyze user profile pictures.",
"longDescription": [
"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."
Expand All @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "Analyze users for known data breaches with have i been pwned",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/aad/analyze-users-haveibeenpwnd",
"creationDateTime": "2022-02-07",
"updateDateTime": "2022-02-07",
"updateDateTime": "2023-02-28",
"shortDescription": "Validate all your users against known breaches with the have i been pwned api.",
"longDescription": [
"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."
Expand All @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "CLI - Delete all Microsoft 365 groups and SharePoint sites",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/aad/delete-m365-groups-and-sharepoint-sites",
"creationDateTime": "2021-03-15",
"updateDateTime": "2021-03-15",
"updateDateTime": "2023-02-28",
"shortDescription": "delete all Microsoft 365 Groups and SharePoint Online site.",
"longDescription": [
"Another example how you can delete all Microsoft 365 Groups and SharePoint Online sites in your development environment."
Expand All @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "CLI - Delete all Microsoft 365 groups",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/aad/delete-m365-groups",
"creationDateTime": "2020-03-15",
"updateDateTime": "2020-03-15",
"updateDateTime": "2023-02-28",
"shortDescription": "this script deletes the AAD groups you no longer need.",
"longDescription": [
"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."
Expand All @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/sample-scripts/aad/delete-m365-groups/index.md
Expand Up @@ -65,6 +65,6 @@ There are so many different ways to create Microsoft 365 groups. Teams, Planner,
displayName=$(echo $o365group | cut -d';' -f 1)
id=$(echo $o365group | cut -d';' -f 2)
echo "Deleting $displayName..."
m365 aad o365group remove --id "$id" --confirm
m365 aad o365group remove --id $id --confirm
done
```
Expand Up @@ -5,7 +5,7 @@
"title": "Scan for Microsoft 365 Groups created with user's first or last name",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/aad/flag-groups-with-user-names",
"creationDateTime": "2020-03-28",
"updateDateTime": "2020-03-28",
"updateDateTime": "2023-02-28",
"shortDescription": "This sample script scans the Microsoft 365 groups that may contain user’s first or last name as the group mail.",
"longDescription": [
"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."
Expand All @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "Bulk add/remove users to Microsoft Teams and Microsoft 365 Groups",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/aad/manage-group-users",
"creationDateTime": "2020-05-09",
"updateDateTime": "2020-05-09",
"updateDateTime": "2023-02-28",
"shortDescription": "Sample script to add/remove bulk users to/from Microsoft Teams team or Microsoft 365 groupl.",
"longDescription": [
"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."
Expand All @@ -23,7 +23,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/sample-scripts/aad/manage-group-users/index.md
Expand Up @@ -35,7 +35,7 @@ Note: Refactor the code as per your requirement.
If ($action -eq "add") {

If ($role -eq "owner") {
m365 aad o365group user add --groupId $group.id --userName $user.mail --role Owner;
m365 aad o365group user add --groupId $group.id --userName $user.mail --role Owner
Write-Host $user.mail " added as owner in " $group.mailNickname
}
ElseIf ($role -eq "member") {
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "CLI - Replace a user's membership in selected Microsoft 365 Groups or Teams",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/aad/replace-membership-of-selected-groups",
"creationDateTime": "2021-05-04",
"updateDateTime": "2021-05-04",
"updateDateTime": "2023-02-28",
"shortDescription": "This script can be used to replace the membership of a user for a selected list of Groups.",
"longDescription": [
"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."
Expand All @@ -24,7 +24,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -107,7 +107,7 @@ This script can be used to replace the membership of a user for a selected list

try {
Write-Host "Removing $oldUser..."
m365 aad o365group user remove --groupId $groupId --userName $oldUser --confirm $false | Get-CLIValue
m365 aad o365group user remove --groupId $groupId --userName $oldUser | Get-CLIValue
}
catch {
Write-Host $_.Exception.Message -ForegroundColor Red
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "CLI - Replace an owner in a Microsoft 365 Group or Microsoft Team",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/aad/replace-owner-with-a-different-one",
"creationDateTime": "2021-04-28",
"updateDateTime": "2021-04-28",
"updateDateTime": "2023-02-28",
"shortDescription": "Find all the Microsoft 365 Groups that a user is an Owner of and replace them with someone else.",
"longDescription": [
"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."
Expand All @@ -23,7 +23,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -76,7 +76,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 aad o365group user remove --groupId $group.id --userName $oldUser --confirm $false | Get-CLIValue
m365 aad o365group user remove --groupId $group.id --userName $oldUser | Get-CLIValue
}
catch {
Write-Host $_.Exception.Message -ForegroundColor Red
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "Cancel all running flow runs for a flow in an environment",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/flow/cancel-all-running-flow-runs",
"creationDateTime": "2021-06-04",
"updateDateTime": "2021-06-04",
"updateDateTime": "2023-02-28",
"shortDescription": "This script will cancel all running flow runs.",
"longDescription": [
"This script will cancel all running flow runs of a Power Automate flow created in an environment. Pass the Flow environment id and the flow guid as parameter while running the script."
Expand All @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -19,13 +19,11 @@ This script will cancel all running flow runs of a Power Automate flow created i
```powershell
$flowEnvironment = $args[0]
$flowGUID = $args[1]
$flowRuns = m365 flow run list --environment $flowEnvironment --flow $flowGUID --output json | ConvertFrom-Json
$flowRuns = m365 flow run list --environmentName $flowEnvironment --flow $flowGUID --status Running --output json | ConvertFrom-Json
foreach ($run in $flowRuns) {
if ($run.status -eq "Running") {
Write-Output "Run details: " $run
# Cancel all the running flow runs
m365 flow run cancel --environment $flowEnvironment --flow $flowGUID --name $run.name --confirm
Write-Output "Run Cancelled successfully"
}
Write-Output "Run details: " $run
# Cancel all the running flow runs
m365 flow run cancel --environmentName $flowEnvironment --flow $flowGUID --name $run.name --confirm
Write-Output "Run Cancelled successfully"
}
```
Expand Up @@ -5,7 +5,7 @@
"title": "CLI - Export all flows in environment",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/flow/export-all-flows-in-environment",
"creationDateTime": "2021-06-16",
"updateDateTime": "2021-06-16",
"updateDateTime": "2023-02-28",
"shortDescription": "This script will get all flows in your default environment and export them.",
"longDescription": [
"This script will get all flows in your default environment and export them as both a ZIP file for importing back into Power Automate and as a JSON file for importing into Azure as an Azure Logic App."
Expand All @@ -21,7 +21,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -21,7 +21,7 @@ This script will get all flows in your default environment and export them as bo
$environment = m365 flow environment list --query '[?properties.isDefault==`true`].name' --output json | ConvertFrom-JSON

Write-Output "Getting Flows info..."
$flows = m365 flow list --environment $environment --asAdmin --output json | ConvertFrom-JSON
$flows = m365 flow list --environmentName $environment --asAdmin --output json | ConvertFrom-JSON

Write-Output "Found $($flows.Count) Flows to export..."

Expand All @@ -32,8 +32,8 @@ This script will get all flows in your default environment and export them as bo
$exportPath = "$($filename)_$($timestamp)"
$flowId = $_.Name
m365 flow export --id $flowId --environment $environment --packageDisplayName $_.displayName --path "$exportPath.zip"
m365 flow export --id $flowId --environment $environment --format json --path "$exportPath.json"
m365 flow export --id $flowId --environmentName $environment --packageDisplayName $_.displayName --path "$exportPath.zip"
m365 flow export --id $flowId --environmentName $environment --format json --path "$exportPath.json"
}

Write-Output "Complete"
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "Export a single flow to a Logic App",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/flow/export-flow-logicapp",
"creationDateTime": "2021-02-07",
"updateDateTime": "2021-02-07",
"updateDateTime": "2023-02-28",
"shortDescription": "This script will export the Power Automate flow.",
"longDescription": [
"This script will export the Power Automate flow *Your sample test flow*, make sure to pass the correct name in the script, and your flow will be exported right away."
Expand All @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/sample-scripts/flow/export-flow-logicapp/index.md
Expand Up @@ -23,10 +23,10 @@ This script will export the Power Automate flow *Your sample test flow*, make su
```powershell
Write-Output "Getting environment info..."
$environmentId = $(m365 flow environment list --query "[?displayName == '(default)']" -o json | ConvertFrom-Json).Name
$flowId = $(m365 flow list --environment $environmentId --query "[?displayName == 'Your sample test flow']" -o json | ConvertFrom-Json)[0].Name
$flowId = $(m365 flow list --environmentName $environmentId --query "[?displayName == 'Your sample test flow']" -o json | ConvertFrom-Json)[0].Name

Write-Output "Getting Flow info..."
m365 flow export --environment $environmentId --id $flowId -f 'json'
m365 flow export --environmentName $environmentId --id $flowId -f 'json'

Write-Output "Complete"
```
Expand All @@ -36,7 +36,7 @@ This script will export the Power Automate flow *Your sample test flow*, make su
```bash
#!/bin/bash
ENV_NAME=m365 flow environment list --query '[?contains(displayName,`default`)] .name'
FLOW_NAME=m365 flow list --environment $environmentId --query '[?displayName == `Your sample test flow`] .name'
FLOW_NAME=m365 flow list --environmentName $environmentId --query '[?displayName == `Your sample test flow`] .name'
echo "Exporting your flow"
m365 flow export --environment $ENV_NAME --id $FLOW_NAME -f 'json'
m365 flow export --environmentName $ENV_NAME --id $FLOW_NAME -f 'json'
```
Expand Up @@ -5,7 +5,7 @@
"title": "CLI - Flow runs day summary report",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/flow/flow-runs-day-summary",
"creationDateTime": "2021-10-16",
"updateDateTime": "2021-10-16",
"updateDateTime": "2023-02-28",
"shortDescription": "This script creates a report of all flow runs from current day.",
"longDescription": [
"This script creates a report of all flow runs from current day and sends the report as an adaptive card to the provided url."
Expand All @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
9 changes: 3 additions & 6 deletions docs/docs/sample-scripts/flow/flow-runs-day-summary/index.md
Expand Up @@ -25,19 +25,16 @@ This script creates a report of all flow runs from current day and sends the rep

$flows = m365 flow list --environmentName $environment --output json
$flows = $flows | ConvertFrom-Json
$currentDayDate = Get-Date
$previousDayDate = (Get-Date).AddDays(-1)
$currentDayDate = (Get-Date).ToUniversalTime().ToString("o")
$previousDayDate = (Get-Date).AddDays(-1).ToUniversalTime().ToString("o")

$adaptiveCardDescription = ""
foreach ($flow in $flows)
{
$flowRuns = m365 flow run list --environmentName $environment --flowName $flow.name --output json
$flowRuns = $flowRuns | ConvertFrom-Json
$todayRuns = m365 flow run list --environmentName $environment --flowName $flow.name --triggerStartTime $previousDayDate --triggerEndTime $currentDayDate --output json | ConvertFrom-Json

$displayName = $flow.displayName
$id = $flow.name

$todayRuns = $flowRuns.Where({[DateTime]$_.properties.endTime -le $currentDayDate -and [DateTime]$_.properties.endTime -gt $previousDayDate})
$todayRunsCount = 0
$todaySuccessRunsCount = 0
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "Inventory Flows By Creator",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/flow/inventory-flows-by-author",
"creationDateTime": "2020-05-05",
"updateDateTime": "2020-05-05",
"updateDateTime": "2023-02-28",
"shortDescription": "This script retrieves Flows from the Default Environment and maps creator information from Azure AD to list Flows by owner.",
"longDescription": [
"The [Power Automate Admin Center](https://admin.flow.microsoft.com) provides a list of the Flows in your tenant, but there is no way to easily export Flows from the Flow admin center for governance activities. This script retrieves Flows from the Default Environment and maps creator information from Azure AD to list Flows by owner, state and trigger type."
Expand All @@ -22,7 +22,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down
Expand Up @@ -47,7 +47,7 @@ The `bash` version of this script uses an external file to process owner mapping

# Step 2 - Get all of the flows using the cli and write flows json to a tmp file
# Use a JMESPath query to filter the size of the file. See https://github.com/pnp/cli-microsoft365/issues/1266
m365 flow list --environment $defaultEnvironment `
m365 flow list --environmentName $defaultEnvironment `
--query '[].{name: name, displayName: properties.displayName,owner: properties.creator.userId, state: properties.state, created: properties.createdTime, lastModified: properties.lastModifiedTime, trigger: properties.definitionSummary.triggers[0].swaggerOperationId, triggerType: properties.definitionSummary.triggers[0].type }' --asAdmin --output json |
Out-File "$TMP_FLOWS" -Encoding ASCII
$flows = Get-Content "$TMP_FLOWS" | ConvertFrom-Json
Expand Down Expand Up @@ -140,7 +140,7 @@ The `bash` version of this script uses an external file to process owner mapping

#Step 2 - Get all of the flows using the cli and write flows json to a tmp file
#See https://github.com/pnp/cli-microsoft365/issues/1266 for temp file usage reason
m365 flow list --environment $DEFAULT_ENVIRONMENT --asAdmin --output json > $TMP_FLOWS
m365 flow list --environmentName $DEFAULT_ENVIRONMENT --asAdmin --output json > $TMP_FLOWS

#Step 3 - Get a unique list of the flow owners from the tmp file
echo "Flows found, searching for owner values..."
Expand Down
Expand Up @@ -5,7 +5,7 @@
"title": "Resubmit all failed flow runs for a flow in an environment",
"url": "https://pnp.github.io/cli-microsoft365/sample-scripts/flow/resubmit-all-failed-flow-runs",
"creationDateTime": "2021-06-04",
"updateDateTime": "2021-06-04",
"updateDateTime": "2023-02-28",
"shortDescription": "This script will resubmit all failed flow runs.",
"longDescription": [
"This script will resubmit all failed flow runs of a Power Automate flow created in an environment. Pass the Flow environment id and the flow guid as parameter while running the script."
Expand All @@ -20,7 +20,7 @@
"metadata": [
{
"key": "CLI-FOR-MICROSOFT365",
"value": "5.3.0"
"value": "6.3.0"
}
],
"thumbnails": [
Expand Down

0 comments on commit 94bf1f9

Please sign in to comment.