Maintain control of your Microsoft 365 data
chrisflyckelen
Service Provider
Posts: 64 Liked: 8 times
Joined: Oct 15, 2019 7:51 am
Contact:
Post
by chrisflyckelen » Jan 03, 2024 12:16 pm
this post
Hey guys,
i'm struggling to add an organization via PowerShell to VBO. Maybe someone has solved this before.
What I'm trying to achieve is that Teams chats are enabled after adding the organization. Related to the helpcenter it is necessary to create Azure AD application upfront and the script configures this application as needed.
My main issue is converting the data type of the AppGuid to the data type the Veeam Cmdlet expects. I've tried several ways to do this. That's my last attempt:
Code: Select all
Import-Module "C:\Program Files\Veeam\Backup365\Veeam.Archiver.PowerShell\Veeam.Archiver.PowerShell.psd1"
$debnr = Read-Host "Enter customer's debtor no (ktxxxxxxxx)"
$securepassword = Read-Host "Enter your password" -AsSecureString
$certname = "CRT-$debnr-pcoM365BaaS"
#Upfront creation an AzureAD application
Connect-AzureAD
New-AzureADApplication -DisplayName "pco-M365BaaS"
$AzADApp = Get-AzureADApplication -SearchString "pco-M365BaaS" | Select-Object -ExpandProperty AppID
$AzADAppGuid = [System.Guid]$AzADApp
#Creation of a new self-signed certificate
$cert = New-SelfSignedCertificate -Subject "CN=$certname" -CertStoreLocation "Cert:\LocalMachine\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256
Export-PfxCertificate -Cert $cert -FilePath "C:\Certificates\$certname.pfx" -Password $securepassword
$newapp = New-VBOOffice365ApplicationOnlyConnectionSettings -ApplicationCertificatePath "C:\Certificates\$certname.pfx" -ApplicationCertificatePassword $securepassword -ApplicationId $AzADAppGuid -ConfigureApplication
Add-VBOOrganization -Office365ExchangeConnectionsSettings $newapp -Office365SharePointConnectionsSettings $newapp -EnableTeamsChats
May I ask for assistance?
Kind regards,
Christian
Mildur
Product Manager
Posts: 10278 Liked: 2746 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:
Post
by Mildur » Jan 04, 2024 8:07 am
this post
Hi Christian
Why are you not just using the value of the property "AppID"? I don't understand the part where you try to convert the AppID ([System.Guid]$AzADApp).
This works for me:
Code: Select all
Import-Module "C:\Program Files\Veeam\Backup365\Veeam.Archiver.PowerShell\Veeam.Archiver.PowerShell.psd1"
$debnr = Read-Host "Enter customer's debtor no (ktxxxxxxxx)"
$securepassword = Read-Host "Enter your password" -AsSecureString
$certname = "CRT-$debnr-pcoM365BaaS"
#Upfront creation an AzureAD application
Connect-AzureAD
New-AzureADApplication -DisplayName "pco-M365BaaS"
$AzADApp = Get-AzureADApplication -SearchString "pco-M365BaaS" | Select-Object -ExpandProperty AppID
#Creation of a new self-signed certificate
$cert = New-SelfSignedCertificate -Subject "CN=$certname" -CertStoreLocation "Cert:\LocalMachine\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256
Export-PfxCertificate -Cert $cert -FilePath "C:\Certificates\$certname.pfx" -Password $securepassword
$newapp = New-VBOOffice365ApplicationOnlyConnectionSettings -ApplicationCertificatePath "C:\Certificates\$certname.pfx" -ApplicationCertificatePassword $securepassword -ApplicationId $AzADApp -ConfigureApplication
Add-VBOOrganization -Office365ExchangeConnectionsSettings $newapp -Office365SharePointConnectionsSettings $newapp -EnableTeamsChats
Do you get an error message when running your code? Is it possible that your variable
$AzADApp has more than one value? If you use -searchstring, you get all values starting with that string. Multiple values for the AppID are not allowed for
New-VBOOffice365ApplicationOnlyConnectionSettings .
Best,
Fabian
Update:
This code filters with where-object. It only selects one application where the display name matches the provided value:
Code: Select all
Import-Module "C:\Program Files\Veeam\Backup365\Veeam.Archiver.PowerShell\Veeam.Archiver.PowerShell.psd1"
$debnr = Read-Host "Enter customer's debtor no (ktxxxxxxxx)"
$securepassword = Read-Host "Enter your password" -AsSecureString
$certname = "CRT-$debnr-pcoM365BaaS"
#Upfront creation an AzureAD application
Connect-AzureAD
New-AzureADApplication -DisplayName "pco-M365BaaS"
$AzADApp = (Get-AzureADApplication | Where-Object {$_.DisplayName -eq "pco-M365BaaS"}).appid
#Creation of a new self-signed certificate
$cert = New-SelfSignedCertificate -Subject "CN=$certname" -CertStoreLocation "Cert:\LocalMachine\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256
Export-PfxCertificate -Cert $cert -FilePath "C:\Certificates\$certname.pfx" -Password $securepassword
$newapp = New-VBOOffice365ApplicationOnlyConnectionSettings -ApplicationCertificatePath "C:\Certificates\$certname.pfx" -ApplicationCertificatePassword $securepassword -ApplicationId $AzADApp -ConfigureApplication
Add-VBOOrganization -Office365ExchangeConnectionsSettings $newapp -Office365SharePointConnectionsSettings $newapp -EnableTeamsChats
Product Management Analyst @ Veeam Software
Users browsing this forum: No registered users and 20 guests