diff --git a/.github/workflows/PublishGitHubPages.yml b/.github/workflows/PublishGitHubPages.yml index 9e5d43e675..d1402a56bb 100644 --- a/.github/workflows/PublishGitHubPages.yml +++ b/.github/workflows/PublishGitHubPages.yml @@ -21,6 +21,7 @@ jobs: New-M365DSCCmdletDocumentation - name: Commit files # commit the output folder if: always() + shell: pwsh run: | git config --local user.email "nik.charlebois@microsoft.com" git config --local user.name "Nik Charlebois" @@ -29,7 +30,7 @@ jobs: git commit -m "Updated Resources and Cmdlet documentation pages" git push $SHA = git rev-parse HEAD - echo "::set-output name=commitid::$SHA" + echo "commitid=$SHA" >> $env:GITHUB_OUTPUT deploy: needs: GenerateResource diff --git a/CHANGELOG.md b/CHANGELOG.md index d02360df44..c6d6726636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,25 @@ # UNRELEASED - * DRG +* IntuneASRRulesPolicyWindows10 + * Corrects possible values for parameter OfficeCommunicationAppsLaunchChildProcess + FIXES [#2730](https://github.com/microsoft/Microsoft365DSC/issues/2730) +* TeamsIPPhonePolicy + * Added descriptions to the resource parameters + * Limited possible parameter values where required + FIXES [#2722](https://github.com/microsoft/Microsoft365DSC/issues/2722) +* TeamsMeetingPolicy + * Deprecating RecordingStorageMode parameter, which is no longer available. + FIXES [#2723](https://github.com/microsoft/Microsoft365DSC/issues/2723) +* TeamsShiftsPolicy + * Added descriptions to the resource parameters + * Limited possible parameter values where required + FIXES [#2722](https://github.com/microsoft/Microsoft365DSC/issues/2722) +* TeamsFilesPolicy + * Added descriptions to the resource parameters + * Limited possible parameter values where required + FIXES [#2722](https://github.com/microsoft/Microsoft365DSC/issues/2722) +* DRG * Various fixes for Graph and Intune resources automation * Migrated to new schema including description * Added support to generate parameter descriptions automatically from schema diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneASRRulesPolicyWindows10/MSFT_IntuneASRRulesPolicyWindows10.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneASRRulesPolicyWindows10/MSFT_IntuneASRRulesPolicyWindows10.schema.mof index 15de4150c3..8d006b6b63 100644 Binary files a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneASRRulesPolicyWindows10/MSFT_IntuneASRRulesPolicyWindows10.schema.mof and b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneASRRulesPolicyWindows10/MSFT_IntuneASRRulesPolicyWindows10.schema.mof differ diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsFilesPolicy/MSFT_TeamsFilesPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsFilesPolicy/MSFT_TeamsFilesPolicy.psm1 index 9dbfd29aad..9a5471c6f3 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsFilesPolicy/MSFT_TeamsFilesPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsFilesPolicy/MSFT_TeamsFilesPolicy.psm1 @@ -9,10 +9,12 @@ function Get-TargetResource $Identity, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $NativeFileEntryPoints, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $SPChannelFilesTab, @@ -98,10 +100,12 @@ function Set-TargetResource $Identity, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $NativeFileEntryPoints, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $SPChannelFilesTab, @@ -209,10 +213,12 @@ function Test-TargetResource $Identity, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $NativeFileEntryPoints, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $SPChannelFilesTab, @@ -316,7 +322,7 @@ function Export-TargetResource $ManagedIdentity ) - $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftTeams' ` + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftTeams' ` -InboundParameters $PSBoundParameters #Ensure the proper dependencies are installed in the current environment. @@ -354,11 +360,11 @@ function Export-TargetResource } Write-Host " |---[$i/$($getValue.Count)] $displayedKey" -NoNewline $params = @{ - Identity = $config.Identity - Ensure = 'Present' - Credential = $Credential - ApplicationId = $ApplicationId - TenantId = $TenantId + Identity = $config.Identity + Ensure = 'Present' + Credential = $Credential + ApplicationId = $ApplicationId + TenantId = $TenantId CertificateThumbprint = $CertificateThumbprint } diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsFilesPolicy/MSFT_TeamsFilesPolicy.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsFilesPolicy/MSFT_TeamsFilesPolicy.schema.mof index 595dc72037..65d59f8b9e 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsFilesPolicy/MSFT_TeamsFilesPolicy.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsFilesPolicy/MSFT_TeamsFilesPolicy.schema.mof @@ -1,9 +1,9 @@ [ClassVersion("1.0.0.0"), FriendlyName("TeamsFilesPolicy")] class MSFT_TeamsFilesPolicy : OMI_BaseResource { - [Key, Description("")] String Identity; - [Write, Description("")] String NativeFileEntryPoints; - [Write, Description("")] String SPChannelFilesTab; + [Key, Description("Specifies the policy instance name")] String Identity; + [Write, Description("Specifies whether users see the options to upload files from OneDrive for Business, other cloud storage services configured for the user account, and SharePoint Online"), ValueMap{"Enabled","Disabled"}, Values{"Enabled","Disabled"}] String NativeFileEntryPoints; + [Write, Description("Specifies whether users see the Teams Files channel tab in any channel or in Teams chat."), ValueMap{"Enabled","Disabled"}, Values{"Enabled","Disabled"}] String SPChannelFilesTab; [Write, Description("Present ensures the instance exists, absent ensures it is removed."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [Write, Description("Credentials of the workload's Admin"), EmbeddedInstance("MSFT_Credential")] string Credential; [Write, Description("Id of the Azure Active Directory application to authenticate with.")] String ApplicationId; diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsIPPhonePolicy/MSFT_TeamsIPPhonePolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsIPPhonePolicy/MSFT_TeamsIPPhonePolicy.psm1 index 718a0cb7ee..72d842411e 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsIPPhonePolicy/MSFT_TeamsIPPhonePolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsIPPhonePolicy/MSFT_TeamsIPPhonePolicy.psm1 @@ -9,10 +9,12 @@ function Get-TargetResource $Identity, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $AllowBetterTogether, [Parameter()] + [ValidateSet('Enabled', 'EnabledUserOverride', 'Disabled')] [System.String] $AllowHomeScreen, @@ -29,10 +31,12 @@ function Get-TargetResource $HotDeskingIdleTimeoutInMinutes, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $SearchOnCommonAreaPhoneMode, [Parameter()] + [ValidateSet('UserSignIn', 'CommonAreaPhoneSignIn', 'MeetingSignIn')] [System.String] $SignInMode, @@ -123,10 +127,12 @@ function Set-TargetResource $Identity, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $AllowBetterTogether, [Parameter()] + [ValidateSet('Enabled', 'EnabledUserOverride', 'Disabled')] [System.String] $AllowHomeScreen, @@ -143,10 +149,12 @@ function Set-TargetResource $HotDeskingIdleTimeoutInMinutes, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $SearchOnCommonAreaPhoneMode, [Parameter()] + [ValidateSet('UserSignIn', 'CommonAreaPhoneSignIn', 'MeetingSignIn')] [System.String] $SignInMode, @@ -254,10 +262,12 @@ function Test-TargetResource $Identity, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $AllowBetterTogether, [Parameter()] + [ValidateSet('Enabled', 'EnabledUserOverride', 'Disabled')] [System.String] $AllowHomeScreen, @@ -274,10 +284,12 @@ function Test-TargetResource $HotDeskingIdleTimeoutInMinutes, [Parameter()] + [ValidateSet('Enabled', 'Disabled')] [System.String] $SearchOnCommonAreaPhoneMode, [Parameter()] + [ValidateSet('UserSignIn', 'CommonAreaPhoneSignIn', 'MeetingSignIn')] [System.String] $SignInMode, @@ -381,7 +393,7 @@ function Export-TargetResource $ManagedIdentity ) - $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftTeams' ` + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftTeams' ` -InboundParameters $PSBoundParameters #Ensure the proper dependencies are installed in the current environment. @@ -419,11 +431,11 @@ function Export-TargetResource } Write-Host " |---[$i/$($getValue.Count)] $displayedKey" -NoNewline $params = @{ - Identity = $config.Identity - Ensure = 'Present' - Credential = $Credential - ApplicationId = $ApplicationId - TenantId = $TenantId + Identity = $config.Identity + Ensure = 'Present' + Credential = $Credential + ApplicationId = $ApplicationId + TenantId = $TenantId CertificateThumbprint = $CertificateThumbprint } diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsIPPhonePolicy/MSFT_TeamsIPPhonePolicy.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsIPPhonePolicy/MSFT_TeamsIPPhonePolicy.schema.mof index 69ffaa205f..e4fe6f5bc7 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsIPPhonePolicy/MSFT_TeamsIPPhonePolicy.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsIPPhonePolicy/MSFT_TeamsIPPhonePolicy.schema.mof @@ -1,14 +1,14 @@ [ClassVersion("1.0.0.0"), FriendlyName("TeamsIPPhonePolicy")] class MSFT_TeamsIPPhonePolicy : OMI_BaseResource { - [Key, Description("")] String Identity; - [Write, Description("")] String AllowBetterTogether; - [Write, Description("")] String AllowHomeScreen; - [Write, Description("")] Boolean AllowHotDesking; - [Write, Description("")] String Description; - [Write, Description("")] UInt64 HotDeskingIdleTimeoutInMinutes; - [Write, Description("")] String SearchOnCommonAreaPhoneMode; - [Write, Description("")] String SignInMode; + [Key, Description("Specifies the policy instance name")] String Identity; + [Write, Description("Determines whether Better Together mode is enabled, phones can lock and unlock in an integrated fashion when connected to their Windows PC running a 64-bit Teams desktop client."), ValueMap{"Enabled","Disabled"}, Values{"Enabled","Disabled"}] String AllowBetterTogether; + [Write, Description("Determines whether the Home Screen feature of the Teams IP Phones is enabled."), ValueMap{"Enabled","EnabledUserOverride","Disabled"}, Values{"Enabled","EnabledUserOverride","Disabled"}] String AllowHomeScreen; + [Write, Description("Determines whether hot desking mode is enabled.")] Boolean AllowHotDesking; + [Write, Description("Specifies the description of the policy")] String Description; + [Write, Description("Determines the idle timeout value in minutes for the signed in user account. When the timeout is reached, the account is logged out.")] UInt64 HotDeskingIdleTimeoutInMinutes; + [Write, Description("Determines whether a user can search the Global Address List in Common Area Phone Mode."), ValueMap{"Enabled","Disabled"}, Values{"Enabled","Disabled"}] String SearchOnCommonAreaPhoneMode; + [Write, Description("Determines the sign in mode for the device when signing in to Teams."), ValueMap{"UserSignIn","CommonAreaPhoneSignIn","MeetingSignIn"}, Values{"UserSignIn","CommonAreaPhoneSignIn","MeetingSignIn"}] String SignInMode; [Write, Description("Present ensures the instance exists, absent ensures it is removed."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [Write, Description("Credentials of the workload's Admin"), EmbeddedInstance("MSFT_Credential")] string Credential; [Write, Description("Id of the Azure Active Directory application to authenticate with.")] String ApplicationId; diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsMeetingPolicy/MSFT_TeamsMeetingPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsMeetingPolicy/MSFT_TeamsMeetingPolicy.psm1 index f2819ace9c..71cc26f519 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsMeetingPolicy/MSFT_TeamsMeetingPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsMeetingPolicy/MSFT_TeamsMeetingPolicy.psm1 @@ -225,7 +225,7 @@ function Get-TargetResource [Parameter()] [System.UInt32] - [ValidateRange(-1,99999)] + [ValidateRange(-1, 99999)] $NewMeetingRecordingExpirationDays, [Parameter()] @@ -237,6 +237,7 @@ function Get-TargetResource [System.String] $QnAEngagementMode, + #DEPRECATED [Parameter()] [System.String] [ValidateSet('Stream', 'OneDriveForBusiness')] @@ -320,6 +321,11 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion + # Warning for deprecated parameters + if ($PSBoundParameters.ContainsKey('RecordingStorageMode')) + { + Write-Warning 'RecordingStorageMode is deprecated. Please remove this parameter from your configuration.' + } $nullReturn = $PSBoundParameters $nullReturn.Ensure = 'Absent' @@ -390,7 +396,8 @@ function Get-TargetResource NewMeetingRecordingExpirationDays = $policy.NewMeetingRecordingExpirationDays PreferredMeetingProviderForIslandsMode = $policy.PreferredMeetingProviderForIslandsMode QnAEngagementMode = $policy.QnAEngagementMode - RecordingStorageMode = $policy.RecordingStorageMode + #DEPRECATED + #RecordingStorageMode = $policy.RecordingStorageMode RoomPeopleNameUserOverride = $policy.RoomPeopleNameUserOverride ScreenSharingMode = $policy.ScreenSharingMode SpeakerAttributionMode = $policy.SpeakerAttributionMode @@ -643,7 +650,7 @@ function Set-TargetResource [Parameter()] [System.UInt32] - [ValidateRange(-1,99999)] + [ValidateRange(-1, 99999)] $NewMeetingRecordingExpirationDays, [Parameter()] @@ -655,6 +662,7 @@ function Set-TargetResource [System.String] $QnAEngagementMode, + #DEPRECATED [Parameter()] [System.String] [ValidateSet('Stream', 'OneDriveForBusiness')] @@ -738,6 +746,12 @@ function Set-TargetResource $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftTeams' ` -InboundParameters $PSBoundParameters + # Warning for deprecated parameters + if ($PSBoundParameters.ContainsKey('RecordingStorageMode')) + { + Write-Warning 'RecordingStorageMode is deprecated. Please remove this parameter from your configuration.' + } + $CurrentValues = Get-TargetResource @PSBoundParameters $SetParameters = $PSBoundParameters @@ -748,6 +762,10 @@ function Set-TargetResource $SetParameters.Remove('CertificateThumbprint') | Out-Null $SetParameters.Remove('Verbose') | Out-Null # Needs to be implicitly removed for the cmdlet to work + # Remove deprecated parameters + #DEPRECATED + $SetParameters.Remove('RecordingStorageMode') | Out-Null + if ($Ensure -eq 'Present' -and $CurrentValues.Ensure -eq 'Absent') { Write-Verbose -Message "Creating a new Teams Meeting Policy {$Identity}" @@ -778,7 +796,6 @@ function Set-TargetResource } if ($SetParameters.AllowCloudRecording -eq $false ) { - $SetParameters.Remove('RecordingStorageMode') $SetParameters.Remove('AllowRecordingStorageOutsideRegion') } Set-CsTeamsMeetingPolicy @SetParameters @@ -1017,7 +1034,7 @@ function Test-TargetResource [Parameter()] [System.UInt32] - [ValidateRange(-1,99999)] + [ValidateRange(-1, 99999)] $NewMeetingRecordingExpirationDays, [Parameter()] @@ -1029,6 +1046,7 @@ function Test-TargetResource [System.String] $QnAEngagementMode, + #DEPRECATED [Parameter()] [System.String] [ValidateSet('Stream', 'OneDriveForBusiness')] @@ -1106,6 +1124,12 @@ function Test-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion + # Warning for deprecated parameters + if ($PSBoundParameters.ContainsKey('RecordingStorageMode')) + { + Write-Warning 'RecordingStorageMode is deprecated. Please remove this parameter from your configuration.' + } + Write-Verbose -Message "Testing configuration of Team Meeting Policy {$Identity}" $CurrentValues = Get-TargetResource @PSBoundParameters @@ -1122,6 +1146,9 @@ function Test-TargetResource # The AllowIPVideo is temporarly not working, therefore we won't check the value. $ValuesToCheck.Remove('AllowIPVideo') | Out-Null + # Remove deprecated parameters + #DEPRECATED + $ValuesToCheck.Remove('RecordingStorageMode') | Out-Null $TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` -Source $($MyInvocation.MyCommand.Source) ` diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsMeetingPolicy/MSFT_TeamsMeetingPolicy.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsMeetingPolicy/MSFT_TeamsMeetingPolicy.schema.mof index 23927b4c7d..2aa71c82d8 100644 Binary files a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsMeetingPolicy/MSFT_TeamsMeetingPolicy.schema.mof and b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsMeetingPolicy/MSFT_TeamsMeetingPolicy.schema.mof differ diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsShiftsPolicy/MSFT_TeamsShiftsPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsShiftsPolicy/MSFT_TeamsShiftsPolicy.psm1 index 9b33693328..c8c766090c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsShiftsPolicy/MSFT_TeamsShiftsPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsShiftsPolicy/MSFT_TeamsShiftsPolicy.psm1 @@ -13,6 +13,7 @@ function Get-TargetResource $AccessGracePeriodMinutes, [Parameter()] + [ValidateSet('UnrestrictedAccess_TeamsApp')] [System.String] $AccessType, @@ -25,6 +26,7 @@ function Get-TargetResource $EnableShiftPresence, [Parameter()] + [ValidateSet('Always', 'ShowOnceOnChange', 'Never')] [System.String] $ShiftNoticeFrequency, @@ -33,6 +35,7 @@ function Get-TargetResource $ShiftNoticeMessageCustom, [Parameter()] + [ValidateSet('DefaultMessage', 'Message1', 'Message2', 'Message3', 'Message4', 'Message5', 'Message6', 'Message7', 'CustomMessage')] [System.String] $ShiftNoticeMessageType, @@ -127,6 +130,7 @@ function Set-TargetResource $AccessGracePeriodMinutes, [Parameter()] + [ValidateSet('UnrestrictedAccess_TeamsApp')] [System.String] $AccessType, @@ -139,6 +143,7 @@ function Set-TargetResource $EnableShiftPresence, [Parameter()] + [ValidateSet('Always', 'ShowOnceOnChange', 'Never')] [System.String] $ShiftNoticeFrequency, @@ -147,6 +152,7 @@ function Set-TargetResource $ShiftNoticeMessageCustom, [Parameter()] + [ValidateSet('DefaultMessage', 'Message1', 'Message2', 'Message3', 'Message4', 'Message5', 'Message6', 'Message7', 'CustomMessage')] [System.String] $ShiftNoticeMessageType, @@ -258,6 +264,7 @@ function Test-TargetResource $AccessGracePeriodMinutes, [Parameter()] + [ValidateSet('UnrestrictedAccess_TeamsApp')] [System.String] $AccessType, @@ -270,6 +277,7 @@ function Test-TargetResource $EnableShiftPresence, [Parameter()] + [ValidateSet('Always', 'ShowOnceOnChange', 'Never')] [System.String] $ShiftNoticeFrequency, @@ -278,6 +286,7 @@ function Test-TargetResource $ShiftNoticeMessageCustom, [Parameter()] + [ValidateSet('DefaultMessage', 'Message1', 'Message2', 'Message3', 'Message4', 'Message5', 'Message6', 'Message7', 'CustomMessage')] [System.String] $ShiftNoticeMessageType, @@ -381,7 +390,7 @@ function Export-TargetResource $ManagedIdentity ) - $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftTeams' ` + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftTeams' ` -InboundParameters $PSBoundParameters #Ensure the proper dependencies are installed in the current environment. @@ -419,11 +428,11 @@ function Export-TargetResource } Write-Host " |---[$i/$($getValue.Count)] $displayedKey" -NoNewline $params = @{ - Identity = $config.Identity - Ensure = 'Present' - Credential = $Credential - ApplicationId = $ApplicationId - TenantId = $TenantId + Identity = $config.Identity + Ensure = 'Present' + Credential = $Credential + ApplicationId = $ApplicationId + TenantId = $TenantId CertificateThumbprint = $CertificateThumbprint } diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsShiftsPolicy/MSFT_TeamsShiftsPolicy.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsShiftsPolicy/MSFT_TeamsShiftsPolicy.schema.mof index be006c0432..1216e56a1f 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsShiftsPolicy/MSFT_TeamsShiftsPolicy.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsShiftsPolicy/MSFT_TeamsShiftsPolicy.schema.mof @@ -1,14 +1,14 @@ [ClassVersion("1.0.0.0"), FriendlyName("TeamsShiftsPolicy")] class MSFT_TeamsShiftsPolicy : OMI_BaseResource { - [Key, Description("")] String Identity; - [Write, Description("")] UInt64 AccessGracePeriodMinutes; - [Write, Description("")] String AccessType; - [Write, Description("")] Boolean EnableScheduleOwnerPermissions; - [Write, Description("")] Boolean EnableShiftPresence; - [Write, Description("")] String ShiftNoticeFrequency; - [Write, Description("")] String ShiftNoticeMessageCustom; - [Write, Description("")] String ShiftNoticeMessageType; + [Key, Description("Specifies the policy instance name")] String Identity; + [Write, Description("Determines the grace period time in minutes between when the first shift starts or last shift ends and when access is blocked")] UInt64 AccessGracePeriodMinutes; + [Write, Description("Determines the Teams access type granted to the user. Today, only unrestricted access to Teams app is supported."), ValueMap{"UnrestrictedAccess_TeamsApp"}, Values{"UnrestrictedAccess_TeamsApp"}] String AccessType; + [Write, Description("Determines whether a user can manage a Shifts schedule as a team member.")] Boolean EnableScheduleOwnerPermissions; + [Write, Description("Determines whether a user is given shift-based presence (On shift, Off shift, or Busy). This must be set in order to have any off shift warning message-specific settings.")] Boolean EnableShiftPresence; + [Write, Description("Determines the frequency of warning dialog displayed when user opens Teams."), ValueMap{"Always","ShowOnceOnChange","Never"}, Values{"Always","ShowOnceOnChange","Never"}] String ShiftNoticeFrequency; + [Write, Description("Specifies a custom message. Must set ShiftNoticeMessageType to 'CustomMessage' to enforce this")] String ShiftNoticeMessageCustom; + [Write, Description("Specifies the warning message is shown in the blocking dialog when a user access Teams off shift hours. Select one of 7 Microsoft provided messages, a default message or a custom message."), ValueMap{"DefaultMessage","Message1","Message2","Message3","Message4","Message5","Message6","Message7","CustomMessage"}, Values{"DefaultMessage","Message1","Message2","Message3","Message4","Message5","Message6","Message7","CustomMessage"}] String ShiftNoticeMessageType; [Write, Description("Present ensures the instance exists, absent ensures it is removed."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [Write, Description("Credentials of the workload's Admin"), EmbeddedInstance("MSFT_Credential")] string Credential; [Write, Description("Id of the Azure Active Directory application to authenticate with.")] String ApplicationId; diff --git a/ResourceGenerator/M365DSCResourceGenerator.psm1 b/ResourceGenerator/M365DSCResourceGenerator.psm1 index 31b46e5d58..98f8ea28ff 100644 --- a/ResourceGenerator/M365DSCResourceGenerator.psm1 +++ b/ResourceGenerator/M365DSCResourceGenerator.psm1 @@ -64,7 +64,7 @@ function New-M365DSCResource $readmeFilePath = New-M365DSCReadmeFile -ResourceName $ResourceName -Path $Path $unitTestPath = New-M365DSCUnitTest -ResourceName $ResourceName -Path $UnitTestPath - $graphWorkloads=@('MicrosoftGraph','Intune') + $graphWorkloads = @('MicrosoftGraph', 'Intune') if ($Workload -in $graphWorkloads) { $Global:CIMInstancesAlreadyFound = @() @@ -119,7 +119,7 @@ function New-M365DSCResource -APIVersion $ApiVersion #Check if the actual type returns multiple type of policies - $policyTypes=($cmdletDefinition.EntityType|Where-Object -FilterScript {$_.basetype -like "*$actualType"}).Name + $policyTypes = ($cmdletDefinition.EntityType | Where-Object -FilterScript { $_.basetype -like "*$actualType" }).Name if ($null -ne $policyTypes -and $policyTypes.GetType().Name -like '*[[\]]') { if ([String]::IsNullOrEmpty($AdditionalPropertiesType)) @@ -173,36 +173,36 @@ function New-M365DSCResource $repository = 'deviceManagement/deviceConfigurations' $addIntuneAssignments = $true $ParametersToSkip += 'Assignments' - $assignmentCmdletNoun= 'MgDeviceManagementDeviceConfigurationAssignment' - $assignmentKey='DeviceConfigurationId' + $assignmentCmdletNoun = 'MgDeviceManagementDeviceConfigurationAssignment' + $assignmentKey = 'DeviceConfigurationId' } 'DeviceCompliancePolicy' { $repository = 'deviceCompliancePolicies' $addIntuneAssignments = $true $ParametersToSkip += 'Assignments' - $assignmentCmdletNoun= 'MgDeviceManagementCompliancePolicyAssignment' - $assignmentKey='DeviceManagementConfigurationPolicyAssignmentId' + $assignmentCmdletNoun = 'MgDeviceManagementCompliancePolicyAssignment' + $assignmentKey = 'DeviceManagementConfigurationPolicyAssignmentId' } 'DeviceManagementConfigurationPolicy' { $repository = 'deviceManagement/configurationPolicies' $addIntuneAssignments = $true $ParametersToSkip += 'Assignments' - $assignmentCmdletNoun= 'MgDeviceManagementConfigurationPolicyAssignment' - $assignmentKey='DeviceManagementConfigurationPolicyId' + $assignmentCmdletNoun = 'MgDeviceManagementConfigurationPolicyAssignment' + $assignmentKey = 'DeviceManagementConfigurationPolicyId' } 'DeviceManagementIntent' { $repository = 'deviceManagement/intents' $addIntuneAssignments = $true $ParametersToSkip += 'Assignments' - $assignmentCmdletNoun= 'MgDeviceManagementIntentAssignment' - $assignmentKey='DeviceManagementIntentId' + $assignmentCmdletNoun = 'MgDeviceManagementIntentAssignment' + $assignmentKey = 'DeviceManagementIntentId' } } } - $parameterInformation = $parameterInformation | Where-Object -FilterScript {$_.Name -notin $ParametersToSkip} + $parameterInformation = $parameterInformation | Where-Object -FilterScript { $_.Name -notin $ParametersToSkip } @@ -261,10 +261,10 @@ function New-M365DSCResource $platforms = @{ 'Windows10' = 'for Windows10' - 'Android' = 'for Android' - 'Mac O S' = 'for macOS' - 'I O S' = 'for iOS' - 'A A D' = 'Azure AD' + 'Android' = 'for Android' + 'Mac O S' = 'for macOS' + 'I O S' = 'for iOS' + 'A A D' = 'Azure AD' } $resourceDescription = ($ResourceName -split '_')[0] -creplace '(?<=\w)([A-Z])', ' $1' foreach ($platform in $platforms.keys) @@ -285,46 +285,46 @@ function New-M365DSCResource $getKeyIdentifier = ($getDefaultParameterSet.Parameters | Where-Object -FilterScript { $_.IsMandatory }).Name } - if($typeProperties.Name -contains 'id') + if ($typeProperties.Name -contains 'id') { - $primaryKey='Id' - $alternativeKey='DisplayName' + $primaryKey = 'Id' + $alternativeKey = 'DisplayName' } if ($null -ne $getKeyIdentifier ) { $getParameterString = [System.Text.StringBuilder]::New() - foreach($key in $getKeyIdentifier ) + foreach ($key in $getKeyIdentifier ) { - if($getKeyIdentifier.Count -gt 1) + if ($getKeyIdentifier.Count -gt 1) { - $getParameterString.append("```r`n") |out-null - $getParameterString.append(" ") |out-null + $getParameterString.append("```r`n") | Out-Null + $getParameterString.append(' ') | Out-Null } $keyValue = $key - if($key -eq "$($actualtype)Id") + if ($key -eq "$($actualtype)Id") { $keyValue = $primaryKey } - $getParameterString.append("-$key `$$keyValue ") |out-null + $getParameterString.append("-$key `$$keyValue ") | Out-Null } [String]$getKeyIdentifier = $getParameterString.ToString() } $getDefaultParameterSet = $getCmdlet.ParameterSets | Where-Object -FilterScript { $_.Name -eq 'List' } - $getListIdentifier =$getDefaultParameterSet.Parameters.Name + $getListIdentifier = $getDefaultParameterSet.Parameters.Name $getAlternativeFilterString = [System.Text.StringBuilder]::New() - if($getListIdentifier -contains 'Filter') + if ($getListIdentifier -contains 'Filter') { - $getAlternativeFilterString.appendline(" -Filter `"$alternativeKey eq '`$$alternativeKey'`" ``")|out-null - $getAlternativeFilterString.append(" -ErrorAction SilentlyContinue")|out-null + $getAlternativeFilterString.appendline(" -Filter `"$alternativeKey eq '`$$alternativeKey'`" ``") | Out-Null + $getAlternativeFilterString.append(' -ErrorAction SilentlyContinue') | Out-Null } else { - $getAlternativeFilterString.appendline(" -ErrorAction SilentlyContinue | Where-Object ``")|out-null - $getAlternativeFilterString.appendline(" -FilterScript { ``")|out-null - $getAlternativeFilterString.appendline(" `$_.$alternativeKey -eq `"`$(`$$alternativeKey)`" ``")|out-null - $getAlternativeFilterString.append(" }")|out-null + $getAlternativeFilterString.appendline(" -ErrorAction SilentlyContinue | Where-Object ``") | Out-Null + $getAlternativeFilterString.appendline(" -FilterScript { ``") | Out-Null + $getAlternativeFilterString.appendline(" `$_.$alternativeKey -eq `"`$(`$$alternativeKey)`" ``") | Out-Null + $getAlternativeFilterString.append(' }') | Out-Null } Write-TokenReplacement -Token '' -Value $getAlternativeFilterString.ToString() -FilePath $moduleFilePath @@ -342,19 +342,19 @@ function New-M365DSCResource if ($null -ne $newKeyIdentifier ) { $newParameterString = [System.Text.StringBuilder]::New() - foreach($key in $newKeyIdentifier ) + foreach ($key in $newKeyIdentifier ) { - if($newKeyIdentifier.Count -gt 1) + if ($newKeyIdentifier.Count -gt 1) { - $newParameterString.append("```r`n") |out-null - $newParameterString.append(" ") |out-null + $newParameterString.append("```r`n") | Out-Null + $newParameterString.append(' ') | Out-Null } $keyValue = $key - if($key -eq 'BodyParameter') + if ($key -eq 'BodyParameter') { $keyValue = 'CreateParameters' } - $newParameterString.append("-$key `$$keyValue ") |out-null + $newParameterString.append("-$key `$$keyValue ") | Out-Null } [String]$newKeyIdentifier = $newParameterString.ToString() } @@ -367,21 +367,21 @@ function New-M365DSCResource Write-TokenReplacement -Token '' -Value $alternativeKey -FilePath $moduleFilePath $exportGetCommand = [System.Text.StringBuilder]::New() - $exportGetCommand.AppendLine(" [array]`$getValue = Get-$CmdLetNoun ``") |out-null - if ($getDefaultParameterSet.Parameters.Name -contains "All") + $exportGetCommand.AppendLine(" [array]`$getValue = Get-$CmdLetNoun ``") | Out-Null + if ($getDefaultParameterSet.Parameters.Name -contains 'All') { - $exportGetCommand.AppendLine(" -All ``")|out-null + $exportGetCommand.AppendLine(" -All ``") | Out-Null } if ($isAdditionalProperty) { - $exportGetCommand.AppendLine(" -ErrorAction Stop | Where-Object ``")|out-null - $exportGetCommand.AppendLine(" -FilterScript { ``")|out-null - $exportGetCommand.AppendLine(" `$_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.$($selectedODataType)' ``")|out-null - $exportGetCommand.AppendLine(" }")|out-null + $exportGetCommand.AppendLine(" -ErrorAction Stop | Where-Object ``") | Out-Null + $exportGetCommand.AppendLine(" -FilterScript { ``") | Out-Null + $exportGetCommand.AppendLine(" `$_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.$($selectedODataType)' ``") | Out-Null + $exportGetCommand.AppendLine(' }') | Out-Null } else { - $exportGetCommand.AppendLine(" -ErrorAction Stop")|out-null + $exportGetCommand.AppendLine(' -ErrorAction Stop') | Out-Null } Write-TokenReplacement -Token '' -Value $exportGetCommand.ToString() -FilePath $moduleFilePath @@ -390,11 +390,11 @@ function New-M365DSCResource Write-TokenReplacement -Token '<#ConvertComplexToString#>' -Value $hashtableResults.ConvertToString -FilePath $moduleFilePath Write-TokenReplacement -Token '<#ConvertComplexToVariable#>' -Value $hashtableResults.ConvertToVariable -FilePath $moduleFilePath - $updateVerb='Update' - $updateCmdlet=Find-MgGraphCommand -Command "$updateVerb-$CmdLetNoun" -ApiVersion $ApiVersion -errorAction SilentlyContinue - if($null -eq $updateCmdlet) + $updateVerb = 'Update' + $updateCmdlet = Find-MgGraphCommand -Command "$updateVerb-$CmdLetNoun" -ApiVersion $ApiVersion -ErrorAction SilentlyContinue + if ($null -eq $updateCmdlet) { - $updateVerb='Set' + $updateVerb = 'Set' } $updateCmdlet = Get-Command -Name "$updateVerb-$CmdLetNoun" $updateDefaultParameterSet = $updateCmdlet.ParameterSets | Where-Object -FilterScript { $_.Name -eq "$updateVerb" } @@ -403,30 +403,30 @@ function New-M365DSCResource if ($null -ne $updateKeyIdentifier ) { $updateParameterString = [System.Text.StringBuilder]::New() - foreach($key in $updateKeyIdentifier ) + foreach ($key in $updateKeyIdentifier ) { - if($updateKeyIdentifier.Count -gt 1) + if ($updateKeyIdentifier.Count -gt 1) { - $updateParameterString.append("```r`n") |out-null - $updateParameterString.append(" ") |out-null + $updateParameterString.append("```r`n") | Out-Null + $updateParameterString.append(' ') | Out-Null } $keyValue = $key - if($key -eq 'BodyParameter') + if ($key -eq 'BodyParameter') { $keyValue = 'UpdateParameters' } - if($key -eq "$($actualtype)Id") + if ($key -eq "$($actualtype)Id") { - $keyValue = 'currentInstance.'+$primaryKey + $keyValue = 'currentInstance.' + $primaryKey } - $updateParameterString.append("-$key `$$keyValue ") |out-null + $updateParameterString.append("-$key `$$keyValue ") | Out-Null } [String]$updateKeyIdentifier = $updateParameterString.ToString() } - $odataType=$null - if($isAdditionalProperty) + $odataType = $null + if ($isAdditionalProperty) { - $odataType=" `$UpdateParameters.Add(`"@odata.type`", `"#microsoft.graph.$SelectedODataType`")`r`n" + $odataType = " `$UpdateParameters.Add(`"@odata.type`", `"#microsoft.graph.$SelectedODataType`")`r`n" } Write-TokenReplacement -Token '' -Value "$odataType" -FilePath $moduleFilePath Write-TokenReplacement -Token '' -Value "$updateVerb-$CmdLetNoun" -FilePath $moduleFilePath @@ -439,19 +439,19 @@ function New-M365DSCResource if ($null -ne $removeKeyIdentifier ) { $removeParameterString = [System.Text.StringBuilder]::New() - foreach($key in $removeKeyIdentifier ) + foreach ($key in $removeKeyIdentifier ) { - if($removeKeyIdentifier.Count -gt 1) + if ($removeKeyIdentifier.Count -gt 1) { - $removeParameterString.append("```r`n") |out-null - $removeParameterString.append(" ") |out-null + $removeParameterString.append("```r`n") | Out-Null + $removeParameterString.append(' ') | Out-Null } $keyValue = $key - if($removeKeyIdentifier.Count -eq 1) + if ($removeKeyIdentifier.Count -eq 1) { - $keyValue='currentInstance.'+$primaryKey + $keyValue = 'currentInstance.' + $primaryKey } - $removeParameterString.append("-$key `$$keyValue ") |out-null + $removeParameterString.append("-$key `$$keyValue ") | Out-Null } [String]$removeKeyIdentifier = $removeParameterString.ToString() } @@ -637,11 +637,11 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments Write-TokenReplacement -Token '' -Value $ResourceName -FilePath $schemaFilePath Write-TokenReplacement -Token '' -Value $schemaProperties -FilePath $schemaFilePath - $resourcePermissions = (get-M365DSCResourcePermission ` - -Workload $Workload ` - -CmdLetNoun $CmdLetNoun ` - -ApiVersion $ApiVersion ` - -UpdateVerb $updateVerb).permissions | ConvertTo-Json -Depth 20 + $resourcePermissions = (Get-M365DSCResourcePermission ` + -Workload $Workload ` + -CmdLetNoun $CmdLetNoun ` + -ApiVersion $ApiVersion ` + -UpdateVerb $updateVerb).permissions | ConvertTo-Json -Depth 20 $resourcePermissions = ' ' + $resourcePermissions Write-TokenReplacement -Token '' -Value $ResourceName -FilePath $settingsFilePath Write-TokenReplacement -Token '' -Value $resourceDescription -FilePath $settingsFilePath @@ -662,13 +662,13 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments else { $ParametersToFilterOut = @('Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'InformationAction', 'ErrorVariable', 'WarningVariable', 'InformationVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable', 'WhatIf', 'Confirm') - $cmdlet = Get-Command ($cmdletVerb + "-" + $cmdletNoun) + $cmdlet = Get-Command ($cmdletVerb + '-' + $cmdletNoun) - $defaultParameterSetProperties = $cmdlet.ParameterSets | Where-Object -FilterScript {$_.IsDefault} - $properties = $defaultParameterSetProperties.Parameters | Where-Object -FilterScript {-not $ParametersToFilterOut.Contains($_.Name) -and -not $_.Name.StartsWith('MsftInternal')} + $defaultParameterSetProperties = $cmdlet.ParameterSets | Where-Object -FilterScript { $_.IsDefault } + $properties = $defaultParameterSetProperties.Parameters | Where-Object -FilterScript { -not $ParametersToFilterOut.Contains($_.Name) -and -not $_.Name.StartsWith('MsftInternal') } #region Get longuest parametername - $longuestParameterName = ("CertificateThumbprint").Length + $longuestParameterName = ('CertificateThumbprint').Length foreach ($property in $properties) { if ($property.Name.Length -gt $longuestParameterName) @@ -688,13 +688,13 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments foreach ($property in $properties) { $propertyTypeMOF = $property.ParameterType.Name - switch($property.ParameterType.Name) + switch ($property.ParameterType.Name) { - "Int64" + 'Int64' { $propertyTypeMOF = 'UInt64' } - "Int32" + 'Int32' { $propertyTypeMOF = 'UInt32' } @@ -710,16 +710,16 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments } else { - $paramContent.AppendLine(" [Parameter()]") | Out-Null + $paramContent.AppendLine(' [Parameter()]') | Out-Null $mofSchemaContent.AppendLine(" [Write, Description(`"$($property.Description)`")] $propertyTypeMOF $($property.Name);") | Out-Null } $fakeValues.Add($property.Name, (Get-M365DSCDRGFakeValueForParameter -ParameterType $property.ParameterType.Name)) - $spacingRequired = " " + $spacingRequired = ' ' for ($i = 0; $i -lt ($longuestParameterName - $property.Name.Length); $i++) { - $spacingRequired += " " + $spacingRequired += ' ' } $returnContent.AppendLine(" $($property.Name)$spacingRequired= `$instance.$($property.Name)") | Out-Null @@ -729,30 +729,30 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments } # Ensure - $spacingRequired = " " - for ($i = 0; $i -lt ($longuestParameterName - ("Ensure").Length); $i++) + $spacingRequired = ' ' + for ($i = 0; $i -lt ($longuestParameterName - ('Ensure').Length); $i++) { - $spacingRequired += " " + $spacingRequired += ' ' } $returnContent.AppendLine(" Ensure$spacingRequired= 'Present'") | Out-Null - $paramContent.AppendLine(" [Parameter()]") | Out-Null + $paramContent.AppendLine(' [Parameter()]') | Out-Null $paramContent.AppendLine(" [ValidateSet('Present', 'Absent')]") | Out-Null - $paramContent.AppendLine(" [System.String]") | Out-Null + $paramContent.AppendLine(' [System.String]') | Out-Null $paramContent.AppendLine(" `$Ensure,`r`n") | Out-Null $mofSchemaContent.AppendLine(" [Write, Description(`"Present ensures the instance exists, absent ensures it is removed.`"), ValueMap{`"Present`",`"Absent`"}, Values{`"Present`",`"Absent`"}] string Ensure;") | Out-Null # Credential - $spacingRequired = " " - for ($i = 0; $i -lt ($longuestParameterName - ("Credential").Length); $i++) + $spacingRequired = ' ' + for ($i = 0; $i -lt ($longuestParameterName - ('Credential').Length); $i++) { - $spacingRequired += " " + $spacingRequired += ' ' } $returnContent.AppendLine(" Credential$spacingRequired= `$Credential") | Out-Null - $paramContent.AppendLine(" [Parameter()]") | Out-Null - $paramContent.AppendLine(" [System.Management.Automation.PSCredential]") | Out-Null + $paramContent.AppendLine(' [Parameter()]') | Out-Null + $paramContent.AppendLine(' [System.Management.Automation.PSCredential]') | Out-Null $paramContent.AppendLine(" `$Credential,`r`n") | Out-Null $mofSchemaContent.AppendLine(" [Write, Description(`"Credentials of the workload's Admin`"), EmbeddedInstance(`"MSFT_Credential`")] string Credential;") | Out-Null @@ -760,15 +760,15 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments if ($Workload -ne 'SecurityAndCompliance') { # Application Id - $spacingRequired = " " - for ($i = 0; $i -lt ($longuestParameterName - ("ApplicationId").Length); $i++) + $spacingRequired = ' ' + for ($i = 0; $i -lt ($longuestParameterName - ('ApplicationId').Length); $i++) { - $spacingRequired += " " + $spacingRequired += ' ' } $returnContent.AppendLine(" ApplicationId$spacingRequired= `$ApplicationId") | Out-Null - $paramContent.AppendLine(" [Parameter()]") | Out-Null - $paramContent.AppendLine(" [System.String]") | Out-Null + $paramContent.AppendLine(' [Parameter()]') | Out-Null + $paramContent.AppendLine(' [System.String]') | Out-Null $paramContent.AppendLine(" `$ApplicationId,`r`n") | Out-Null $exportAuthContent.AppendLine(" ApplicationId = `$ApplicationId") | Out-Null @@ -776,15 +776,15 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments $mofSchemaContent.AppendLine(" [Write, Description(`"Id of the Azure Active Directory application to authenticate with.`")] String ApplicationId;") | Out-Null # Tenant Id - $spacingRequired = " " - for ($i = 0; $i -lt ($longuestParameterName - ("TenantId").Length); $i++) + $spacingRequired = ' ' + for ($i = 0; $i -lt ($longuestParameterName - ('TenantId').Length); $i++) { - $spacingRequired += " " + $spacingRequired += ' ' } $returnContent.AppendLine(" TenantId$spacingRequired= `$TenantId") | Out-Null - $paramContent.AppendLine(" [Parameter()]") | Out-Null - $paramContent.AppendLine(" [System.String]") | Out-Null + $paramContent.AppendLine(' [Parameter()]') | Out-Null + $paramContent.AppendLine(' [System.String]') | Out-Null $paramContent.AppendLine(" `$TenantId,`r`n") | Out-Null $exportAuthContent.AppendLine(" TenantId = `$TenantId") | Out-Null @@ -792,15 +792,15 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments $mofSchemaContent.AppendLine(" [Write, Description(`"Id of the Azure Active Directory tenant used for authentication.`")] String TenantId;") | Out-Null # CertificateThumbprint - $spacingRequired = " " - for ($i = 0; $i -lt ($longuestParameterName - ("CertificateThumbprint").Length); $i++) + $spacingRequired = ' ' + for ($i = 0; $i -lt ($longuestParameterName - ('CertificateThumbprint').Length); $i++) { - $spacingRequired += " " + $spacingRequired += ' ' } $returnContent.AppendLine(" CertificateThumbprint$spacingRequired= `$CertificateThumbprint") | Out-Null - $paramContent.AppendLine(" [Parameter()]") | Out-Null - $paramContent.AppendLine(" [System.String]") | Out-Null + $paramContent.AppendLine(' [Parameter()]') | Out-Null + $paramContent.AppendLine(' [System.String]') | Out-Null $paramContent.AppendLine(" `$CertificateThumbprint,`r`n") | Out-Null $exportAuthContent.AppendLine(" CertificateThumbprint = `$CertificateThumbprint") | Out-Null @@ -810,14 +810,14 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments if ($workload -ne 'MicrosoftTeams') { # ApplicationSecret - $spacingRequired = " " - for ($i = 0; $i -lt ($longuestParameterName - ("ApplicationSecret").Length); $i++) + $spacingRequired = ' ' + for ($i = 0; $i -lt ($longuestParameterName - ('ApplicationSecret').Length); $i++) { - $spacingRequired += " " + $spacingRequired += ' ' } $returnContent.AppendLine(" ApplicationSecret$spacingRequired= `$ApplicationSecret") | Out-Null - $paramContent.AppendLine(" [Parameter()]") | Out-Null - $paramContent.AppendLine(" [System.Management.Automation.PSCredential]") | Out-Null + $paramContent.AppendLine(' [Parameter()]') | Out-Null + $paramContent.AppendLine(' [System.Management.Automation.PSCredential]') | Out-Null $paramContent.AppendLine(" `$ApplicationSecret,`r`n") | Out-Null $exportAuthContent.AppendLine(" ApplicationSecret = `$ApplicationSecret") | Out-Null @@ -827,7 +827,7 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments } $parameterBlock = $paramContent.ToString() - $parameterBlock = $parameterBlock.Remove($parameterBlock.Length -5, 5) # remove trailing comma + $parameterBlock = $parameterBlock.Remove($parameterBlock.Length - 5, 5) # remove trailing comma Write-TokenReplacement -Token '' -Value $parameterBlock -FilePath $moduleFilePath Write-TokenReplacement -Token '' -Value $exportAuthContent.ToString() -FilePath $moduleFilePath Write-TokenReplacement -Token '' -Value $returnContent.ToString() -FilePath $moduleFilePath @@ -839,7 +839,7 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments #region GetKeyIdentifier $cmdlet = Get-Command $('Get-' + $cmdletNoun) - $defaultParameterSetProperties = $cmdlet.ParameterSets | Where-Object -FilterScript {$_.IsDefault} + $defaultParameterSetProperties = $cmdlet.ParameterSets | Where-Object -FilterScript { $_.IsDefault } Write-TokenReplacement -Token '' -Value $defaultParameterSetProperties[0].Name -FilePath $moduleFilePath #endregion @@ -873,59 +873,59 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments for ($i = 0; $i -lt ($longuestParameterName - $key.Length); $i++) { - $spacingRequired += " " + $spacingRequired += ' ' } $propertyValue = $null $propertyDriftValue = $null switch ($fakeValues.$key.GetType().Name) { - "String" + 'String' { $propertyValue = "`"$($fakeValues.$key)`"" if ($key -ne $primaryKey) { $propertyDriftValue = "`"" + (Get-M365DSCDRGFakeValueForParameter -ParameterType 'String' ` - -Drift:$true) + "`"" + -Drift:$true) + "`"" } else { $propertyDriftValue = $propertyValue } } - "Boolean" + 'Boolean' { $propertyValue = "`$$($fakeValues.$key)" if ($key -ne $primaryKey) { $propertyDriftValue = "`$" + (Get-M365DSCDRGFakeValueForParameter -ParameterType 'Boolean' ` - -Drift:$true) + -Drift:$true) } else { $propertyDriftValue = $propertyValue } } - "Int32" + 'Int32' { $propertyValue = $fakeValues.$key.ToString() if ($key -ne $primaryKey) { $propertyDriftValue = (Get-M365DSCDRGFakeValueForParameter -ParameterType 'Int32' ` - -Drift:$true) + -Drift:$true) } else { $propertyDriftValue = $propertyValue } } - "Int64" + 'Int64' { $propertyValue = $fakeValues.$key.ToString() if ($key -ne $primaryKey) { $propertyDriftValue = (Get-M365DSCDRGFakeValueForParameter -ParameterType 'Int64' ` - -Drift:$true) + -Drift:$true) } else { @@ -959,8 +959,8 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments $exportContent = Get-Content $exportedFilePath -Raw $start = $exportContent.IndexOf("`r`n $ResourceName ") $end = $exportContent.IndexOf("`r`n }", $start) - $start = $exportContent.IndexOf("{", $start) + 1 - $exampleContent = $exportContent.Substring($start, $end-$start) + $start = $exportContent.IndexOf('{', $start) + 1 + $exampleContent = $exportContent.Substring($start, $end - $start) $exampleFileFullPath = "$ExampleFilePath\$ResourceName\1-$ResourceName-Example.psm1" $folderPath = "$ExampleFilePath\$ResourceName" @@ -1074,14 +1074,14 @@ function Get-CmdletDefinition if ($ApiVersion -eq 'v1.0') { - $Uri='https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/clean_v10_metadata/cleanMetadataWithDescriptionsv1.0.xml' + $Uri = 'https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/clean_v10_metadata/cleanMetadataWithDescriptionsv1.0.xml' } else { - $Uri='https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/clean_beta_metadata/cleanMetadataWithDescriptionsbeta.xml' + $Uri = 'https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/clean_beta_metadata/cleanMetadataWithDescriptionsbeta.xml' } - $metadata=(Invoke-RestMethod -Uri $Uri).edmx.DataServices.schema + $metadata = (Invoke-RestMethod -Uri $Uri).edmx.DataServices.schema return $metadata } @@ -1098,115 +1098,115 @@ function Get-TypeProperties $Entity ) - $namespace=$CmdletDefinition|Where-Object -FilterScript {$_.EntityType.Name -contains $Entity} - if($null -eq $namespace) + $namespace = $CmdletDefinition | Where-Object -FilterScript { $_.EntityType.Name -contains $Entity } + if ($null -eq $namespace) { - $namespace=$CmdletDefinition|Where-Object -FilterScript {$_.ComplexType.Name -contains $Entity} + $namespace = $CmdletDefinition | Where-Object -FilterScript { $_.ComplexType.Name -contains $Entity } } - $properties=@() - $baseType=$Entity + $properties = @() + $baseType = $Entity #Get all properties for the entity or complex do { - $isComplex=$false - $entityType=$namespace.EntityType|Where-Object -FilterScript{$_.Name -eq $baseType} - if($null -eq $entityType) + $isComplex = $false + $entityType = $namespace.EntityType | Where-Object -FilterScript { $_.Name -eq $baseType } + if ($null -eq $entityType) { - $isComplex=$true - $entityType=$namespace.ComplexType|Where-Object -FilterScript{$_.Name -eq $baseType} + $isComplex = $true + $entityType = $namespace.ComplexType | Where-Object -FilterScript { $_.Name -eq $baseType } } - if($null -ne $entityType.Property) + if ($null -ne $entityType.Property) { - $properties+=$entityType.Property + $properties += $entityType.Property } - elseif($isComplex) + elseif ($isComplex) { - $abstractType=$namespace.ComplexType|Where-Object -FilterScript {$_.BaseType -eq "graph.$baseType"} - $properties+=$abstractType.Property + $abstractType = $namespace.ComplexType | Where-Object -FilterScript { $_.BaseType -eq "graph.$baseType" } + $properties += $abstractType.Property $object = New-Object -TypeName PSCustomObject Add-Member -InputObject $object -MemberType NoteProperty -Name 'Name' -Value '@odata.type' Add-Member -InputObject $object -MemberType NoteProperty -Name 'Members' -Value $abstractType.Name Add-Member -InputObject $object -MemberType NoteProperty -Name 'type' -Value 'Custom.Enum' Add-Member -InputObject $object -MemberType NoteProperty -Name 'Description' -Value 'The type of the entity.' - $properties+=$object + $properties += $object } - $baseType=$null - if(-not [String]::IsNullOrEmpty($entityType.BaseType)) + $baseType = $null + if (-not [String]::IsNullOrEmpty($entityType.BaseType)) { - $baseType=$entityType.BaseType.replace('graph.','') + $baseType = $entityType.BaseType.replace('graph.', '') } } - while($null -ne $baseType) + while ($null -ne $baseType) # Enrich properties - foreach($property in $properties) + foreach ($property in $properties) { - $derivedType=$property.Type + $derivedType = $property.Type #Array - $isArray=$false - $isEnum=$false - if($derivedType -eq 'Custom.Enum') + $isArray = $false + $isEnum = $false + if ($derivedType -eq 'Custom.Enum') { - $isEnum=$true + $isEnum = $true } - $isComplex=$false + $isComplex = $false - if($derivedType -like "Collection(*)") + if ($derivedType -like 'Collection(*)') { - $isArray=$true - $derivedType=$derivedType.Replace('Collection(','').replace(')','') + $isArray = $true + $derivedType = $derivedType.Replace('Collection(', '').replace(')', '') } - if($null -eq $property.isArray) + if ($null -eq $property.isArray) { Add-Member -InputObject $property -MemberType NoteProperty -Name 'isArray' -Value $isArray } #DerivedType - if($derivedType -like ('graph.*')) + if ($derivedType -like ('graph.*')) { - $derivedType=$derivedType.Replace('graph.','') + $derivedType = $derivedType.Replace('graph.', '') #Enum - if($derivedType -in $namespace.EnumType.Name) + if ($derivedType -in $namespace.EnumType.Name) { - $isEnum=$true - $enumType=$namespace.EnumType | where-Object -FilterScript {$_.Name -eq $derivedType} + $isEnum = $true + $enumType = $namespace.EnumType | Where-Object -FilterScript { $_.Name -eq $derivedType } Add-Member -InputObject $property -MemberType NoteProperty -Name 'Members' -Value $enumType.Member.Name } #Complex - if($derivedType -in $namespace.ComplexType.Name) + if ($derivedType -in $namespace.ComplexType.Name) { - $isComplex=$true + $isComplex = $true $nestedProperties = Get-TypeProperties -CmdletDefinition $CmdletDefinition -Entity $derivedType Add-Member -InputObject $property -MemberType NoteProperty -Name 'Properties' -Value $nestedProperties } } - if($derivedType -like ('Edm.*')) + if ($derivedType -like ('Edm.*')) { - $derivedType=$derivedType.Replace('Edm','System') + $derivedType = $derivedType.Replace('Edm', 'System') } - if($isEnum) + if ($isEnum) { - $derivedType='System.String' + $derivedType = 'System.String' } - if($null -eq $property.derivedType) + if ($null -eq $property.derivedType) { - Add-Member -InputObject $property -MemberType NoteProperty -Name 'derivedType' -Value $derivedType + Add-Member -InputObject $property -MemberType NoteProperty -Name 'derivedType' -Value $derivedType } - if($null -eq $property.isComplexType) + if ($null -eq $property.isComplexType) { Add-Member -InputObject $property -MemberType NoteProperty -Name 'isComplexType' -Value $isComplex } - if($null -eq $property.isEnumType) + if ($null -eq $property.isEnumType) { Add-Member -InputObject $property -MemberType NoteProperty -Name 'isEnumType' -Value $isEnum } #Description - if(-Not [String]::IsNullOrEmpty($property.Annotation.String) -and $null -eq $property.Description) + if (-Not [String]::IsNullOrEmpty($property.Annotation.String) -and $null -eq $property.Description) { Add-Member -InputObject $property -MemberType NoteProperty -Name 'Description' -Value $property.Annotation.String } @@ -1252,14 +1252,14 @@ function Get-ParameterBlockInformation $parameterName = "$($parameterNameFirstLetter)$($parameterNameCamelCaseString)" $myParam = @{ - IsMandatory = $isMandatory - Attribute = $parameterAttribute - Type = $property.DerivedType - Name = $parameterName - Description = $property.Description - IsArray = $property.IsArray - IsComplexType = $property.IsComplexType - IsEnumType = $property.IsEnumType + IsMandatory = $isMandatory + Attribute = $parameterAttribute + Type = $property.DerivedType + Name = $parameterName + Description = $property.Description + IsArray = $property.IsArray + IsComplexType = $property.IsComplexType + IsEnumType = $property.IsEnumType } if ($property.IsEnumType) { @@ -1270,7 +1270,7 @@ function Get-ParameterBlockInformation $myParam.add('Properties', $property.Properties) } - $parameterBlock+=$myParam + $parameterBlock += $myParam } return $parameterBlock } @@ -1433,7 +1433,7 @@ function Get-M365DSCDRGFakeValueForParameter switch ($ParameterType) { - "String" + 'String' { if ($ValidateSetValues -ne $null -and $ValidateSetValues.Length -gt 0) { @@ -1443,12 +1443,12 @@ function Get-M365DSCDRGFakeValueForParameter { if ($Drift) { - return "FakeStringValueDrift #Drift" + return 'FakeStringValueDrift #Drift' } - return "FakeStringValue" + return 'FakeStringValue' } } - "Boolean" + 'Boolean' { if ($Drift) { @@ -1456,7 +1456,7 @@ function Get-M365DSCDRGFakeValueForParameter } return $true } - "Int32" + 'Int32' { if ($Drift) { @@ -1464,7 +1464,7 @@ function Get-M365DSCDRGFakeValueForParameter } return 3 } - "Int64" + 'Int64' { if ($Drift) { @@ -1764,15 +1764,15 @@ function Get-M365DSCResourcePermission [Parameter()] [System.String] - $UpdateVerb='Update', + $UpdateVerb = 'Update', [Parameter()] - [ValidateSet('v1.0','beta')] + [ValidateSet('v1.0', 'beta')] [System.String] - $APIVersion='v1.0' + $APIVersion = 'v1.0' ) - $readPermissionsNames = (Find-MgGraphCommand -Command "Get-$CmdLetNoun" -ApiVersion $ApiVersion| Select-Object -First 1 -ExpandProperty Permissions).Name + $readPermissionsNames = (Find-MgGraphCommand -Command "Get-$CmdLetNoun" -ApiVersion $ApiVersion | Select-Object -First 1 -ExpandProperty Permissions).Name $updatePermissionsNames = (Find-MgGraphCommand -Command "$UpdateVerb-$CmdLetNoun" -ApiVersion $ApiVersion | Select-Object -First 1 -ExpandProperty Permissions).Name switch ($Workload) @@ -1898,7 +1898,7 @@ function Get-M365DSCDRGCimInstancesSchemaStringContent $propertySet = ", ValueMap{$mySet}, Values{$mySet}" } - if($property.IsComplexType) + if ($property.IsComplexType) { $stringResult += " [Write, Description(`"$($property.Description)`"), EmbeddedInstance(`"MSFT_$Workload$($cimInstance.Name)`")] String $($property.Name)" } @@ -2039,10 +2039,10 @@ function New-M365DSCModuleFile [Parameter()] [System.String] - $Workload = "MicrosoftGraph" + $Workload = 'MicrosoftGraph' ) $filePath = "$Path\MSFT_$ResourceName\MSFT_$($ResourceName).psm1" - if ($workload -in @('MicrosoftGraph','Intune')) + if ($workload -in @('MicrosoftGraph', 'Intune')) { Copy-Item -Path .\Module.Template.psm1 -Destination $filePath -Force } @@ -2131,7 +2131,7 @@ function New-M365DSCSchemaFile $Workload = 'MicrosoftGraph' ) $filePath = "$Path\MSFT_$ResourceName\MSFT_$($ResourceName).schema.mof" - if ($Workload -in @('MicrosoftGraph','Intune')) + if ($Workload -in @('MicrosoftGraph', 'Intune')) { Copy-Item -Path .\Schema.Template.mof -Destination $filePath } @@ -2281,7 +2281,7 @@ function New-M365HashTableMapping } else { - $SkipAdditionalPropertiesParameters =@( + $SkipAdditionalPropertiesParameters = @( 'Description' 'displayName' 'Id' @@ -2309,7 +2309,7 @@ function New-M365HashTableMapping } } - $defaultKeys=@( + $defaultKeys = @( 'Ensure' 'Credential' 'ApplicationId' @@ -2318,14 +2318,14 @@ function New-M365HashTableMapping 'CertificateThumbprint' 'Managedidentity' ) - foreach($key in $defaultKeys) + foreach ($key in $defaultKeys) { $keyValue = "`$$key" - if($key -eq 'Ensure') + if ($key -eq 'Ensure') { $keyValue = "'Present'" } - if($key -eq 'ManagedIdentity') + if ($key -eq 'ManagedIdentity') { $keyValue = '$ManagedIdentity.IsPresent' } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsFilesPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsFilesPolicy.Tests.ps1 index 62e6d3b8b0..d3402d96a5 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsFilesPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsFilesPolicy.Tests.ps1 @@ -2,27 +2,27 @@ param( ) $M365DSCTestFolder = Join-Path -Path $PSScriptRoot ` - -ChildPath "..\..\Unit" ` - -Resolve + -ChildPath '..\..\Unit' ` + -Resolve $CmdletModule = (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\Stubs\Microsoft365.psm1" ` - -Resolve) + -ChildPath '\Stubs\Microsoft365.psm1' ` + -Resolve) $GenericStubPath = (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\Stubs\Generic.psm1" ` - -Resolve) + -ChildPath '\Stubs\Generic.psm1' ` + -Resolve) Import-Module -Name (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\UnitTestHelper.psm1" ` + -ChildPath '\UnitTestHelper.psm1' ` -Resolve) $Global:DscHelper = New-M365DscUnitTestHelper -StubModule $CmdletModule ` - -DscResource "TeamsFilesPolicy" -GenericStubModule $GenericStubPath + -DscResource 'TeamsFilesPolicy' -GenericStubModule $GenericStubPath Describe -Name $Global:DscHelper.DescribeHeader -Fixture { InModuleScope -ModuleName $Global:DscHelper.ModuleName -ScriptBlock { Invoke-Command -ScriptBlock $Global:DscHelper.InitializeScript -NoNewScope BeforeAll { - $secpasswd = ConvertTo-SecureString "f@kepassword1" -AsPlainText -Force - $Credential = New-Object System.Management.Automation.PSCredential ("tenantadmin@mydomain.com", $secpasswd) + $secpasswd = ConvertTo-SecureString 'f@kepassword1' -AsPlainText -Force + $Credential = New-Object System.Management.Automation.PSCredential ('tenantadmin@mydomain.com', $secpasswd) Mock -CommandName Confirm-M365DSCDependencies -MockWith { } @@ -43,25 +43,25 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } Mock -CommandName New-M365DSCConnection -MockWith { - return "Credential" + return 'Credential' } } # Test contexts - Context -Name "The TeamsFilesPolicy should exist but it DOES NOT" -Fixture { + Context -Name 'The TeamsFilesPolicy should exist but it DOES NOT' -Fixture { BeforeAll { $testParams = @{ - NativeFileEntryPoints = "FakeStringValue" - SPChannelFilesTab = "FakeStringValue" - Identity = "FakeStringValue" - Ensure = "Present" - Credential = $Credential; + NativeFileEntryPoints = 'Enabled' + SPChannelFilesTab = 'Enabled' + Identity = 'FakeStringValue' + Ensure = 'Present' + Credential = $Credential; } Mock -CommandName Get-CsTeamsFilesPolicy -MockWith { return $null } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Absent' } It 'Should return false from the Test method' { @@ -73,27 +73,27 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } } - Context -Name "The TeamsFilesPolicy exists but it SHOULD NOT" -Fixture { + Context -Name 'The TeamsFilesPolicy exists but it SHOULD NOT' -Fixture { BeforeAll { $testParams = @{ - NativeFileEntryPoints = "FakeStringValue" - SPChannelFilesTab = "FakeStringValue" - Identity = "FakeStringValue" - Ensure = "Absent" - Credential = $Credential; + NativeFileEntryPoints = 'Enabled' + SPChannelFilesTab = 'Enabled' + Identity = 'FakeStringValue' + Ensure = 'Absent' + Credential = $Credential; } Mock -CommandName Get-CsTeamsFilesPolicy -MockWith { return @{ - NativeFileEntryPoints = "FakeStringValue" - SPChannelFilesTab = "FakeStringValue" - Identity = "FakeStringValue" + NativeFileEntryPoints = 'Enabled' + SPChannelFilesTab = 'Enabled' + Identity = 'FakeStringValue' } } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Present' } @@ -106,21 +106,21 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Should -Invoke -CommandName Remove-CsTeamsFilesPolicy -Exactly 1 } } - Context -Name "The TeamsFilesPolicy Exists and Values are already in the desired state" -Fixture { + Context -Name 'The TeamsFilesPolicy Exists and Values are already in the desired state' -Fixture { BeforeAll { $testParams = @{ - NativeFileEntryPoints = "FakeStringValue" - SPChannelFilesTab = "FakeStringValue" - Identity = "FakeStringValue" - Ensure = "Present" - Credential = $Credential; + NativeFileEntryPoints = 'Enabled' + SPChannelFilesTab = 'Enabled' + Identity = 'FakeStringValue' + Ensure = 'Present' + Credential = $Credential; } Mock -CommandName Get-CsTeamsFilesPolicy -MockWith { return @{ - NativeFileEntryPoints = "FakeStringValue" - SPChannelFilesTab = "FakeStringValue" - Identity = "FakeStringValue" + NativeFileEntryPoints = 'Enabled' + SPChannelFilesTab = 'Enabled' + Identity = 'FakeStringValue' } } @@ -132,26 +132,26 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } } - Context -Name "The TeamsFilesPolicy exists and values are NOT in the desired state" -Fixture { + Context -Name 'The TeamsFilesPolicy exists and values are NOT in the desired state' -Fixture { BeforeAll { $testParams = @{ - NativeFileEntryPoints = "FakeStringValue" - SPChannelFilesTab = "FakeStringValue" - Identity = "FakeStringValue" - Ensure = "Present" + NativeFileEntryPoints = 'Enabled' + SPChannelFilesTab = 'Enabled' + Identity = 'FakeStringValue' + Ensure = 'Present' Credential = $Credential; } Mock -CommandName Get-CsTeamsFilesPolicy -MockWith { return @{ - NativeFileEntryPoints = "FakeStringValueDrift #Drift" - SPChannelFilesTab = "FakeStringValueDrift #Drift" - Identity = "FakeStringValue" + NativeFileEntryPoints = 'Disabled' + SPChannelFilesTab = 'Disabled' + Identity = 'FakeStringValue' } } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Present' } @@ -159,13 +159,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Test-TargetResource @testParams | Should -Be $false } - It "Should call the Set method" { + It 'Should call the Set method' { Set-TargetResource @testParams Should -Invoke -CommandName Set-CsTeamsFilesPolicy -Exactly 1 } } - Context -Name "ReverseDSC Tests" -Fixture { + Context -Name 'ReverseDSC Tests' -Fixture { BeforeAll { $Global:CurrentModeIsExport = $true $testParams = @{ @@ -174,14 +174,14 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Mock -CommandName Get-CsTeamsFilesPolicy -MockWith { return @{ - NativeFileEntryPoints = "FakeStringValue" - SPChannelFilesTab = "FakeStringValue" - Identity = "FakeStringValue" + NativeFileEntryPoints = 'Enabled' + SPChannelFilesTab = 'Enabled' + Identity = 'FakeStringValue' } } } - It "Should Reverse Engineer resource from the Export method" { + It 'Should Reverse Engineer resource from the Export method' { Export-TargetResource @testParams } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsIPPhonePolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsIPPhonePolicy.Tests.ps1 index c5f2840bf3..8bb68bdd37 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsIPPhonePolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsIPPhonePolicy.Tests.ps1 @@ -2,27 +2,27 @@ param( ) $M365DSCTestFolder = Join-Path -Path $PSScriptRoot ` - -ChildPath "..\..\Unit" ` - -Resolve + -ChildPath '..\..\Unit' ` + -Resolve $CmdletModule = (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\Stubs\Microsoft365.psm1" ` - -Resolve) + -ChildPath '\Stubs\Microsoft365.psm1' ` + -Resolve) $GenericStubPath = (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\Stubs\Generic.psm1" ` - -Resolve) + -ChildPath '\Stubs\Generic.psm1' ` + -Resolve) Import-Module -Name (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\UnitTestHelper.psm1" ` + -ChildPath '\UnitTestHelper.psm1' ` -Resolve) $Global:DscHelper = New-M365DscUnitTestHelper -StubModule $CmdletModule ` - -DscResource "TeamsIPPhonePolicy" -GenericStubModule $GenericStubPath + -DscResource 'TeamsIPPhonePolicy' -GenericStubModule $GenericStubPath Describe -Name $Global:DscHelper.DescribeHeader -Fixture { InModuleScope -ModuleName $Global:DscHelper.ModuleName -ScriptBlock { Invoke-Command -ScriptBlock $Global:DscHelper.InitializeScript -NoNewScope BeforeAll { - $secpasswd = ConvertTo-SecureString "f@kepassword1" -AsPlainText -Force - $Credential = New-Object System.Management.Automation.PSCredential ("tenantadmin@mydomain.com", $secpasswd) + $secpasswd = ConvertTo-SecureString 'f@kepassword1' -AsPlainText -Force + $Credential = New-Object System.Management.Automation.PSCredential ('tenantadmin@mydomain.com', $secpasswd) Mock -CommandName Confirm-M365DSCDependencies -MockWith { } @@ -43,30 +43,30 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } Mock -CommandName New-M365DSCConnection -MockWith { - return "Credential" + return 'Credential' } } # Test contexts - Context -Name "The TeamsIPPhonePolicy should exist but it DOES NOT" -Fixture { + Context -Name 'The TeamsIPPhonePolicy should exist but it DOES NOT' -Fixture { BeforeAll { $testParams = @{ AllowHotDesking = $True - AllowBetterTogether = "FakeStringValue" - SearchOnCommonAreaPhoneMode = "FakeStringValue" - Description = "FakeStringValue" + AllowBetterTogether = 'Enabled' + SearchOnCommonAreaPhoneMode = 'Enabled' + Description = 'FakeStringValue' HotDeskingIdleTimeoutInMinutes = 3 - SignInMode = "FakeStringValue" - Identity = "FakeStringValue" - AllowHomeScreen = "FakeStringValue" - Ensure = "Present" - Credential = $Credential; + SignInMode = 'UserSignIn' + Identity = 'FakeStringValue' + AllowHomeScreen = 'Enabled' + Ensure = 'Present' + Credential = $Credential; } Mock -CommandName Get-CsTeamsIPPhonePolicy -MockWith { return $null } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Absent' } It 'Should return false from the Test method' { @@ -78,37 +78,36 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } } - Context -Name "The TeamsIPPhonePolicy exists but it SHOULD NOT" -Fixture { + Context -Name 'The TeamsIPPhonePolicy exists but it SHOULD NOT' -Fixture { BeforeAll { $testParams = @{ AllowHotDesking = $True - AllowBetterTogether = "FakeStringValue" - SearchOnCommonAreaPhoneMode = "FakeStringValue" - Description = "FakeStringValue" + AllowBetterTogether = 'Enabled' + SearchOnCommonAreaPhoneMode = 'Enabled' + Description = 'FakeStringValue' HotDeskingIdleTimeoutInMinutes = 3 - SignInMode = "FakeStringValue" - Identity = "FakeStringValue" - AllowHomeScreen = "FakeStringValue" - Ensure = "Absent" - Credential = $Credential; + SignInMode = 'UserSignIn' + Identity = 'FakeStringValue' + AllowHomeScreen = 'Enabled' + Ensure = 'Absent' + Credential = $Credential; } Mock -CommandName Get-CsTeamsIPPhonePolicy -MockWith { return @{ - AllowHotDesking = $True - AllowBetterTogether = "FakeStringValue" - SearchOnCommonAreaPhoneMode = "FakeStringValue" - Description = "FakeStringValue" - HotDeskingIdleTimeoutInMinutes = 3 - SignInMode = "FakeStringValue" - Identity = "FakeStringValue" - AllowHomeScreen = "FakeStringValue" - + AllowHotDesking = $True + AllowBetterTogether = 'Enabled' + SearchOnCommonAreaPhoneMode = 'Enabled' + Description = 'FakeStringValue' + HotDeskingIdleTimeoutInMinutes = 3 + SignInMode = 'UserSignIn' + Identity = 'FakeStringValue' + AllowHomeScreen = 'Enabled' } } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Present' } @@ -121,72 +120,70 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Should -Invoke -CommandName Remove-CsTeamsIPPhonePolicy -Exactly 1 } } - Context -Name "The TeamsIPPhonePolicy Exists and Values are already in the desired state" -Fixture { + Context -Name 'The TeamsIPPhonePolicy Exists and Values are already in the desired state' -Fixture { BeforeAll { $testParams = @{ AllowHotDesking = $True - AllowBetterTogether = "FakeStringValue" - SearchOnCommonAreaPhoneMode = "FakeStringValue" - Description = "FakeStringValue" + AllowBetterTogether = 'Enabled' + SearchOnCommonAreaPhoneMode = 'Enabled' + Description = 'FakeStringValue' HotDeskingIdleTimeoutInMinutes = 3 - SignInMode = "FakeStringValue" - Identity = "FakeStringValue" - AllowHomeScreen = "FakeStringValue" - Ensure = "Present" - Credential = $Credential; + SignInMode = 'UserSignIn' + Identity = 'FakeStringValue' + AllowHomeScreen = 'Enabled' + Ensure = 'Present' + Credential = $Credential; } Mock -CommandName Get-CsTeamsIPPhonePolicy -MockWith { return @{ - AllowHotDesking = $True - AllowBetterTogether = "FakeStringValue" - SearchOnCommonAreaPhoneMode = "FakeStringValue" - Description = "FakeStringValue" - HotDeskingIdleTimeoutInMinutes = 3 - SignInMode = "FakeStringValue" - Identity = "FakeStringValue" - AllowHomeScreen = "FakeStringValue" - + AllowHotDesking = $True + AllowBetterTogether = 'Enabled' + SearchOnCommonAreaPhoneMode = 'Enabled' + Description = 'FakeStringValue' + HotDeskingIdleTimeoutInMinutes = 3 + SignInMode = 'UserSignIn' + Identity = 'FakeStringValue' + AllowHomeScreen = 'Enabled' } } } - It 'Should return true from the Test method' { Test-TargetResource @testParams | Should -Be $true } } - Context -Name "The TeamsIPPhonePolicy exists and values are NOT in the desired state" -Fixture { + Context -Name 'The TeamsIPPhonePolicy exists and values are NOT in the desired state' -Fixture { BeforeAll { $testParams = @{ AllowHotDesking = $True - AllowBetterTogether = "FakeStringValue" - SearchOnCommonAreaPhoneMode = "FakeStringValue" - Description = "FakeStringValue" + AllowBetterTogether = 'Enabled' + SearchOnCommonAreaPhoneMode = 'Enabled' + Description = 'FakeStringValue' HotDeskingIdleTimeoutInMinutes = 3 - SignInMode = "FakeStringValue" - Identity = "FakeStringValue" - AllowHomeScreen = "FakeStringValue" - Ensure = "Present" - Credential = $Credential; + SignInMode = 'UserSignIn' + Identity = 'FakeStringValue' + AllowHomeScreen = 'Enabled' + Ensure = 'Present' + Credential = $Credential; } Mock -CommandName Get-CsTeamsIPPhonePolicy -MockWith { return @{ - AllowHotDesking = $False - AllowBetterTogether = "FakeStringValueDrift #Drift" - SearchOnCommonAreaPhoneMode = "FakeStringValueDrift #Drift" - Description = "FakeStringValueDrift #Drift" - HotDeskingIdleTimeoutInMinutes = 2 - SignInMode = "FakeStringValueDrift #Drift" - Identity = "FakeStringValue" - AllowHomeScreen = "FakeStringValueDrift #Drift" + AllowHotDesking = $False + AllowBetterTogether = 'Disabled' + SearchOnCommonAreaPhoneMode = 'Disabled' + Description = 'FakeStringValueDrift #Drift' + HotDeskingIdleTimeoutInMinutes = 2 + SignInMode = 'CommonAreaPhoneSignIn' + Identity = 'FakeStringValue' + AllowHomeScreen = 'Disabled' } } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Present' } @@ -194,13 +191,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Test-TargetResource @testParams | Should -Be $false } - It "Should call the Set method" { + It 'Should call the Set method' { Set-TargetResource @testParams Should -Invoke -CommandName Set-CsTeamsIPPhonePolicy -Exactly 1 } } - Context -Name "ReverseDSC Tests" -Fixture { + Context -Name 'ReverseDSC Tests' -Fixture { BeforeAll { $Global:CurrentModeIsExport = $true $testParams = @{ @@ -209,19 +206,19 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Mock -CommandName Get-CsTeamsIPPhonePolicy -MockWith { return @{ - AllowHotDesking = $True - AllowBetterTogether = "FakeStringValue" - SearchOnCommonAreaPhoneMode = "FakeStringValue" - Description = "FakeStringValue" - HotDeskingIdleTimeoutInMinutes = 3 - SignInMode = "FakeStringValue" - Identity = "FakeStringValue" - AllowHomeScreen = "FakeStringValue" + AllowHotDesking = $True + AllowBetterTogether = 'Enabled' + SearchOnCommonAreaPhoneMode = 'Enabled' + Description = 'FakeStringValue' + HotDeskingIdleTimeoutInMinutes = 3 + SignInMode = 'UserSignIn' + Identity = 'FakeStringValue' + AllowHomeScreen = 'Enabled' } } } - It "Should Reverse Engineer resource from the Export method" { + It 'Should Reverse Engineer resource from the Export method' { Export-TargetResource @testParams } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsShiftsPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsShiftsPolicy.Tests.ps1 index f91525dd39..40fa1233ba 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsShiftsPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsShiftsPolicy.Tests.ps1 @@ -2,27 +2,27 @@ param( ) $M365DSCTestFolder = Join-Path -Path $PSScriptRoot ` - -ChildPath "..\..\Unit" ` - -Resolve + -ChildPath '..\..\Unit' ` + -Resolve $CmdletModule = (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\Stubs\Microsoft365.psm1" ` - -Resolve) + -ChildPath '\Stubs\Microsoft365.psm1' ` + -Resolve) $GenericStubPath = (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\Stubs\Generic.psm1" ` - -Resolve) + -ChildPath '\Stubs\Generic.psm1' ` + -Resolve) Import-Module -Name (Join-Path -Path $M365DSCTestFolder ` - -ChildPath "\UnitTestHelper.psm1" ` + -ChildPath '\UnitTestHelper.psm1' ` -Resolve) $Global:DscHelper = New-M365DscUnitTestHelper -StubModule $CmdletModule ` - -DscResource "TeamsShiftsPolicy" -GenericStubModule $GenericStubPath + -DscResource 'TeamsShiftsPolicy' -GenericStubModule $GenericStubPath Describe -Name $Global:DscHelper.DescribeHeader -Fixture { InModuleScope -ModuleName $Global:DscHelper.ModuleName -ScriptBlock { Invoke-Command -ScriptBlock $Global:DscHelper.InitializeScript -NoNewScope BeforeAll { - $secpasswd = ConvertTo-SecureString "f@kepassword1" -AsPlainText -Force - $Credential = New-Object System.Management.Automation.PSCredential ("tenantadmin@mydomain.com", $secpasswd) + $secpasswd = ConvertTo-SecureString 'f@kepassword1' -AsPlainText -Force + $Credential = New-Object System.Management.Automation.PSCredential ('tenantadmin@mydomain.com', $secpasswd) Mock -CommandName Confirm-M365DSCDependencies -MockWith { } @@ -43,30 +43,30 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } Mock -CommandName New-M365DSCConnection -MockWith { - return "Credential" + return 'Credential' } } # Test contexts - Context -Name "The TeamsShiftsPolicy should exist but it DOES NOT" -Fixture { + Context -Name 'The TeamsShiftsPolicy should exist but it DOES NOT' -Fixture { BeforeAll { $testParams = @{ EnableShiftPresence = $True - AccessType = "FakeStringValue" - ShiftNoticeMessageType = "FakeStringValue" - ShiftNoticeMessageCustom = "FakeStringValue" + AccessType = 'UnrestrictedAccess_TeamsApp' + ShiftNoticeMessageType = 'DefaultMessage' + ShiftNoticeMessageCustom = 'FakeStringValue' AccessGracePeriodMinutes = 3 - Identity = "FakeStringValue" - ShiftNoticeFrequency = "FakeStringValue" + Identity = 'FakeStringValue' + ShiftNoticeFrequency = 'Always' EnableScheduleOwnerPermissions = $True - Ensure = "Present" - Credential = $Credential; + Ensure = 'Present' + Credential = $Credential; } Mock -CommandName Get-CsTeamsShiftsPolicy -MockWith { return $null } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Absent' } It 'Should return false from the Test method' { @@ -78,37 +78,37 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } } - Context -Name "The TeamsShiftsPolicy exists but it SHOULD NOT" -Fixture { + Context -Name 'The TeamsShiftsPolicy exists but it SHOULD NOT' -Fixture { BeforeAll { $testParams = @{ EnableShiftPresence = $True - AccessType = "FakeStringValue" - ShiftNoticeMessageType = "FakeStringValue" - ShiftNoticeMessageCustom = "FakeStringValue" + AccessType = 'UnrestrictedAccess_TeamsApp' + ShiftNoticeMessageType = 'DefaultMessage' + ShiftNoticeMessageCustom = 'FakeStringValue' AccessGracePeriodMinutes = 3 - Identity = "FakeStringValue" - ShiftNoticeFrequency = "FakeStringValue" + Identity = 'FakeStringValue' + ShiftNoticeFrequency = 'Always' EnableScheduleOwnerPermissions = $True - Ensure = "Absent" - Credential = $Credential; + Ensure = 'Absent' + Credential = $Credential; } Mock -CommandName Get-CsTeamsShiftsPolicy -MockWith { return @{ - EnableShiftPresence = $True - AccessType = "FakeStringValue" - ShiftNoticeMessageType = "FakeStringValue" - ShiftNoticeMessageCustom = "FakeStringValue" - AccessGracePeriodMinutes = 3 - Identity = "FakeStringValue" - ShiftNoticeFrequency = "FakeStringValue" - EnableScheduleOwnerPermissions = $True + EnableShiftPresence = $True + AccessType = 'UnrestrictedAccess_TeamsApp' + ShiftNoticeMessageType = 'DefaultMessage' + ShiftNoticeMessageCustom = 'FakeStringValue' + AccessGracePeriodMinutes = 3 + Identity = 'FakeStringValue' + ShiftNoticeFrequency = 'Always' + EnableScheduleOwnerPermissions = $True } } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Present' } @@ -121,31 +121,31 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Should -Invoke -CommandName Remove-CsTeamsShiftsPolicy -Exactly 1 } } - Context -Name "The TeamsShiftsPolicy Exists and Values are already in the desired state" -Fixture { + Context -Name 'The TeamsShiftsPolicy Exists and Values are already in the desired state' -Fixture { BeforeAll { $testParams = @{ EnableShiftPresence = $True - AccessType = "FakeStringValue" - ShiftNoticeMessageType = "FakeStringValue" - ShiftNoticeMessageCustom = "FakeStringValue" + AccessType = 'UnrestrictedAccess_TeamsApp' + ShiftNoticeMessageType = 'DefaultMessage' + ShiftNoticeMessageCustom = 'FakeStringValue' AccessGracePeriodMinutes = 3 - Identity = "FakeStringValue" - ShiftNoticeFrequency = "FakeStringValue" + Identity = 'FakeStringValue' + ShiftNoticeFrequency = 'Always' EnableScheduleOwnerPermissions = $True - Ensure = "Present" - Credential = $Credential; + Ensure = 'Present' + Credential = $Credential; } Mock -CommandName Get-CsTeamsShiftsPolicy -MockWith { return @{ - EnableShiftPresence = $True - AccessType = "FakeStringValue" - ShiftNoticeMessageType = "FakeStringValue" - ShiftNoticeMessageCustom = "FakeStringValue" - AccessGracePeriodMinutes = 3 - Identity = "FakeStringValue" - ShiftNoticeFrequency = "FakeStringValue" - EnableScheduleOwnerPermissions = $True + EnableShiftPresence = $True + AccessType = 'UnrestrictedAccess_TeamsApp' + ShiftNoticeMessageType = 'DefaultMessage' + ShiftNoticeMessageCustom = 'FakeStringValue' + AccessGracePeriodMinutes = 3 + Identity = 'FakeStringValue' + ShiftNoticeFrequency = 'Always' + EnableScheduleOwnerPermissions = $True } } @@ -157,36 +157,36 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } } - Context -Name "The TeamsShiftsPolicy exists and values are NOT in the desired state" -Fixture { + Context -Name 'The TeamsShiftsPolicy exists and values are NOT in the desired state' -Fixture { BeforeAll { $testParams = @{ EnableShiftPresence = $True - AccessType = "FakeStringValue" - ShiftNoticeMessageType = "FakeStringValue" - ShiftNoticeMessageCustom = "FakeStringValue" + AccessType = 'UnrestrictedAccess_TeamsApp' + ShiftNoticeMessageType = 'DefaultMessage' + ShiftNoticeMessageCustom = 'FakeStringValue' AccessGracePeriodMinutes = 3 - Identity = "FakeStringValue" - ShiftNoticeFrequency = "FakeStringValue" + Identity = 'FakeStringValue' + ShiftNoticeFrequency = 'Always' EnableScheduleOwnerPermissions = $True - Ensure = "Present" - Credential = $Credential; + Ensure = 'Present' + Credential = $Credential; } Mock -CommandName Get-CsTeamsShiftsPolicy -MockWith { return @{ - EnableShiftPresence = $False - AccessType = "FakeStringValueDrift #Drift" - ShiftNoticeMessageType = "FakeStringValueDrift #Drift" - ShiftNoticeMessageCustom = "FakeStringValueDrift #Drift" - AccessGracePeriodMinutes = 2 - Identity = "FakeStringValue" - ShiftNoticeFrequency = "FakeStringValueDrift #Drift" - EnableScheduleOwnerPermissions = $False + EnableShiftPresence = $False + AccessType = 'UnrestrictedAccess_TeamsApp' + ShiftNoticeMessageType = 'Message1' + ShiftNoticeMessageCustom = 'FakeStringValueDrift #Drift' + AccessGracePeriodMinutes = 2 + Identity = 'FakeStringValue' + ShiftNoticeFrequency = 'ShowOnceOnChange' + EnableScheduleOwnerPermissions = $False } } } - It "Should return Values from the Get method" { + It 'Should return Values from the Get method' { (Get-TargetResource @testParams).Ensure | Should -Be 'Present' } @@ -194,13 +194,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Test-TargetResource @testParams | Should -Be $false } - It "Should call the Set method" { + It 'Should call the Set method' { Set-TargetResource @testParams Should -Invoke -CommandName Set-CsTeamsShiftsPolicy -Exactly 1 } } - Context -Name "ReverseDSC Tests" -Fixture { + Context -Name 'ReverseDSC Tests' -Fixture { BeforeAll { $Global:CurrentModeIsExport = $true $testParams = @{ @@ -209,19 +209,19 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Mock -CommandName Get-CsTeamsShiftsPolicy -MockWith { return @{ - EnableShiftPresence = $True - AccessType = "FakeStringValue" - ShiftNoticeMessageType = "FakeStringValue" - ShiftNoticeMessageCustom = "FakeStringValue" - AccessGracePeriodMinutes = 3 - Identity = "FakeStringValue" - ShiftNoticeFrequency = "FakeStringValue" - EnableScheduleOwnerPermissions = $True + EnableShiftPresence = $True + AccessType = 'UnrestrictedAccess_TeamsApp' + ShiftNoticeMessageType = 'DefaultMessage' + ShiftNoticeMessageCustom = 'FakeStringValue' + AccessGracePeriodMinutes = 3 + Identity = 'FakeStringValue' + ShiftNoticeFrequency = 'Always' + EnableScheduleOwnerPermissions = $True } } } - It "Should Reverse Engineer resource from the Export method" { + It 'Should Reverse Engineer resource from the Export method' { Export-TargetResource @testParams } }