We are suddenly observing that Set-MsolPasswordPolicy and Set-MsolCompanySettings are giving Access Denied. You do not have permissions to call this cmdlet.
The user account is having global administrator privileges, and earlier it was working fine suddenly we are observing it today.
Post checking the log file in C:\Users\\AppData\Local\Microsoft\Office365\Powershell path we observed that someone blocked to use MSOL power shell on our tenant, post allowing, it is working as expected.
$body = (@{"blockMsolPowerShell"="false"} | ConvertTo-Json)
Hi Team,
We are suddenly observing that Set-MsolPasswordPolicy and Set-MsolCompanySettings are giving Access Denied. You do not have permissions to call this cmdlet.
The user account is having global administrator privileges, and earlier it was working fine suddenly we are observing it today.
Code:
Install-Module -Name MSOnline Import-module MSOnline $passwd = ConvertTo-SecureString 'XXXX' -AsPlainText -Force $pscredential = New-Object System.Management.Automation.PSCredential('XXXXX', $passwd)
Connect-MSOlService -Credential $pscredential
Set-MsolPasswordPolicy -ValidityPeriod 60 -NotificationDays 14 -DomainName "XXXXX" -TenantId 'XXXX'
FYI Set-MsolDeviceRegistrationServicePolicy -MaximumDevicesPerUser 1 but it is working as expected.