@@ -2,14 +2,16 @@ function Set-CIPPAuthenticationPolicy {
22 [CmdletBinding (SupportsShouldProcess = $true )]
33 param (
44 [Parameter (Mandatory = $true )]$Tenant ,
5- [Parameter (Mandatory = $true )][ValidateSet (' FIDO2' , ' MicrosoftAuthenticator' , ' SMS' , ' TemporaryAccessPass' , ' HardwareOATH' , ' softwareOath' , ' Voice' , ' Email' , ' x509Certificate' )]$AuthenticationMethodId ,
5+ [Parameter (Mandatory = $true )][ValidateSet (' FIDO2' , ' MicrosoftAuthenticator' , ' SMS' , ' TemporaryAccessPass' , ' HardwareOATH' , ' softwareOath' , ' Voice' , ' Email' , ' x509Certificate' , ' QRCodePin ' )]$AuthenticationMethodId ,
66 [Parameter (Mandatory = $true )][bool ]$Enabled , # true = enabled or false = disabled
77 $MicrosoftAuthenticatorSoftwareOathEnabled ,
88 $TAPMinimumLifetime = 60 , # Minutes
99 $TAPMaximumLifetime = 480 , # minutes
1010 $TAPDefaultLifeTime = 60 , # minutes
1111 $TAPDefaultLength = 8 , # TAP password generated length in chars
1212 $TAPisUsableOnce = $true ,
13+ [Parameter ()][ValidateRange (1 , 395 )]$QRCodeLifetimeInDays = 365 ,
14+ [Parameter ()][ValidateRange (8 , 20 )]$QRCodePinLength = 8 ,
1315 $APIName = ' Set Authentication Policy' ,
1416 $Headers
1517 )
@@ -103,6 +105,14 @@ function Set-CIPPAuthenticationPolicy {
103105 ' x509Certificate' {
104106 # Nothing special to do here
105107 }
108+
109+ # QR code
110+ ' QRCodePin' {
111+ if ($State -eq ' enabled' ) {
112+ $CurrentInfo.pinLength = $QRCodePinLength
113+ $CurrentInfo.standardQRCodeLifetimeInDays = $QRCodeLifetimeInDays
114+ }
115+ }
106116 Default {
107117 Write-LogMessage - headers $Headers - API $APIName - tenant $Tenant - message " Somehow you hit the default case with an input of $AuthenticationMethodId . You probably made a typo in the input for AuthenticationMethodId. It`' s case sensitive." - sev Error
108118 return " Somehow you hit the default case with an input of $AuthenticationMethodId . You probably made a typo in the input for AuthenticationMethodId. It`' s case sensitive."
@@ -112,14 +122,14 @@ function Set-CIPPAuthenticationPolicy {
112122 try {
113123 if ($PSCmdlet.ShouldProcess ($AuthenticationMethodId , " Set state to $State $OptionalLogMessage " )) {
114124 # Convert body to JSON and send request
115- $null = New-GraphPostRequest - tenantid $Tenant - Uri " https://graph.microsoft.com/beta/policies/authenticationmethodspolicy/authenticationMethodConfigurations/$AuthenticationMethodId " - Type patch - Body ($CurrentInfo | ConvertTo-Json - Compress - Depth 10 ) - ContentType ' application/json'
125+ $null = New-GraphPostRequest - tenantid $Tenant - Uri " https://graph.microsoft.com/beta/policies/authenticationmethodspolicy/authenticationMethodConfigurations/$AuthenticationMethodId " - Type PATCH - Body (ConvertTo-Json - InputObject $CurrentInfo - Compress - Depth 10 ) - ContentType ' application/json'
116126 Write-LogMessage - headers $Headers - API $APIName - tenant $Tenant - message " Set $AuthenticationMethodId state to $State $OptionalLogMessage " - sev Info
117127 }
118128 return " Set $AuthenticationMethodId state to $State $OptionalLogMessage "
119129
120130 } catch {
121131 $ErrorMessage = Get-CippException - Exception $_
122132 Write-LogMessage - headers $Headers - API $APIName - tenant $Tenant - message " Failed to $State $AuthenticationMethodId Support: $ErrorMessage " - sev Error - LogData $ErrorMessage
123- return " Failed to $State $AuthenticationMethodId Support. Error: $ ( $ErrorMessage.NormalizedError ) "
133+ throw " Failed to $State $AuthenticationMethodId Support. Error: $ ( $ErrorMessage.NormalizedError ) "
124134 }
125135}
0 commit comments