1
1
function Test-AADConnected {
2
2
3
3
param (
4
- [Parameter (Mandatory = $false )][Alias ( " UPName " )][ String ]$UserPrincipalName
4
+ [Parameter (Mandatory = $false )][String ]$UserPrincipalName
5
5
)
6
6
Begin {}
7
7
Process {
@@ -16,10 +16,10 @@ function Test-AADConnected {
16
16
}
17
17
18
18
function Set-MSolUMFA {
19
- [CmdletBinding (SupportsShouldProcess = $true )]
19
+ [CmdletBinding (SupportsShouldProcess = $true )]
20
20
param (
21
- [Parameter (Mandatory = $true , ValueFromPipelineByPropertyName = $true )][string ]$UserPrincipalName ,
22
- [Parameter (Mandatory = $true , ValueFromPipelineByPropertyName = $true )][ValidateSet (' Enabled' , ' Disabled' , ' Enforced' )][String ]$StrongAuthenticationRequiremets
21
+ [Parameter (Mandatory = $true , ValueFromPipelineByPropertyName = $true )][string ]$UserPrincipalName ,
22
+ [Parameter (Mandatory = $true , ValueFromPipelineByPropertyName = $true )][ValidateSet (' Enabled' , ' Disabled' , ' Enforced' )][String ]$StrongAuthenticationRequiremets
23
23
)
24
24
begin {
25
25
# Check if connected to Msol Session already
@@ -29,28 +29,28 @@ function Set-MSolUMFA{
29
29
Write-Verbose (' Initiating connection to Msol' )
30
30
Connect-MsolService - ErrorAction Stop
31
31
Write-Verbose (' Connected to Msol successfully' )
32
- }catch {
32
+ } catch {
33
33
return Write-Error ($_.Exception.Message )
34
34
}
35
35
}
36
- if (! (Get-MsolUser - MaxResults 1 - ErrorAction Stop)){
36
+ if (! (Get-MsolUser - MaxResults 1 - ErrorAction Stop)){
37
37
return Write-Error (' Insufficient permissions to set MFA' )
38
38
}
39
39
}
40
40
Process {
41
41
# Get the time and calc 2 min to the future
42
42
$TimeStart = Get-Date
43
43
$TimeEnd = $timeStart.addminutes (1 )
44
- $Finished = $false
44
+ $Finished = $false
45
45
# Loop to check if the user exists already
46
- if ($PSCmdlet.ShouldProcess ($UserPrincipalName , " StrongAuthenticationRequiremets = " + $StrongAuthenticationRequiremets )) {
46
+ if ($PSCmdlet.ShouldProcess ($UserPrincipalName , ' StrongAuthenticationRequiremets = ' + $StrongAuthenticationRequiremets )) {
47
47
}
48
48
}
49
49
End {}
50
50
}
51
51
52
52
Set-MsolUser - UserPrincipalName $UPN - StrongAuthenticationRequirements $sta - ErrorAction Stop
53
- $UserPrincipalName = " Bob"
53
+ $UserPrincipalName = ' Bob'
54
54
if ($UserPrincipalName ) {
55
55
$SplatTestAADConnected.Add (' UserPrincipalName' , $UserPrincipalName )
56
56
}
0 commit comments