Description
Steps to reproduce
Since the recent release, several tests in the SharePointDsc module fail with the following error:
The following PSScriptAnalyzer rule 'PSDSCUseIdenticalMandatoryParametersForDSC' errors need to be fixed:
MSFT_SPSearchContentSource.psm1 (Line 1): The 'Required' parameter 'ScheduleType' is not present in 'Get-TargetResource' DSC resource function(s).
MSFT_SPSearchContentSource.psm1 (Line 219): The 'Required' parameter 'ScheduleType' is not present in 'Set-TargetResource' DSC resource function(s).
MSFT_SPSearchContentSource.psm1 (Line 683): The 'Required' parameter 'ScheduleType' is not present in 'Test-TargetResource' DSC resource function(s).
The specified parameter however are parameters in subclasses, which should not be present in the *-TargetResource methods.
[ClassVersion("1.0.0")]
Class MSFT_SPSearchCrawlSchedule
{
[Required, Description("How frequently should this crawl be run"), ValueMap{"None","Daily","Weekly","Monthly"}, Values{"None","Daily","Weekly","Monthly"}] String ScheduleType;
[Write, Description("Monthly crawls only: Which day of the month should the crawl run on")] Uint32 CrawlScheduleDaysOfMonth;
[Write, Description("Weekly crawls only: What days should the crawl be run on"), ValueMap{"Everyday", "Weekdays", "Weekends", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}, Values{"Everyday", "Weekdays", "Weekends", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}] String CrawlScheduleDaysOfWeek[];
[Write, Description("Monthly crawls only: Which months should this crawl be run during"), ValueMap{"AllMonths", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, Values{"AllMonths", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}] String CrawlScheduleMonthsOfYear[];
[Write, Description("The hour of the day that the schedule should begin")] Uint32 StartHour;
[Write, Description("The minute of the specified hour that the schedule should begin")] Uint32 StartMinute;
[Write, Description("Specifies the number of times to repeat the crawl within a day")] Uint32 CrawlScheduleRepeatDuration;
[Write, Description("Specifies the number of minutes between crawl repeats on a day")] Uint32 CrawlScheduleRepeatInterval;
[Write, Description("For daily crawls, this is the number of days between crawls. For weekly this is the number of weeks between crawls")] Uint32 CrawlScheduleRunEveryInterval;
};
[ClassVersion("1.0.0.0"), FriendlyName("SPSearchContentSource")]
class MSFT_SPSearchContentSource : OMI_BaseResource
{
[Key, Description("The name of the content source")] String Name;
[Key, Description("The name of the search service app that this content source exists within")] String ServiceAppName;
[Required, Description("The type of content source - currently only SharePoint, Website, File Shares and Business are supported"), ValueMap{"SharePoint","Website","FileShare","Business"}, Values{"SharePoint","Website","FileShare","Business"}] String ContentSourceType;
[Write, Description("A list of the addresses this content source includes")] String Addresses[];
[Write, Description("Should the crawler index everything, just the first site or page, or a custom depth (applies to websites only)"), ValueMap{"CrawlEverything","CrawlFirstOnly","Custom"}, Values{"CrawlEverything","CrawlFirstOnly","Custom"}] String CrawlSetting;
[Write, Description("Should this content source use continuous crawl (SharePoint sites only)")] Boolean ContinuousCrawl;
[Write, Description("What is the incremental schedule for this content source"), EmbeddedInstance("MSFT_SPSearchCrawlSchedule")] String IncrementalSchedule;
[Write, Description("What is the full schedule for this content source"), EmbeddedInstance("MSFT_SPSearchCrawlSchedule")] String FullSchedule;
[Write, Description("What is the priority on this content source"), ValueMap{"Normal","High"}, Values{"Normal","High"}] String Priority;
[Write, Description("How many pages deep should the crawler go (-1 = unlimited, website sources only)")] Uint32 LimitPageDepth;
[Write, Description("How many server hops should the crawler make (-1 = unlimtied, website sources only)")] Uint32 LimitServerHops;
[Write, Description("Line of Business System and System Instance names")] String LOBSystemSet[];
[Write, Description("Present if the source should exist, absent if it should not"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;
[Write, Description("Specify true if DSC is allowed to delete and recreate a content source to apply the correct settings, otherwise false will just report errors if a change can not be applied.")] Boolean Force;
[Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount;
};
Expected behavior
Not complaint about the missing parameters
Actual behavior
Gives false positives:
MSFT_SPSearchContentSource.psm1 (Line 1): The 'Required' parameter 'ScheduleType' is not present in 'Get-TargetResource' DSC resource function(s).
MSFT_SPSearchContentSource.psm1 (Line 219): The 'Required' parameter 'ScheduleType' is not present in 'Set-TargetResource' DSC resource function(s).
MSFT_SPSearchContentSource.psm1 (Line 683): The 'Required' parameter 'ScheduleType' is not present in 'Test-TargetResource' DSC resource function(s).
Environment data
Tests are running in AppVeyor with PSv5.1 and v1.18 of PSScriptAnalyzer