-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zip Backup and Message Time to IMG and App create
- Zip backup for each team - IMG set dates to message created - Nuget update + MS Graph fix - Publish script - AAD App Creation
- Loading branch information
1 parent
86fd219
commit 3254993
Showing
19 changed files
with
183 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Azure CLI must be installed | ||
# https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli | ||
# User must be able to create apps and consent (Global Admin, ...) | ||
|
||
$appName = "dev-GKMM-msteamsbackup-app"; #Change for example GKMM to your tenant | ||
$servicePrincipalName = "Microsoft Graph"; | ||
$servicePrincipalNameOauth2Permissions = @("Channel.ReadBasic.All", "ChannelMember.Read.All", "ChannelMessage.Read.All", "ChannelSettings.Read.All", "Group.Read.All", "GroupMember.Read.All", "Team.ReadBasic.All", "TeamMember.Read.All", "TeamSettings.Read.All", "TeamsTab.Read.All"); | ||
|
||
az login --use-device-code --allow-no-subscriptions | ||
|
||
$servicePrincipalId = az ad sp list --filter "displayname eq '$servicePrincipalName'" --query '[0].appId' | ConvertFrom-Json | ||
|
||
$reqGraph = @{ | ||
resourceAppId = $servicePrincipalId | ||
resourceAccess = @() | ||
} | ||
|
||
(az ad sp show --id $servicePrincipalId --query oauth2Permissions | ConvertFrom-Json) | ? { $_.value -in $servicePrincipalNameOauth2Permissions} | % { | ||
$permission = $_ | ||
|
||
$delPermission = @{ | ||
id = $permission.Id | ||
type = "Scope" | ||
} | ||
$reqGraph.resourceAccess += $delPermission | ||
} | ||
|
||
Set-Content ./required_resource_accesses.json -Value ("[" + ($reqGraph | ConvertTo-Json) + "]") | ||
$newapp = az ad app create --display-name $appName --available-to-other-tenants false --native-app true --required-resource-accesses `@required_resource_accesses.json | ConvertFrom-Json | ||
az ad app permission admin-consent --id $newapp.appId | ||
|
||
"ClientId: " + $newapp.appId; | ||
"TenantId: " + (az account show | ConvertFrom-Json).tenantId; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Requires AzureADPreview Module; | ||
# Install-Module AzureADPreview | ||
# User must be able to create apps and consent (Global Admin, ...) | ||
|
||
$appName = "dev-GKMM-msteamsbackup-app"; #Change for example GKMM to your tenant | ||
$servicePrincipalName = "Microsoft Graph"; | ||
$servicePrincipalNameOauth2Permissions = @("Channel.ReadBasic.All", "ChannelMember.Read.All", "ChannelMessage.Read.All", "ChannelSettings.Read.All", "Group.Read.All", "GroupMember.Read.All", "Team.ReadBasic.All", "TeamMember.Read.All", "TeamSettings.Read.All", "TeamsTab.Read.All"); | ||
|
||
# login | ||
Connect-AzureAD; | ||
|
||
# Get MS Graph | ||
$servicePrincipal = Get-AzureADServicePrincipal -All $true | ? { $_.DisplayName -eq $servicePrincipalName }; | ||
|
||
# Thanks http://blog.octavie.nl/index.php/2017/09/19/create-azure-ad-app-registration-with-powershell-part-2 | ||
$reqGraph = New-Object -TypeName "Microsoft.Open.AzureAD.Model.RequiredResourceAccess"; | ||
$reqGraph.ResourceAppId = $servicePrincipal.AppId; | ||
|
||
$servicePrincipal.Oauth2Permissions | ? { $_.Value -in $servicePrincipalNameOauth2Permissions} | % { | ||
$permission = $_ | ||
$delPermission = New-Object -TypeName "Microsoft.Open.AzureAD.Model.ResourceAccess" -ArgumentList $permission.Id,"Scope" #delegate permission (oauth) are always "Scope" | ||
$reqGraph.ResourceAccess += $delPermission | ||
} | ||
|
||
New-AzureADApplication -DisplayName $appName -AvailableToOtherTenants:$false -PublicClient:$true -RequiredResourceAccess $reqGraph; | ||
$newapp = Get-AzureADApplication -SearchString $appName; | ||
"ClientId: " + $newapp.AppId; | ||
"TenantId: " + (Get-AzureADTenantDetail).ObjectId; | ||
|
||
"TODO: Consent in portal"; | ||
"Check AAD app: https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/CallAnAPI/appId/" + $newapp.AppId + "/objectId/" + $newapp.ObjectId + "/isMSAApp/"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#Build release | ||
$corePathToProject = "..\src\BackupConsole"; | ||
$configNames = @("Release"); | ||
|
||
foreach($configName in $configNames){ | ||
$configName; | ||
$publishLocation = ".\$configName-output"; | ||
$publishLocationApp = $publishLocation + "\M365.TeamsBackup.BackupConsole.exe"; | ||
|
||
|
||
dotnet publish $corePathToProject --configuration $configName --output $publishLocation; | ||
|
||
Remove-Item "$publishLocation/appsettings.Development.json"; | ||
Remove-Item "$publishLocation/appsettings.Production.json"; | ||
|
||
if (Test-Path $publishLocationApp){ | ||
|
||
if ((Test-Path $configName) -eq $false){ | ||
mkdir $configName; | ||
} | ||
|
||
$version2publish = [System.Diagnostics.FileVersionInfo]::GetVersionInfo((Get-Location).ToString() + $publishLocationApp).FileVersion.ToString().Replace(".", "-"); | ||
|
||
$thisZipVersion = ".\" + $configName + "\M365.TeamsBackup.BackupConsole-V-" + $version2publish + "-" + $configName + ".zip"; | ||
|
||
Compress-Archive ($publishLocation + "\*") $thisZipVersion -CompressionLevel Fastest; | ||
Remove-Item $publishLocation -Recurse:$true | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#Build release | ||
$corePathToProject = "..\src\BackupToHtmlConsole"; | ||
$configNames = @("Release"); | ||
|
||
foreach($configName in $configNames){ | ||
$configName; | ||
$publishLocation = ".\$configName-output"; | ||
$publishLocationApp = $publishLocation + "\M365.TeamsBackup.BackupToHtmlConsole.exe"; | ||
|
||
|
||
dotnet publish $corePathToProject --configuration $configName --output $publishLocation; | ||
|
||
Remove-Item "$publishLocation/appsettings.Development.json"; | ||
Remove-Item "$publishLocation/appsettings.Production.json"; | ||
|
||
if (Test-Path $publishLocationApp){ | ||
|
||
if ((Test-Path $configName) -eq $false){ | ||
mkdir $configName; | ||
} | ||
|
||
$version2publish = [System.Diagnostics.FileVersionInfo]::GetVersionInfo((Get-Location).ToString() + $publishLocationApp).FileVersion.ToString().Replace(".", "-"); | ||
|
||
$thisZipVersion = ".\" + $configName + "\M365.TeamsBackup.BackupToHtmlConsole-V-" + $version2publish + "-" + $configName + ".zip"; | ||
|
||
Compress-Archive ($publishLocation + "\*") $thisZipVersion -CompressionLevel Fastest; | ||
Remove-Item $publishLocation -Recurse:$true | ||
} | ||
} |
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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