Hi @Limitless Technology : You have provided commands for Exchange Online. Do you have commands for O365 Admin center (to connect MsolService via PowerShell commands)?
Modern authentication (PowerShell script to connect O365 Admin center, Exchange Online)
Currently using below scripts in PowerShell (unattended mode) - Can you provide and advise for below queries.
- As we know that, Microsoft is depreciating basic authentication in Oct2022. In both scripts, it seems bot is utilising basic authentication? Is it correct understanding
- If yes, it will impact both scripts during execution after Oct 2022. How to mitigate this for authentication? Do i have to make any changes in script as modules are already installed in Production servers.
Script #1 : Allocate O365 licenses (as arguments) to new user (O365 Admin center)
$cred = New-Object System.Management.Automation.PsCredential($Botusername, (ConvertTo-SecureString $Password -AsPlainText -Force))
Import-Module MSOnline
Connect-MsolService -Credential $cred
Set-MsolUser -UserPrincipalName $Name -UsageLocation AU
Set-MsolUserLicense -UserPrincipalName $Name -AddLicenses $License1, $License2
Get-msoluser -UserPrincipalName $Name | select Licenses
Scripts #2 : Add new user in DL (Exchange Online)
param([Parameter(Mandatory=$true)] $Botusername,[Parameter(Mandatory=$true)] $Password,[Parameter(Mandatory=$true)] $username,[Parameter(Mandatory=$true)] $MailGroup)
$cred = New-Object System.Management.Automation.PsCredential($Botusername, (ConvertTo-SecureString $Password -AsPlainText -Force))
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -Credential $cred
Add-DistributionGroupMember -Identity $MailGroup -Member $username
Windows for business | Windows Server | User experience | PowerShell
3 answers
Sort by: Most helpful
-
-
Limitless Technology 39,926 Reputation points
2022-08-16T14:45:02.797+00:00 Hello
Thank you for your question and reaching out. I can understand you are having query\issues related to
I believe you can use certificate based authentication Once you have changed to Certificate Based Authentication, the above cmdlet pattern will need to be changed to use Connect-Exchange Online along with other necessary parameters. For example:
Connect-ExchangeOnline -CertificateFilePath "C:\temp\automation-cert.pfx" -CertificatePassword (ConvertTo-SecureString -String "<My Password>" -AsPlainText -Force) -AppID "36ee4c6c-0812-40a2-b820-b22ebd02bce3" -Organization "contoso.onmicrosoft.com"
Reference :
---------------------------------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept as answer--
-
Rohit 6 Reputation points
2022-08-17T23:58:41.397+00:00 @Limitless Technology - Thanks for sharing solution (I can securely put this file and use it in script). One thing to check - what this automation-cert.pfx file contains?