Exchange online retention Policy and Microsoft teams policy

Exchange online retention Policy and Microsoft teams policy

Hi,

since the template for user creation is unable to assign mailbox retention policy and unable to assign teams policy. I think the only way would be using the custom attribute > powershell script.

Currently i am using the script below. However there is no error at all and the script isn't applying. When i ran the script below and specify the UPN manually, it definitely works. Any idea?

#import password file
$pword = Get-Content #removedduetoprivacy
$365Cred = New-Object #removedduetoprivacy
#connect to Microsoft teams admin
connect-microsoftteams -credential #removedduetoprivacy

#Connect to Office 365 Exchange
Connect-ExchangeOnline -UserPrincipalName #serviceaccount -ShowProgress $true -Credential #removedduetoprivacy

#Set the App Permission Policy
Grant-CsTeamsAppPermissionPolicy -PolicyName "Company Prod App Policy" -identity %userPrincipalName%

#Set the App Setup Policy
Grant-CsTeamsAppSetupPolicy -identity %userPrincipalName% -PolicyName "Company Prod App Setup Policy" 

#Set Retention Policy to 6 Months
Set-Mailbox -Identity %userPrincipalName -RetentionPolicy "Company Enterprise Archive Policy"

                New to ADSelfService Plus?