From 88c87648148e22fccd9ab1a74d0dcf44a37178d0 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 22 Oct 2015 14:54:03 +1100 Subject: [PATCH 001/147] Fixed issue with formatting of offline prereq installer arguments --- .../MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 index 41f852290..e65b8e4da 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 @@ -128,7 +128,7 @@ function Set-TargetResource } } $requiredParams | ForEach-Object { - $prereqArgs += " /$_ `"$($PSBoundParameters.$_)`"" + $prereqArgs += " /$_`:`"$($PSBoundParameters.$_)`"" } } From 3df2a416dee930d90e9e686eb1c247673c2e2d57 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 1 Nov 2015 20:49:58 +1100 Subject: [PATCH 002/147] Added documentation to MOF files for autogeneration of wiki --- .../MSFT_xSPBCSServiceApp.schema.mof | 18 ++++++++ .../MSFT_xSPCacheAccounts.schema.mof | 14 ++++++ .../MSFT_xSPCreateFarm.schema.mof | 26 +++++++++++ ...FT_xSPDiagnosticLoggingSettings.schema.mof | 30 +++++++++++++ ...MSFT_xSPDistributedCacheService.schema.mof | 20 +++++++++ .../MSFT_xSPFeature.schema.mof | 18 ++++++++ .../MSFT_xSPInstall.schema.mof | 30 +++++++++++++ .../MSFT_xSPInstallPrereqs.schema.mof | 45 +++++++++++++++++++ .../MSFT_xSPJoinFarm.schema.mof | 17 +++++++ .../MSFT_xSPManagedAccount.schema.mof | 16 +++++++ ...FT_xSPManagedMetaDataServiceApp.schema.mof | 18 ++++++++ .../MSFT_xSPManagedPath.schema.mof | 19 ++++++++ .../MSFT_xSPSearchServiceApp.schema.mof | 21 +++++++++ .../MSFT_xSPSecureStoreServiceApp.schema.mof | 18 ++++++++ .../MSFT_xSPServiceAppPool.schema.mof | 15 +++++++ .../MSFT_xSPServiceInstance.schema.mof | 22 +++++++++ .../MSFT_xSPSite/MSFT_xSPSite.schema.mof | 20 +++++++++ .../MSFT_xSPStateServiceApp.schema.mof | 15 +++++++ .../MSFT_xSPUsageApplication.schema.mof | 18 ++++++++ .../MSFT_xSPUserProfileServiceApp.schema.mof | 25 +++++++++++ .../MSFT_xSPUserProfileSyncService.schema.mof | 18 ++++++++ .../MSFT_xSPWebApplication.schema.mof | 22 +++++++++ Tests/Generate-xSharePointWikiPages.ps1 | 33 ++++++++++++++ Tests/Tests.pssproj | 1 + .../xSharePoint/xSharePoint.TestHelpers.psm1 | 12 ++++- 25 files changed, 510 insertions(+), 1 deletion(-) create mode 100644 Tests/Generate-xSharePointWikiPages.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPBCSServiceApp/MSFT_xSPBCSServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPBCSServiceApp/MSFT_xSPBCSServiceApp.schema.mof index 08020d3ab..9c74b6b6b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPBCSServiceApp/MSFT_xSPBCSServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPBCSServiceApp/MSFT_xSPBCSServiceApp.schema.mof @@ -1,4 +1,22 @@ +/* +**Description** +This resource is used to provision and manage an instance of the Business Connectivity Services Service Application. +It will identify an instance of the BCS app through the application display name. +Currently the resource will provision the app if it does not yet exist, and will change the service account associated to the app if it does not match the configuration. +Database names or server name will not be changed if the configuration does not match, these parameters are only used for the initial provisioning of the service application. + +**Example** + + xSPBCSServiceApp BCSServiceApp + { + Name = "BCS Service Application" + ApplicationPool = "SharePoint Service Applications" + DatabaseName = "SP_BCS" + DatabaseServer = $DatabaseServer + InstallAccount = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPBCSServiceApp")] class MSFT_xSPBCSServiceApp : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPCacheAccounts/MSFT_xSPCacheAccounts.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPCacheAccounts/MSFT_xSPCacheAccounts.schema.mof index 9ebdce416..8ab123936 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPCacheAccounts/MSFT_xSPCacheAccounts.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPCacheAccounts/MSFT_xSPCacheAccounts.schema.mof @@ -1,4 +1,18 @@ +/* +**Description** +This resource is used to set the "super user" and "super reader" cache accounts for the specified web application object (as described in the TechNet article [Configure object cache user accounts in SharePoint Server 2013](https://technet.microsoft.com/en-us/library/ff758656.aspx)). + +**Example** + + xSPCacheAccounts SetCacheAccounts + { + WebAppUrl = "http://sharepoint.contoso.com" + SuperUserAlias = "DEMO\svcSPSuperUser" + SuperReaderAlias = "DEMO\svcSPReader" + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPCacheAccounts")] class MSFT_xSPCacheAccounts : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.schema.mof index 3c51d885e..32955ca6d 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.schema.mof @@ -1,3 +1,29 @@ +/* +**Description** + +This resource is used to provision a new SharePoint farm. +It should only be used on the first server in the farm to create the configuration database, all servers to join the farm after the first server creates the configuration database should use [xSPJoinFarm](xSPJoinFarm). +Once the config DB has been created, the resource will install local help collections, secure resources, activate features and provision the central admin site. + +The port of the Central Admin website can be set by using the CentralAdministrationPort property, if this is not defined the site will be provisioned on port 9999. +However this setting will not impact existing deployments that already have Central Admin provisioned on another port. +Also when a farm is created, the current behavior is to not enroll the server as a cache server (which is the default behavior of SharePoint). +This means you need to use [xSPDistributedCacheService](xSPDistributedCacheService) on at least one server in the farm to designate it as a cache server. + +**Example** + + xSPCreateFarm CreateSPFarm + { + DatabaseServer = "SQL.contoso.local\SQLINSTANCE" + FarmConfigDatabaseName = "SP_Config" + Passphrase = "Example Passphrase" + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SetupAccount + AdminContentDatabaseName = "SP_AdminContent" + CentralAdministrationPort = 2000 + ServerRole = Custom + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPCreateFarm")] class MSFT_xSPCreateFarm : OMI_BaseResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPDiagnosticLoggingSettings/MSFT_xSPDiagnosticLoggingSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPDiagnosticLoggingSettings/MSFT_xSPDiagnosticLoggingSettings.schema.mof index 26731d015..ede389a1d 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPDiagnosticLoggingSettings/MSFT_xSPDiagnosticLoggingSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPDiagnosticLoggingSettings/MSFT_xSPDiagnosticLoggingSettings.schema.mof @@ -1,4 +1,34 @@ +/* +**Description** +This resource is responsible for configuring settings to do with the diagnostic (ULS) logging on servers in the farm. +These settings are applied to the diagnostic logging service for the farm and do not need to be applied to each server individually, the settings will be propagated throughout the farm when they are set. + +**Example** + + xSPDiagnosticLoggingSettings ApplyDiagnosticLogSettings + { + PsDscRunAsCredential = $InstallAccount + LogPath = "L:\ULSLogs" + LogSpaceInGB = 10 + AppAnalyticsAutomaticUploadEnabled = $false + CustomerExperienceImprovementProgramEnabled = $true + DaysToKeepLogs = 7 + DownloadErrorReportingUpdatesEnabled = $false + ErrorReportingAutomaticUploadEnabled = $false + ErrorReportingEnabled = $false + EventLogFloodProtectionEnabled = $true + EventLogFloodProtectionNotifyInterval = 5 + EventLogFloodProtectionQuietPeriod = 2 + EventLogFloodProtectionThreshold = 5 + EventLogFloodProtectionTriggerPeriod = 2 + LogCutInterval = 15 + LogMaxDiskSpaceUsageEnabled = $true + ScriptErrorReportingDelay = 30 + ScriptErrorReportingEnabled = $true + ScriptErrorReportingRequireAuth = $true + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPDiagnosticLoggingSettings")] class MSFT_xSPDiagnosticLoggingSettings : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.schema.mof index eebec204a..13e856455 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.schema.mof @@ -1,3 +1,23 @@ +/* +**Description** + +This resource is responsible for provisioning the distributed cache to the service it runs on. +This is required in your farm on at least one server (as the behavior of [xSPCreateFarm](xSPCreateFarm) and [xSPJoinFarm](xSPJoinFarm) is to not enroll every server as a cache server). +The service will be provisioned or de-provisioned based on the Ensure property, and when provisioned the CacheSizeInMB property and ServiceAccount property will be used to configure it. +The property createFirewallRules is used to determine if exceptions should be added to the windows firewall to allow communication between servers on the appropriate ports. + +**Example** + + xSPDistributedCacheService EnableDistributedCache + { + Name = "AppFabricCachingService" + Ensure = "Present" + CacheSizeInMB = 8192 + ServiceAccount = "DEMO\ServiceAccount" + InstallAccount = $InstallAccount + CreateFirewallRules = $true + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPDistributedCacheService")] class MSFT_xSPDistributedCacheService : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFeature/MSFT_xSPFeature.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPFeature/MSFT_xSPFeature.schema.mof index 98cea1450..be07bcbbc 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPFeature/MSFT_xSPFeature.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPFeature/MSFT_xSPFeature.schema.mof @@ -1,3 +1,21 @@ +/* +**Description** + +This resource is used to make sure that a specific feature is either enabled or disabled at a given URL/scope. +The Ensure property will dictate if the feature should be on or off. +The name property is the name of the feature based on its folder name in the FEATURES folder in the SharePoint hive directory. + +**Example** + + xSPFeature EnableViewFormsLockDown + { + Name = "ViewFormPagesLockDown" + Url = "http://www.contoso.com" + Ensure = "Present" + Scope = "Site" + PsDscRunAsCredential = $SetupAccuount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPFeature")] class MSFT_xSPFeature : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstall/MSFT_xSPInstall.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPInstall/MSFT_xSPInstall.schema.mof index fea52d9f5..b3405b8d4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstall/MSFT_xSPInstall.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstall/MSFT_xSPInstall.schema.mof @@ -1,3 +1,33 @@ +/* +**Description** + +This resource is used to install the SharePoint binaries. +The BinaryDir parameter should point to the path that setup.exe is located (not to setup.exe itself). +The ProductKey parameter is used to inject in to the configuration file and validate the license key during the installation process. +This module depends on the prerequisites already being installed, which can be done through the use of [xSPInstallPreReqs](xSPInstallPreReqs). + +**Example** + + xSPInstall InstallBinaries + { + BinaryDir = "C:\SPInstall" + ProductKey = $ProductKey + } + +**Installing SharePoint Foundation 2013** + +Currently SharePoint Foundation is not supported by xSPInstall (see [Issue #81](https://github.com/PowerShell/xSharePoint/issues/81) for the details). A workaround for this is to use the package resource as demonstrated below. + + Package InstallSharePointFoundation + { + Ensure = "Present" + Name = "Microsoft SharePoint Foundation 2013 Core" + Path = "E:\SharePoint2013\Setup.exe" + Arguments = "/config E:\SharePoint2013\files\setupfarmsilent\config.xml" + ProductID = "90150000-1014-0000-1000-0000000FF1CE" + ReturnCode = 0 + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPInstall")] class MSFT_xSPInstall : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.schema.mof index 94c9b902c..e68494f0f 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.schema.mof @@ -1,3 +1,48 @@ +/* +**Description** + +This resource is responsible for ensuring the installation of all SharePoint prerequisites. +It makes use of the PrerequisiteInstaller.exe file that is part of the SharePoint binaries, and will install the required Windows features as well as additional software. +The OnlineMode boolean will tell the prerequisite installer which mode to run in, if it is online you do not need to list any other parameters for this resource. +If you do not use online mode, you must include all other parameters to specify where the installation files are located. +These additional parameters map directly to the options passed to prerequisiteinstaller.exe. + +Additionally, the process of installing the prerequisites on a Windows Server usually results in 2-3 restarts of the system being required. To ensure the DSC configuration is able to restart the server when needed, ensure the below settings for the local configuration manager are included in your DSC file. + + LocalConfigurationManager + { + RebootNodeIfNeeded = $true + } + +**Examples** + +Online example: + + xSPInstallPrereqs InstallPrerequisites + { + InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" + OnlineMode = $true + } + +Offline example: + + xSPInstallPrereqs InstallPrerequisites + { + InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" + OnlineMode = $false + SQLNCli = "C:\SPInstall\prerequisiteinstallerfiles\sqlncli.msi" + PowerShell = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB2506143-x64.msu" + NETFX = "C:\SPInstall\prerequisiteinstallerfiles\dotNetFx45_Full_setup.exe" + IDFX = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB974405-x64.msu" + Sync = "C:\SPInstall\prerequisiteinstallerfiles\Synchronization.msi" + AppFabric = "C:\SPInstall\prerequisiteinstallerfiles\WindowsServerAppFabricSetup_x64.exe" + IDFX11 = "C:\SPInstall\prerequisiteinstallerfiles\MicrosoftIdentityExtensions-64.msi" + MSIPCClient = "C:\SPInstall\prerequisiteinstallerfiles\setup_msipc_x64.msi" + WCFDataServices = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices.exe" + KB2671763 = "C:\SPInstall\prerequisiteinstallerfiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe" + WCFDataServices56 = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices56.exe" + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPInstallPrereqs")] class MSFT_xSPInstallPrereqs : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.schema.mof index 0284a63fa..dcf244734 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.schema.mof @@ -1,3 +1,20 @@ +/* +**Description** + +This resource will be responsible for joining a server to an existing SharePoint farm. +To create a new farm use the [xSPCreateFarm](xSPCreateFarm) resource on a different server to begin with, and then pass the same database server and configuration database name parameters to the additional servers using this resource. +After the server has joined the farm, the process will wait for 5 minutes to allow farm specific configuration to take place on the server, before allowing further DSC configuration to take place. + +**Example** + + xSPJoinFarm JoinSPFarm + { + DatabaseServer = $DatabaseServer + FarmConfigDatabaseName = "SP_Config" + Passphrase = $FarmPassPhrase + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPJoinFarm")] class MSFT_xSPJoinFarm : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPManagedAccount/MSFT_xSPManagedAccount.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPManagedAccount/MSFT_xSPManagedAccount.schema.mof index a0258492a..4f5133fd3 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPManagedAccount/MSFT_xSPManagedAccount.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPManagedAccount/MSFT_xSPManagedAccount.schema.mof @@ -1,3 +1,19 @@ +/* +**Description** + +This resource will ensure a managed account is provisioned in to the SharePoint farm. +The Account object specific the credential to store (including username and password) to set as the managed account. +The settings for EmailNotification, PreExpireDays and Schedule all relate to enabling automatic password change for the managed account, leaving these option out of the resource will ensure that no automatic password changing from SharePoint occurs. + +**Example** + + xSPManagedAccount WebPoolManagedAccount + { + AccountName = $WebPoolManagedAccount.UserName + Account = $WebPoolManagedAccount + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPManagedAccount")] class MSFT_xSPManagedAccount : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPManagedMetadataServiceApp/MSFT_xSPManagedMetaDataServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPManagedMetadataServiceApp/MSFT_xSPManagedMetaDataServiceApp.schema.mof index 84f36e3db..d4e073221 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPManagedMetadataServiceApp/MSFT_xSPManagedMetaDataServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPManagedMetadataServiceApp/MSFT_xSPManagedMetaDataServiceApp.schema.mof @@ -1,3 +1,21 @@ +/* +**Description** + +Creates a managed metadata service application. +The application pool property specifies which application pool it should use, and will reset the application back to this pool if it is changed after its initial provisioning. +The database server and database name properties are only used during provisioning, and will not be altered as part of the ongoing operation of the DSC resource. + +**Example** + + xSPManagedMetaDataServiceApp ManagedMetadataServiceApp + { + Name = "Managed Metadata Service Application" + InstallAccount = $InstallAccount + ApplicationPool = "SharePoint Service Applications" + DatabaseServer = $DatabaseServer + DatabaseName = "SP_ManagedMetadata" + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPManagedMetaDataServiceApp")] class MSFT_xSPManagedMetaDataServiceApp : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPManagedPath/MSFT_xSPManagedPath.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPManagedPath/MSFT_xSPManagedPath.schema.mof index db74c22c0..d3b7d02b4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPManagedPath/MSFT_xSPManagedPath.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPManagedPath/MSFT_xSPManagedPath.schema.mof @@ -1,3 +1,22 @@ +/* +**Description** + +This resource is responsible for creating managed paths associated with a specific web application. +The WebAppUrl parameter is used to specify the web application to create the path against, and the RelativeUrl parameter lets you set the URL. +Explicit when set to true will create an explicit inclusion path, if set to false the path is created as wildcard inclusion. +If you are using host named site collections set HostHeader to true and the path will be created as a host header path to be applied for host named site collections. + +**Example** + + xSPManagedPath TeamsManagedPath + { + WebAppUrl = "http://sharepoint.contoso.com" + InstallAccount = $InstallAccount + RelativeUrl = "teams" + Explicit = $false + HostHeader = $true + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPManagedPath")] class MSFT_xSPManagedPath : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.schema.mof index 09d9cd3da..314007287 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.schema.mof @@ -1,3 +1,24 @@ +/* +**Description** + +This resource is responsible for provisioning the search service application. +The current version lets you specify the database name and server, as well as the application pool. +If the application pool is changed the DSC resource will set it back as per what is set in the resource. +The database name parameter is used as the prefix for all search databases (so you will end up with one for the admin database which matches the name, and then "_analyticsreportingstore", "_crawlstore" and "_linkstore" databases as well). + +In the current version of the module, it is not possible to apply a search topology via DSC, only provision the service application. +This is something that is coming in a future release. + +**Example** + + xSPSearchServiceApp SearchServiceApp + { + Name = "Search Service Application" + DatabaseName = "SP_Search" + ApplicationPool = "SharePoint Service Applications" + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPSearchServiceApp")] class MSFT_xSPSearchServiceApp : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof index 8b4bc052d..6e45de4e7 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof @@ -1,3 +1,21 @@ +/* +**Description** + +This resource is responsible for provisioning and configuring the secure store service application. +The parameters passed in (except those related to database specifics) are validated and set when the resource is run, the database values are only used in provisioning of the service application. + +**Example** + + xSPSecureStoreServiceApp SecureStoreServiceApp + { + Name = "Secure Store Service Application" + ApplicationPool = "SharePoint Service Applications" + AuditingEnabled = $true + AuditlogMaxSize = 30 + DatabaseName = "SP_SecureStore" + InstallAccount = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPSecureStoreServiceApp")] class MSFT_xSPSecureStoreServiceApp : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPServiceAppPool/MSFT_xSPServiceAppPool.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPServiceAppPool/MSFT_xSPServiceAppPool.schema.mof index 6db5884ac..6af668629 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPServiceAppPool/MSFT_xSPServiceAppPool.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPServiceAppPool/MSFT_xSPServiceAppPool.schema.mof @@ -1,3 +1,18 @@ +/* +**Description** + +This resource is used for provisioning an application pool that can be used for service applications. +The account used for the service account must already be registered as a managed account (which can be provisioned through [xSPManagedAccount](xSPManagedAccount)). + +**Example** + + xSPServiceAppPool MainServiceAppPool + { + Name = "SharePoint Service Applications" + ServiceAccount = "Demo\ServiceAccount" + InstallAccount = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPServiceAppPool")] class MSFT_xSPServiceAppPool : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPServiceInstance/MSFT_xSPServiceInstance.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPServiceInstance/MSFT_xSPServiceInstance.schema.mof index 04d098e42..20166fd82 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPServiceInstance/MSFT_xSPServiceInstance.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPServiceInstance/MSFT_xSPServiceInstance.schema.mof @@ -1,3 +1,25 @@ +/* +**Description** + +This resource is used to specify if a specific service should be running (Ensure = "Present") or not running (Ensure = "Absent") on the current server. +The name is the display name of the service as shown in the Central Admin website. + +**Examples** + + xSPServiceInstance ManagedMetadataServiceInstance + { + Name = "Managed Metadata Web Service" + Ensure = "Present" + InstallAccount = $InstallAccount + } + + xSPServiceInstance StopBCSServiceInstance + { + Name = "Business Data Connectivity Service" + Ensure = "Absent" + InstallAccount = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPServiceInstance")] class MSFT_xSPServiceInstance : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSite/MSFT_xSPSite.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSite/MSFT_xSPSite.schema.mof index 57f943d3a..c15fdf69c 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSite/MSFT_xSPSite.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSite/MSFT_xSPSite.schema.mof @@ -1,3 +1,23 @@ +/* +**Description** + +This resource will provision a site collection to the current farm, based on the settings that are passed through. +These settings map to the New-SPSite cmdlet and accept the same values and types. + +The current version of xSharePoint is only able to check for the existence of a site collection, the additional parameters are not checked for yet, but will be in a later release + +**Example** + + xSPSite TeamSite + { + Url = "http://sharepoint.contoso.com" + OwnerAlias = "CONTOSO\ExampleUser" + HostHeaderWebApplication = "http://spsites.contoso.com" + Name = "Team Sites" + Template = "STS#0" + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPSite")] class MSFT_xSPSite : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPStateServiceApp/MSFT_xSPStateServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPStateServiceApp/MSFT_xSPStateServiceApp.schema.mof index c068a9051..771f73a26 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPStateServiceApp/MSFT_xSPStateServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPStateServiceApp/MSFT_xSPStateServiceApp.schema.mof @@ -1,3 +1,18 @@ +/* +**Description** + +This resource provisions an instance of the state service in to the local farm. +The database specific parameters are only used during initial provisioning of the app, and will not change database settings beyond the initial deployment. + +**Example** + + xSPStateServiceApp StateServiceApp + { + Name = "State Service Application" + DatabaseName = "SP_State" + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPStateServiceApp")] class MSFT_xSPStateServiceApp : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.schema.mof index 81c7bdd83..fe2377888 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.schema.mof @@ -1,3 +1,21 @@ +/* +**Description** + +This resource provisions an instance of the usage and health monitoring service application. +The database settings are only used for initial provisioning, but the usage settings can be changed and will be enforced as the resource is executed. + +**Example** + + xSPUsageApplication UsageApplication + { + Name = "Usage Service Application" + DatabaseName = "SP_Usage" + UsageLogCutTime = 5 + UsageLogLocation = "L:\UsageLogs" + UsageLogMaxFileSizeKB = 1024 + InstallAccount = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPUsageApplication")] class MSFT_xSPUsageApplication : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileServiceApp/MSFT_xSPUserProfileServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileServiceApp/MSFT_xSPUserProfileServiceApp.schema.mof index 6e5592696..c64f0ce4e 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileServiceApp/MSFT_xSPUserProfileServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileServiceApp/MSFT_xSPUserProfileServiceApp.schema.mof @@ -1,3 +1,28 @@ +/* +**Description** + +This resource will provision an instance of the user profile service to the farm. +It creates the required databases using the parameters that are passed in to it (although these are only used during the initial provisioning). +The farm account is used during the provisioning of the service only (in the set method), and the install account is used in the get and test methods. +This is done to ensure that the databases are created with the correct schema owners and allow the user profile sync service to operate correctly. + +**Example** + + xSPUserProfileServiceApp UserProfileServiceApp + { + Name = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + MySiteHostLocation = "http://my.sharepoint.contoso.local" + ProfileDBName = "SP_UserProfiles" + ProfileDBServer = "SQL.contoso.local\SQLINSTANCE" + SocialDBName = "SP_Social" + SocialDBServer = "SQL.contoso.local\SQLINSTANCE" + SyncDBName = "SP_ProfileSync" + SyncDBServer = "SQL.contoso.local\SQLINSTANCE" + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SetupAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPUserProfileServiceApp")] class MSFT_xSPUserProfileServiceApp : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncService/MSFT_xSPUserProfileSyncService.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncService/MSFT_xSPUserProfileSyncService.schema.mof index eef2f3df5..f92ad42a3 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncService/MSFT_xSPUserProfileSyncService.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncService/MSFT_xSPUserProfileSyncService.schema.mof @@ -1,3 +1,21 @@ +/* +**Description** + +This resource is responsible for ensuring that the user profile sync service has been provisioned (Ensure = "Present") or is not running (Ensure = "Absent") on the current server. +This resource uses the InstallAccount to validate the current state only, the set method which will do the provisioning uses the FarmAccount to do the actual work - this means that CredSSP authentication will need to be permitted to allow a connection to the local server. +To allow successful provisioning the farm account must be in the local administrators group, however it is not best practice to leave this account in the Administrators group. +Therefore this resource will add the FarmAccount credential to the local administrators group at the beginning of the set method, and then remove it once it has completed its work. + +**Example** + + xSPUserProfileSyncService UserProfileSyncService + { + UserProfileServiceAppName = "User Profile Service Application" + Ensure = "Present" + FarmAccount = $FarmAccount + InstallAccount = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPUserProfileSyncService")] class MSFT_xSPUserProfileSyncService : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index fc82bdb44..7b9d4c942 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,3 +1,25 @@ +/* +**Description** + +This resource is responsible for creating a web application within the local SharePoint farm. +The resource will provision the web application with all of the current settings, and then ensure that it stays part of the correct application pool beyond that (additional checking and setting of properties will be added in future releases). + +**Example** + + xSPWebApplication HostNameSiteCollectionWebApp + { + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Sites" + ApplicationPoolAccount = "CONTOSO\svcSPWebApp" + AllowAnonymous = $false + AuthenticationMethod = "NTLM" + DatabaseName = "SP_Content_01" + DatabaseServer = "SQL.contoso.local\SQLINSTANCE" + Url = "http://example.contoso.local" + Port = 80 + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPWebApplication")] class MSFT_xSPWebApplication : OMI_BaseResource { diff --git a/Tests/Generate-xSharePointWikiPages.ps1 b/Tests/Generate-xSharePointWikiPages.ps1 new file mode 100644 index 000000000..67204587f --- /dev/null +++ b/Tests/Generate-xSharePointWikiPages.ps1 @@ -0,0 +1,33 @@ +param +( + [parameter(Mandatory = $true)] [System.String] $OutPutPath +) + +Import-Module (Join-Path $PSScriptRoot "xSharePoint\xSharePoint.TestHelpers.psm1") + +$repoDir = Join-Path $PSScriptRoot "..\" -Resolve + +Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` + ForEach-Object { + Write-Output "Generating wiki page for $($result.FriendlyName)" + $result = Get-MofSchemaObject $_.FullName + + $output = "**Parameters**" + [Environment]::NewLine + [Environment]::NewLine + + foreach($property in $result.Attributes) { + $output += " - $($property.Name) ($($property.State), $($property.DataType)" + if ([string]::IsNullOrEmpty($property.ValueMap) -ne $true) { + $output += ", Allowed values: " + $property.ValueMap | ForEach-Object { + $output += $_ + ", " + } + $output = $output.TrimEnd(" ") + $output = $output.TrimEnd(",") + } + $output += ")" + [Environment]::NewLine + } + + $output += [Environment]::NewLine + $result.Documentation + + $output | Out-File -FilePath (Join-Path $OutPutPath "$($result.FriendlyName).md") -Encoding utf8 -Force + } \ No newline at end of file diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 09c494faf..1e048964c 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -59,6 +59,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 index 0d2001041..f3403eec9 100644 --- a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 +++ b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 @@ -10,10 +10,20 @@ function Get-MofSchemaObject() { FriendlyName = $null ClassName = $null Attributes = @() + Documentation = $null } + $currentComment = "" + $currentlyInCommentBlock = $false foreach($textLine in $contents) { - if ($textLine.Contains("ClassVersion") -or $textLine.Contains("ClassVersion")) { + if ($textLine.StartsWith("/*")) { + $currentlyInCommentBlock = $true + } elseif($textLine.StartsWith("*/")) { + $currentlyInCommentBlock = $false + $results.Documentation = $currentComment + } elseif($currentlyInCommentBlock -eq $true) { + $currentComment += $textLine + [Environment]::NewLine + } elseif ($textLine.Contains("ClassVersion") -or $textLine.Contains("ClassVersion")) { if ($textLine -match "ClassVersion(`"*.`")") { $start = $textLine.IndexOf("ClassVersion(`"") + 14 $end = $textLine.IndexOf("`")", $start) From ab7fd27c5133b7ef43ceb3dcd7b07cd795afd22a Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 9 Nov 2015 21:56:59 +1100 Subject: [PATCH 003/147] Updated credential handling in secure store resource --- .../MSFT_xSPSecureStoreServiceApp.psm1 | 30 ++++++--- .../MSFT_xSPSecureStoreServiceApp.schema.mof | 3 +- .../xSharePoint/xSharePoint.Global.Tests.ps1 | 1 - ...rePoint.xSPSecureStoreServiceApp.Tests.ps1 | 62 +++++++++++++++++++ 4 files changed, 84 insertions(+), 12 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.psm1 index a27731b3c..00c48bd64 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.psm1 @@ -9,12 +9,11 @@ function Get-TargetResource [parameter(Mandatory = $true)] [System.Boolean] $AuditingEnabled, [parameter(Mandatory = $false)] [System.UInt32] $AuditlogMaxSize, [parameter(Mandatory = $false)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabasePassword, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.String] $DatabaseUsername, [parameter(Mandatory = $false)] [System.String] $FailoverDatabaseServer, [parameter(Mandatory = $false)] [System.Boolean] $PartitionMode, [parameter(Mandatory = $false)] [System.Boolean] $Sharing, + [parameter(Mandatory = $false)] [ValidateSet("Windows", "SQL")] [System.String] $DatabaseAuthenticationType, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -23,7 +22,6 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue if ($null -eq $serviceApps) { @@ -58,12 +56,11 @@ function Set-TargetResource [parameter(Mandatory = $true)] [System.Boolean] $AuditingEnabled, [parameter(Mandatory = $false)] [System.UInt32] $AuditlogMaxSize, [parameter(Mandatory = $false)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabasePassword, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.String] $DatabaseUsername, [parameter(Mandatory = $false)] [System.String] $FailoverDatabaseServer, [parameter(Mandatory = $false)] [System.Boolean] $PartitionMode, [parameter(Mandatory = $false)] [System.Boolean] $Sharing, + [parameter(Mandatory = $false)] [ValidateSet("Windows", "SQL")] [System.String] $DatabaseAuthenticationType, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -71,11 +68,19 @@ function Set-TargetResource $result = Get-TargetResource @PSBoundParameters $params = $PSBoundParameters + if((($params.ContainsKey("DatabaseAuthenticationType") -eq $true) -and ` + ($params.ContainsKey("DatabaseCredentials") -eq $false)) -or ` + (($params.ContainsKey("DatabaseCredentials") -eq $true) -and ` + ($params.ContainsKey("DatabaseAuthenticationType") -eq $false))) { + throw "Where DatabaseCredentials are specified you must also specify DatabaseAuthenticationType to identify the type of credentials being passed" + return; + } + switch((Get-xSharePointInstalledProductVersion).FileMajorPart) { 16 { $hasOptionalParams = $false - @("AuditlogMaxSize","DatabaseName","DatabasePassword","DatabaseServer","DatabaseUsername", ` - "FailoverDatabaseServer","PartitionMode","Sharing","DatabaseCredentials") | ForEach-Object { + @("AuditlogMaxSize","DatabaseName","DatabaseServer","FailoverDatabaseServer",` + "PartitionMode","Sharing","DatabaseCredentials") | ForEach-Object { if ($PSBoundParameters.ContainsKey($_) -eq $true) { $hasOptionalParams = $true } } if ($hasOptionalParams -eq $false) { @@ -92,6 +97,14 @@ function Set-TargetResource if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } + if($params.ContainsKey("DatabaseAuthenticationType")) { + if ($params.DatabaseAuthenticationType -eq "SQL") { + $params.Add("DatabaseUsername", $params.DatabaseCredentials.Username) + $params.Add("DatabasePassword", (ConvertTo-SecureString $params.DatabaseCredentials.GetNetworkCredential().Password -AsPlainText -Force)) + } + $params.Remove("DatabaseAuthenticationType") + } + New-SPSecureStoreServiceApplication @params | New-SPSecureStoreServiceApplicationProxy -Name "$($params.Name) Proxy" } } else { @@ -130,12 +143,11 @@ function Test-TargetResource [parameter(Mandatory = $true)] [System.Boolean] $AuditingEnabled, [parameter(Mandatory = $false)] [System.UInt32] $AuditlogMaxSize, [parameter(Mandatory = $false)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabasePassword, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.String] $DatabaseUsername, [parameter(Mandatory = $false)] [System.String] $FailoverDatabaseServer, [parameter(Mandatory = $false)] [System.Boolean] $PartitionMode, [parameter(Mandatory = $false)] [System.Boolean] $Sharing, + [parameter(Mandatory = $false)] [ValidateSet("Windows", "SQL")] [System.String] $DatabaseAuthenticationType, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof index 6e45de4e7..86f8c38ac 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof @@ -25,9 +25,8 @@ class MSFT_xSPSecureStoreServiceApp : OMI_BaseResource [Write] uint32 AuditlogMaxSize; [Write, EmbeddedInstance("MSFT_Credential")] String DatabaseCredentials; [Write] string DatabaseName; - [Write] string DatabasePassword; [Write] string DatabaseServer; - [Write] string DatabaseUsername; + [Write, ValueMap {"Windows","SQL"}, Value{"Windows","SQL"}] string DatabaseAuthenticationType; [Write] string FailoverDatabaseServer; [Write] boolean PartitionMode; [Write] boolean Sharing; diff --git a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 index cfe9684bf..88a73b344 100644 --- a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 @@ -2,7 +2,6 @@ param( [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) - $ErrorActionPreference = 'stop' Set-StrictMode -Version latest diff --git a/Tests/xSharePoint/xSharePoint.xSPSecureStoreServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSecureStoreServiceApp.Tests.ps1 index 4dd73048c..c3459ad80 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSecureStoreServiceApp.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSecureStoreServiceApp.Tests.ps1 @@ -151,5 +151,67 @@ Describe "xSPSecureStoreServiceApp" { { Set-TargetResource @testParams } | Should Throw } } + + Context "When specific windows credentials are to be used for the database" { + $testParams = @{ + Name = "Secure Store Service Application" + ApplicationPool = "SharePoint Search Services" + AuditingEnabled = $false + DatabaseName = "SP_ManagedMetadata" + DatabaseCredentials = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + DatabaseAuthenticationType = "Windows" + } + + Mock Get-SPServiceApplication { return $null } + Mock New-SPSecureStoreServiceApplication { } + Mock New-SPSecureStoreServiceApplicationProxy { } + + It "allows valid Windows credentials can be passed" { + Set-TargetResource @testParams + Assert-MockCalled New-SPSecureStoreServiceApplication + } + + It "throws an exception if database authentication type is not specified" { + $testParams.Remove("DatabaseAuthenticationType") + { Set-TargetResource @testParams } | Should Throw + } + + It "throws an exception if the credentials aren't provided and the authentication type is set" { + $testParams.Add("DatabaseAuthenticationType", "Windows") + $testParams.Remove("DatabaseCredentials") + { Set-TargetResource @testParams } | Should Throw + } + } + + Context "When specific SQL credentials are to be used for the database" { + $testParams = @{ + Name = "Secure Store Service Application" + ApplicationPool = "SharePoint Search Services" + AuditingEnabled = $false + DatabaseName = "SP_ManagedMetadata" + DatabaseCredentials = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + DatabaseAuthenticationType = "SQL" + } + + Mock Get-SPServiceApplication { return $null } + Mock New-SPSecureStoreServiceApplication { } + Mock New-SPSecureStoreServiceApplicationProxy { } + + It "allows valid SQL credentials can be passed" { + Set-TargetResource @testParams + Assert-MockCalled New-SPSecureStoreServiceApplication + } + + It "throws an exception if database authentication type is not specified" { + $testParams.Remove("DatabaseAuthenticationType") + { Set-TargetResource @testParams } | Should Throw + } + + It "throws an exception if the credentials aren't provided and the authentication type is set" { + $testParams.Add("DatabaseAuthenticationType", "Windows") + $testParams.Remove("DatabaseCredentials") + { Set-TargetResource @testParams } | Should Throw + } + } } } \ No newline at end of file From 51968b53f5384e708cedd2419036e880c43ff013 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 9 Nov 2015 22:30:29 +1100 Subject: [PATCH 004/147] Fixed credential handling in usage app resource --- .../MSFT_xSPUsageApplication.psm1 | 15 +++++++-------- .../MSFT_xSPUsageApplication.schema.mof | 3 +-- .../xSharePoint.xSPusageApplication.Tests.ps1 | 8 ++++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.psm1 index 4fd51fefe..18adf7e2e 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.psm1 @@ -7,9 +7,8 @@ function Get-TargetResource [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabasePassword, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.String] $DatabaseUsername, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, [parameter(Mandatory = $false)] [System.String] $FailoverDatabaseServer, [parameter(Mandatory = $false)] [System.UInt32] $UsageLogCutTime, [parameter(Mandatory = $false)] [System.String] $UsageLogLocation, @@ -63,9 +62,8 @@ function Set-TargetResource [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabasePassword, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.String] $DatabaseUsername, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, [parameter(Mandatory = $false)] [System.String] $FailoverDatabaseServer, [parameter(Mandatory = $false)] [System.UInt32] $UsageLogCutTime, [parameter(Mandatory = $false)] [System.String] $UsageLogLocation, @@ -84,9 +82,11 @@ function Set-TargetResource $newParams = @{} $newParams.Add("Name", $params.Name) if ($params.ContainsKey("DatabaseName")) { $newParams.Add("DatabaseName", $params.DatabaseName) } - if ($params.ContainsKey("DatabasePassword")) { $newParams.Add("DatabasePassword", (ConvertTo-SecureString -String $params.DatabasePassword -AsPlainText -force)) } + if ($params.ContainsKey("DatabaseCredentials")) { + $params.Add("DatabaseUsername", $params.DatabaseCredentials.Username) + $params.Add("DatabasePassword", (ConvertTo-SecureString $params.DatabaseCredentials.GetNetworkCredential().Password -AsPlainText -Force)) + } if ($params.ContainsKey("DatabaseServer")) { $newParams.Add("DatabaseServer", $params.DatabaseServer) } - if ($params.ContainsKey("DatabaseUsername")) { $newParams.Add("DatabaseUsername", $params.DatabaseUsername) } if ($params.ContainsKey("FailoverDatabaseServer")) { $newParams.Add("FailoverDatabaseServer", $params.FailoverDatabaseServer) } New-SPUsageApplication @newParams @@ -118,9 +118,8 @@ function Test-TargetResource [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabasePassword, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.String] $DatabaseUsername, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, [parameter(Mandatory = $false)] [System.String] $FailoverDatabaseServer, [parameter(Mandatory = $false)] [System.UInt32] $UsageLogCutTime, [parameter(Mandatory = $false)] [System.String] $UsageLogLocation, diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.schema.mof index fe2377888..9b8c513e6 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUsageApplication/MSFT_xSPUsageApplication.schema.mof @@ -22,9 +22,8 @@ class MSFT_xSPUsageApplication : OMI_BaseResource [Key] string Name; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Write] string DatabaseName; - [Write] string DatabasePassword; [Write] string DatabaseServer; - [Write] string DatabaseUsername; + [Write, EmbeddedInstance("MSFT_Credential")] String DatabaseCredentials; [Write] string FailoverDatabaseServer; [Write] uint32 UsageLogCutTime; [Write] string UsageLogLocation; diff --git a/Tests/xSharePoint/xSharePoint.xSPusageApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPusageApplication.Tests.ps1 index b95d44197..702e12bda 100644 --- a/Tests/xSharePoint/xSharePoint.xSPusageApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPusageApplication.Tests.ps1 @@ -22,8 +22,6 @@ Describe "xSPUsageApplication" { UsageLogMaxSpaceGB = 10 DatabaseName = "SP_Usage" DatabaseServer = "sql.test.domain" - DatabaseUsername = "user" - DatabasePassword = "password" FailoverDatabaseServer = "anothersql.test.domain" } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -60,6 +58,12 @@ Describe "xSPUsageApplication" { Set-TargetResource @testParams Assert-MockCalled New-SPUsageApplication } + + It "creates a new service application with custom database credentials" { + $testParams.Add("DatabaseCredentials", (New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString "password" -AsPlainText -Force)))) + Set-TargetResource @testParams + Assert-MockCalled New-SPUsageApplication + } } Context "When service applications exist in the current farm but not the specific usage service app" { From 54402cf6f637e8cf1f110b775540af5f5bbb3abe Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Wed, 11 Nov 2015 13:45:03 +1100 Subject: [PATCH 005/147] Updated Prereqs for SP2016 preview --- .../MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 | 8 +++++++- .../MSFT_xSPInstallPrereqs.schema.mof | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 index e65b8e4da..6dbbc15fa 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 @@ -19,6 +19,8 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $WCFDataServices56, [parameter(Mandatory = $false)] [System.String] $KB2898850, [parameter(Mandatory = $false)] [System.String] $MSVCRT12, + [parameter(Mandatory = $false)] [System.String] $ODBC, + [parameter(Mandatory = $false)] [System.String] $DotNet452, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) @@ -101,6 +103,8 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $WCFDataServices56, [parameter(Mandatory = $false)] [System.String] $KB2898850, [parameter(Mandatory = $false)] [System.String] $MSVCRT12, + [parameter(Mandatory = $false)] [System.String] $ODBC, + [parameter(Mandatory = $false)] [System.String] $DotNet452, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) @@ -117,7 +121,7 @@ function Set-TargetResource } if ($majorVersion -eq 16) { Write-Verbose -Message "Version: SharePoint 2016" - $requiredParams = @("SQLNCli","Sync","AppFabric","IDFX11","MSIPCClient","WCFDataServices","KB2671763","WCFDataServices56","KB2898850","MSVCRT12") + $requiredParams = @("SQLNCli","Sync","AppFabric","IDFX11","MSIPCClient","WCFDataServices","KB2671763","WCFDataServices56","KB2898850","MSVCRT12","ODBC","DotNet452") } $prereqArgs = "/unattended" @@ -183,6 +187,8 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $WCFDataServices56, [parameter(Mandatory = $false)] [System.String] $KB2898850, [parameter(Mandatory = $false)] [System.String] $MSVCRT12, + [parameter(Mandatory = $false)] [System.String] $ODBC, + [parameter(Mandatory = $false)] [System.String] $DotNet452, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.schema.mof index e68494f0f..6d500e2b1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.schema.mof @@ -61,6 +61,8 @@ class MSFT_xSPInstallPrereqs : OMI_BaseResource [Write] String WCFDataServices56; [Write] String KB2898850; [Write] String MSVCRT12; + [Write] String ODBC; + [Write] String DotNet452; [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; }; From 32298a8cbacb9783fb25f99ad632951536749295 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Wed, 11 Nov 2015 13:49:10 +1100 Subject: [PATCH 006/147] Updated tests based on actual prereqs --- Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 index e66f9f35c..3722b6f72 100644 --- a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 @@ -157,7 +157,7 @@ Describe "xSPInstallPrereqs" { $requiredParams = @("SQLNCli","PowerShell","NETFX","IDFX","Sync","AppFabric","IDFX11","MSIPCClient","WCFDataServices","KB2671763","WCFDataServices56") } if ($majorBuildNumber -eq 16) { - $requiredParams = @("SQLNCli","Sync","AppFabric","IDFX11","MSIPCClient","WCFDataServices","KB2671763","WCFDataServices56","KB2898850","MSVCRT12") + $requiredParams = @("SQLNCli","Sync","AppFabric","IDFX11","MSIPCClient","WCFDataServices","KB2671763","WCFDataServices56","KB2898850","MSVCRT12","ODBC","DotNet452") } $requiredParams | ForEach-Object { $testParams.Add($_, "C:\fake\value.exe") From 102f72a58dd566e79f0e45f2db1fb4f5b6eb6d80 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Thu, 12 Nov 2015 07:32:29 +0000 Subject: [PATCH 007/147] adding xSPPasswordChangeSettings --- .../MSFT_xSPPasswordChangeSettings.psm1 | 87 +++++++++++++++++ .../MSFT_xSPPasswordChangeSettings.schema.mof | 8 ++ Modules/xSharePoint/xSharePoint.pssproj | 3 + Tests/Tests.pssproj | 1 + ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 95 +++++++++++++++++++ 5 files changed, 194 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 new file mode 100644 index 000000000..4a14d0817 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -0,0 +1,87 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + ) + + Write-Verbose -Message "Retrieving farm wide automatic password change settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $farm = Get-SPFarm + if ($null -eq $farm ) { return $null } + return @{ + + MailAddress = $farm.PasswordChangeEmailAddress + PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime + NumberOfRetries= $farm.PasswordChangeMaximumTries + DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + ) + + Write-Verbose -Message "Updating farm wide automatic password change settings" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + <#$updateParams = @{ + PasswordChangeEmailAddress = $params.MailAddress + DaysBeforePasswordExpirationToSendEmail = $params.DaysBeforeExpiry + PasswordChangeMaximumTries = $params.NumberOfRetries + PasswordChangeGuardTime = $params.PasswordChangeWaitTimeSeconds + + }#> + $farm = Get-SPFarm + $farm.PasswordChangeEmailAddress=$params.MailAddress; + $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds + $farm.PasswordChangeMaximumTries=$params.NumberOfRetries + $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry + $farm.Update(); + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing retrieving farm wide automatic password change settings" + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("MailAddress", "DaysBeforeExpiry","PasswordChangeWaitTimeSeconds","NumberOfRetries") +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof new file mode 100644 index 000000000..f08d7a6e9 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -0,0 +1,8 @@ +[ClassVersion("1.0.0.0"), FriendlyName("xSPPasswordChangeSettings")] +class MSFT_xSPPasswordChangeSettings : OMI_BaseResource +{ + [Write] string MailAddress; + [Write] Uint32 DaysBeforeExpiry; + [Write] Uint32 PasswordChangeWaitTimeSeconds; + [Write] Uint32 NumberOfRetries; +}; diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index dd7740cee..41769a7e3 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -72,6 +72,7 @@ + @@ -103,6 +104,7 @@ + @@ -127,6 +129,7 @@ + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 09c494faf..fa1df4831 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -65,6 +65,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 new file mode 100644 index 000000000..1572305b5 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -0,0 +1,95 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPPasswordChangeSettings" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPPasswordChangeSettings" { + InModuleScope $ModuleName { + $testParams = @{ + MailAddress = "e@mail.com" + DaysBeforeExpiry = 7 + PasswordChangeWaitTimeSeconds = 60 + NumberOfRetries = 3 + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Context " Farm isn't available " { + Mock Get-SPFarm { return $null + } + + It "returns null from the get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + } + + Context " Properties already set tests " { + Mock Get-SPFarm { + return @{ + PasswordChangeEmailAddress = "e@mail.com" + DaysBeforePasswordExpirationToSendEmail = 7 + PasswordChangeGuardTime = 60 + PasswordChangeMaximumTries = 3 + } + } + + It "returns farm properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + + + Context " Properties update tests " { + Mock Get-SPFarm { + $result = @{ + PasswordChangeEmailAddress=""; + PasswordChangeGuardTime=0 + PasswordChangeMaximumTries=0 + DaysBeforePasswordExpirationToSendEmail=0 + } + $result = $result | Add-Member ScriptMethod Update { return $true} -passThru + return $result + } + + It "returns farm properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "calls the new and set methods from the set function" { + Set-TargetResource @testParams + Assert-MockCalled Get-SPFarm + } + } + + + + } +} \ No newline at end of file From 0246424f97c14d67385bfaca2f9e815c414bf247 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Thu, 12 Nov 2015 08:01:08 +0000 Subject: [PATCH 008/147] commiting removing comented out code --- .../MSFT_xSPPasswordChangeSettings.psm1 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 4a14d0817..3a1c74336 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -44,15 +44,7 @@ function Set-TargetResource Write-Verbose -Message "Updating farm wide automatic password change settings" Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - - <#$updateParams = @{ - PasswordChangeEmailAddress = $params.MailAddress - DaysBeforePasswordExpirationToSendEmail = $params.DaysBeforeExpiry - PasswordChangeMaximumTries = $params.NumberOfRetries - PasswordChangeGuardTime = $params.PasswordChangeWaitTimeSeconds - - }#> - $farm = Get-SPFarm + $farm = Get-SPFarm $farm.PasswordChangeEmailAddress=$params.MailAddress; $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds $farm.PasswordChangeMaximumTries=$params.NumberOfRetries From 8e0092f52fe7e6607302d05a74dd1ac21f13daaf Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sat, 14 Nov 2015 10:47:45 +0000 Subject: [PATCH 009/147] fixing xSPPasswordChangeSettings and adding xSPOutgoingEmailSettings --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 94 ++++++++++++++++++ .../MSFT_xSPOutgoingEmailSettings.schema.mof | 10 ++ .../MSFT_xSPPasswordChangeSettings.psm1 | 10 +- .../MSFT_xSPPasswordChangeSettings.schema.mof | 2 +- .../xSharePoint.Util/xSharePoint.Util.psm1 | 4 + Modules/xSharePoint/xSharePoint.pssproj | 3 + Tests/Tests.pssproj | 1 + ...rePoint.xSPOutgoingEmailSettings.Tests.ps1 | 99 +++++++++++++++++++ ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 39 ++++---- 9 files changed, 237 insertions(+), 25 deletions(-) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 new file mode 100644 index 000000000..124000077 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -0,0 +1,94 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + + ) + + Write-Verbose -Message "Retrieving outgoing email settings configuration " + + $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $webApp = $null + if([string]::IsNullOrEmpty($params.WebAppUrl)){ + $webApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } + }else{ + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + } + if ($null -eq $webApp ) { + throw "Web Application $webAppUrl not found" + } + return @{ + WebAppUrl = $webApp.Url + SMTPServer= $webApp.OutboundMailServiceInstance + FromAddress= $webApp.OutboundMailSenderAddress + ReplyToAddress= $webApp.OutboundMailReplyToAddress + CharacterSet = $webApp.OutboundMailCodePage + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + ) + + Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" + Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $webApp = $null + if([string]::IsNullOrEmpty($params.WebAppUrl)){ + Write-Verbose -Message "retrieving global(CA) settings" + $webApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } + }else{ + Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + } + if($null -eq $webApp) + { + throw "Web Application $webAppUrl not found" + } + $webApp.UpdateMailSettings($params.SMTPServer, $params.FromAddress, $params.ReplyToAddress, $params.CharacterSet) + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Comparing Current and Target Outgoing email settings" + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("WebAppUrl", "SMTPServer","FromAddress","ReplyToAddress","CharacterSet") +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof new file mode 100644 index 000000000..dd3663744 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -0,0 +1,10 @@ +[ClassVersion("1.0.0.0"), FriendlyName("xSPOutgoingEmailSettings")] +class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource +{ + [key] string WebAppUrl; + [Write] string SMTPServer; + [Write] string FromAddress; + [Write] string ReplyToAddress; + [Write] string CharacterSet; +}; + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 3a1c74336..196490871 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -4,8 +4,7 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $true)] [System.String] $MailAddress, [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries @@ -13,7 +12,7 @@ function Get-TargetResource Write-Verbose -Message "Retrieving farm wide automatic password change settings" - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $farm = Get-SPFarm @@ -34,7 +33,6 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $true)] [System.String] $MailAddress, [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, @@ -45,11 +43,14 @@ function Set-TargetResource Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $farm = Get-SPFarm + + if ($null -eq $farm ) { return $null } $farm.PasswordChangeEmailAddress=$params.MailAddress; $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds $farm.PasswordChangeMaximumTries=$params.NumberOfRetries $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry $farm.Update(); + } } @@ -60,7 +61,6 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $true)] [System.String] $MailAddress, [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index f08d7a6e9..48fb75dc0 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -1,7 +1,7 @@ [ClassVersion("1.0.0.0"), FriendlyName("xSPPasswordChangeSettings")] class MSFT_xSPPasswordChangeSettings : OMI_BaseResource { - [Write] string MailAddress; + [key] string MailAddress; [Write] Uint32 DaysBeforeExpiry; [Write] Uint32 PasswordChangeWaitTimeSeconds; [Write] Uint32 NumberOfRetries; diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index fa7b44dc9..0915b5557 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -26,6 +26,10 @@ function Get-xSharePointAssemblyVersion() { ) return (Get-Command $PathToAssembly).FileVersionInfo.FileMajorPart } +function Get-UtilAsScriptBlock(){ + $content = Get-Content (Resolve-Path .\xSharePoint.psd1) + write-host [Scriptblock]::Create($content ) +} function Get-xSharePointInstalledProductVersion() { $pathToSearch = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\*\ISAPI\Microsoft.SharePoint.dll" diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 41769a7e3..c494f1883 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -62,6 +62,7 @@ + @@ -104,6 +105,8 @@ + + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index fa1df4831..9337cc013 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -65,6 +65,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 new file mode 100644 index 000000000..5bb8d7b03 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -0,0 +1,99 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPOutgoingEmailSettings" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPOutgoingEmailSettings" { + InModuleScope $ModuleName { + $testParams = @{ + WebAppUrl = "http://sp2013.australiasoutheast.cloudapp.azure.com" + SMTPServer = "smtp.contoso.com" + FromAddress = "from@email.com" + ReplyToAddress = "reply@email.com" + CharacterSet= "65001" + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + + + Context " Web Application isn't available " { + Mock Get-SPWebApplication -MockWith { return $null + } + + It "throws exception from the get method" { + {Get-TargetResource @testParams} | Should Throw + } + + It "throws exception from the test method" { + { Test-TargetResource @testParams } | Should Throw + } + + } + + Context " Properties match" { + Mock Get-SPWebApplication { + return @{ + Url= "http://sp2013.australiasoutheast.cloudapp.azure.com" + OutboundMailServiceInstance= "smtp.contoso.com" + OutboundMailSenderAddress = "from@email.com" + OutboundMailReplyToAddress= "reply@email.com" + OutboundMailCodePage= "65001" + } + } + + It "returns web app properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + + + Context " Properties update tests " { + Mock Get-SPWebApplication { + $result = @{ + Url= "http://sp2013.australiasoutheast.cloudapp.azure.com" + OutboundMailServiceInstance= "smtp2.contoso.com" + OutboundMailSenderAddress = "from@email.com" + OutboundMailReplyToAddress= "reply@email.com" + OutboundMailCodePage= "65001" + } + $result = $result | Add-Member ScriptMethod UpdateMailSettings { + param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) + return ; +} -passThru + return $result + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "calls the new and set methods from the set function" { + Set-TargetResource @testParams + Assert-MockCalled Get-SPWebApplication + } + } + + + + } +} \ No newline at end of file diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 1572305b5..0048f3148 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -28,30 +28,31 @@ Describe "xSPPasswordChangeSettings" { Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue - Context " Farm isn't available " { + Context " Farm isn't available " { Mock Get-SPFarm { return $null - } + } It "returns null from the get method" { - Get-TargetResource @testParams | Should BeNullOrEmpty + Get-TargetResource @testParams | Should Throw } It "returns false from the test method" { - Test-TargetResource @testParams | Should Be $false + Test-TargetResource @testParams | Should be $false } } - Context " Properties already set tests " { + + Context " Properties already set tests " { Mock Get-SPFarm { - return @{ + return @{ PasswordChangeEmailAddress = "e@mail.com" DaysBeforePasswordExpirationToSendEmail = 7 PasswordChangeGuardTime = 60 PasswordChangeMaximumTries = 3 - } - } - + } + } + It "returns farm properties from the get method" { Get-TargetResource @testParams | Should Not BeNullOrEmpty } @@ -63,17 +64,17 @@ Describe "xSPPasswordChangeSettings" { } - Context " Properties update tests " { + Context " Properties update tests " { Mock Get-SPFarm { - $result = @{ - PasswordChangeEmailAddress=""; - PasswordChangeGuardTime=0 - PasswordChangeMaximumTries=0 - DaysBeforePasswordExpirationToSendEmail=0 - } - $result = $result | Add-Member ScriptMethod Update { return $true} -passThru - return $result - } + $result = @{ + PasswordChangeEmailAddress=""; + PasswordChangeGuardTime=0 + PasswordChangeMaximumTries=0 + DaysBeforePasswordExpirationToSendEmail=0 + } + $result = $result | Add-Member ScriptMethod Update { return $true} -passThru + return $result + } It "returns farm properties from the get method" { Get-TargetResource @testParams | Should Not BeNullOrEmpty From ecb3d8ad0db6513f42e4a4353b10ba79acac5be4 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sat, 14 Nov 2015 22:42:50 +0000 Subject: [PATCH 010/147] fixing formatting issues --- .../MSFT_xSPPasswordChangeSettings.psm1 | 46 +++++++++---------- .../MSFT_xSPPasswordChangeSettings.schema.mof | 2 +- .../Examples/Single Server/Caller.ps1 | 3 ++ .../xSharePoint.Util/xSharePoint.Util.psm1 | 2 +- ...rePoint.xSPOutgoingEmailSettings.Tests.ps1 | 5 +- 5 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 Modules/xSharePoint/Examples/Single Server/Caller.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 196490871..850d5fac4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -4,10 +4,10 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] [System.String] $MailAddress, - [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries ) Write-Verbose -Message "Retrieving farm wide automatic password change settings" @@ -19,10 +19,10 @@ function Get-TargetResource if ($null -eq $farm ) { return $null } return @{ - MailAddress = $farm.PasswordChangeEmailAddress - PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime - NumberOfRetries= $farm.PasswordChangeMaximumTries - DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail + MailAddress = $farm.PasswordChangeEmailAddress + PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime + NumberOfRetries= $farm.PasswordChangeMaximumTries + DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail } } return $result @@ -33,23 +33,23 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $true)] [System.String] $MailAddress, - [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries ) Write-Verbose -Message "Updating farm wide automatic password change settings" Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $farm = Get-SPFarm + $farm = Get-SPFarm - if ($null -eq $farm ) { return $null } - $farm.PasswordChangeEmailAddress=$params.MailAddress; - $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds - $farm.PasswordChangeMaximumTries=$params.NumberOfRetries - $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry - $farm.Update(); + if ($null -eq $farm ) { return $null } + $farm.PasswordChangeEmailAddress=$params.MailAddress; + $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds + $farm.PasswordChangeMaximumTries=$params.NumberOfRetries + $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry + $farm.Update(); } } @@ -61,16 +61,16 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)] [System.String] $MailAddress, - [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries - ) + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + ) $CurrentValues = Get-TargetResource @PSBoundParameters Write-Verbose -Message "Testing retrieving farm wide automatic password change settings" - if ($null -eq $CurrentValues) { return $false } - + if ($null -eq $CurrentValues) { return $false } + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("MailAddress", "DaysBeforeExpiry","PasswordChangeWaitTimeSeconds","NumberOfRetries") } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index 48fb75dc0..3ac447092 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -2,7 +2,7 @@ class MSFT_xSPPasswordChangeSettings : OMI_BaseResource { [key] string MailAddress; - [Write] Uint32 DaysBeforeExpiry; + [Write] Uint32 DaysBeforeExpiry; [Write] Uint32 PasswordChangeWaitTimeSeconds; [Write] Uint32 NumberOfRetries; }; diff --git a/Modules/xSharePoint/Examples/Single Server/Caller.ps1 b/Modules/xSharePoint/Examples/Single Server/Caller.ps1 new file mode 100644 index 000000000..8b65a099b --- /dev/null +++ b/Modules/xSharePoint/Examples/Single Server/Caller.ps1 @@ -0,0 +1,3 @@ +# +# Caller.ps1 +# diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 0915b5557..e1874bbaf 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -28,7 +28,7 @@ function Get-xSharePointAssemblyVersion() { } function Get-UtilAsScriptBlock(){ $content = Get-Content (Resolve-Path .\xSharePoint.psd1) - write-host [Scriptblock]::Create($content ) + write-host [Scriptblock]::Create($content ) } function Get-xSharePointInstalledProductVersion() { diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index 5bb8d7b03..7b049d724 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -77,9 +77,8 @@ Describe "xSPOutgoingEmailSettings" { OutboundMailCodePage= "65001" } $result = $result | Add-Member ScriptMethod UpdateMailSettings { - param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) - return ; -} -passThru + param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) + return ; } -passThru return $result } From 00509bd4a39b0ce9664254e1bef0c50e75bcf866 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 18:35:00 +1100 Subject: [PATCH 011/147] First cut of search roles resource --- .../MSFT_xSPSearchRoles.psm1 | 242 +++++++++++++++++ .../MSFT_xSPSearchRoles.schema.mof | 17 ++ Tests/Tests.pssproj | 1 + .../xSharePoint.xSPSearchRoles.Tests.ps1 | 247 ++++++++++++++++++ 4 files changed, 507 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 new file mode 100644 index 000000000..dfbeab730 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 @@ -0,0 +1,242 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $ServiceAppName, + [parameter(Mandatory = $true)] [System.Boolean] $Admin, + [parameter(Mandatory = $true)] [System.Boolean] $Crawler, + [parameter(Mandatory = $true)] [System.Boolean] $ContentProcessing, + [parameter(Mandatory = $true)] [System.Boolean] $AnalyticsProcessing, + [parameter(Mandatory = $true)] [System.Boolean] $QueryProcessing, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.UInt32] $FirstPartitionIndex, + [parameter(Mandatory = $true)] [System.String] $FirstPartitionDirectory, + [parameter(Mandatory = $true)] [System.String] $FirstPartitionServers + ) + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $ConfirmPreference = 'None' + + $AdminExists = $false; + $CrawlerExists = $false; + $ContentProcessingExists = $false; + $AnalyticsProcessingExists = $false; + $QueryProcessingExists = $false; + + $ssi = Get-SPEnterpriseSearchServiceInstance -Identity $env:COMPUTERNAME + $ssa = Get-SPEnterpriseSearchServiceApplication + if($ssi.Status -eq "Offline") { + Write-Verbose "Search is offline" + return @{ + ServiceAppName = $params.ServiceAppName + Admin = $false + Crawler = $false + ContentProcessing = $false + AnalyticsProcessing = $false + QueryProcessing = $false + InstallAccount = $params.InstallAccount + FirstPartitionIndex = $params.FirstPartitionIndex + FirstPartitionDirectory = $params.FirstPartitionDirectory + FirstPartitionServers = $params.FirstPartitionServers + Ensure = $params.Ensure + } + } + $currentTopology = $ssa.ActiveTopology + + #Make sure what we expect to be there is + $AdminComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "AdminComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if($AdminComponent1) { + $AdminExists = $true + } + $CrawlComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "CrawlComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if($CrawlComponent1) { + $CrawlerExists = $true + } + $ContentProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "ContentProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if($ContentProcessingComponent1) { + $ContentProcessingExists = $true + } + $AnalyticsProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "AnalyticsProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if($AnalyticsProcessingComponent1) { + $AnalyticsProcessingExists = $true + } + $QueryProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "QueryProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if($QueryProcessingComponent1) { + $QueryProcessingExists = $true + } + + return @{ + ServiceAppName = $params.ServiceAppName + Admin = $AdminExists + Crawler = $CrawlerExists + ContentProcessing = $ContentProcessingExists + AnalyticsProcessing = $AnalyticsProcessingExists + QueryProcessing = $QueryProcessingExists + InstallAccount = $params.InstallAccount + FirstPartitionIndex = $params.FirstPartitionIndex + FirstPartitionDirectory = $params.FirstPartitionDirectory + FirstPartitionServers = $params.FirstPartitionServers + Ensure = $params.Ensure + } + } + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $ServiceAppName, + [parameter(Mandatory = $true)] [System.Boolean] $Admin, + [parameter(Mandatory = $true)] [System.Boolean] $Crawler, + [parameter(Mandatory = $true)] [System.Boolean] $ContentProcessing, + [parameter(Mandatory = $true)] [System.Boolean] $AnalyticsProcessing, + [parameter(Mandatory = $true)] [System.Boolean] $QueryProcessing, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.UInt32] $FirstPartitionIndex, + [parameter(Mandatory = $true)] [System.String] $FirstPartitionDirectory, + [parameter(Mandatory = $true)] [System.String] $FirstPartitionServers + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters, $CurrentValues) -ScriptBlock { + $params = $args[0] + $CurrentValues = $args[1] + $ConfirmPreference = 'None' + + $ssi = Get-SPEnterpriseSearchServiceInstance -Local + $ssa = Get-SPEnterpriseSearchServiceApplication + + if($ssi.Status -eq "Offline") { + Write-Verbose "Start Search Service Instance" + Start-SPEnterpriseSearchServiceInstance -Identity $ssi + } + + #Wait for Search Service Instance to come online + $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; + do { + $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; + Write-Verbose "Waiting for service: $($online.TypeName)" + } + until ($online.Status -eq "Online") + + $currentTopology = $ssa.ActiveTopology + $newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $currentTopology + + + if ($params.Ensure -eq "Present") { + if($CurrentValues.Admin -eq $false -and $params.Admin -eq $true) { + New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology ` + -SearchServiceInstance $ssi + } + if($CurrentValues.Crawler -eq $false -and $params.Crawler -eq $true) { + New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology ` + -SearchServiceInstance $ssi + } + if($CurrentValues.ContentProcessing -eq $false -and $params.ContentProcessing -eq $true) { + New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology ` + -SearchServiceInstance $ssi + } + if($CurrentValues.AnalyticsProcessing -eq $false -and $params.AnalyticsProcessing -eq $true) { + New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology ` + -SearchServiceInstance $ssi + } + if($CurrentValues.QueryProcessing -eq $false -and $params.QueryProcessing -eq $true) { + New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology ` + -SearchServiceInstance $ssi + } + + $IndexComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object { + ($_.GetType().Name -ccontains "IndexComponent") + } + + #Add the First search index if no other indexes already exist required + if($null -eq $IndexComponent1) { + Write-Verbose "Adding First search indedx at partition $($params.FirstPartitionIndex)" + + $servers = $params.FirstPartitionServers.Split(',', [StringSplitOptions]::RemoveEmptyEntries) + foreach($server in $servers) { + $InvokeCommandArgs = @{ + ArgumentList = @($params.FirstPartitionDirectory) + } + $session = New-PSSession -ComputerName $server -Name "Microsoft.SharePoint.DSC.SearchRolesSetup" -SessionOption (New-PSSessionOption -OperationTimeout 0 -IdleTimeout 60000) + if ($null -ne $session) { $InvokeCommandArgs.Add("Session", $session) } + Invoke-Command @InvokeCommandArgs -ScriptBlock { + New-Item $args[0] -ItemType Directory -Force + } + $indexSsi = Get-SPEnterpriseSearchServiceInstance -Identity $server + if($indexSsi.Status -eq "Offline") { + Write-Verbose "Start Search Service Instance" + Start-SPEnterpriseSearchServiceInstance -Identity $indexSsi + } + $online = Get-SPEnterpriseSearchServiceInstance -Identity $indexSsi + do { + $online = Get-SPEnterpriseSearchServiceInstance -Identity $indexSsi + Write-Verbose "Waiting for service: $($online.TypeName)" + } + until ($online.Status -eq "Online") + New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $indexSsi -IndexPartition $params.FirstPartitionIndex -RootDirectory $params.FirstPartitionDirectory + } + } + Set-SPEnterpriseSearchTopology -Identity $newTopology + } else { + $AdminComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "AdminComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if (($params.Admin -eq $false) -and ($null -ne $AdminComponent1)) { + Remove-SPEnterpriseSearchComponent -Identity $AdminComponent1.ComponentId -SearchTopology $newTopology -confirm:$false + } + $CrawlComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "CrawlComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if (($params.Crawler -eq $false) -and ($null -ne $CrawlComponent1)) { + Remove-SPEnterpriseSearchComponent -Identity $CrawlComponent1.ComponentId -SearchTopology $newTopology -confirm:$false + } + $ContentProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "ContentProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if (($params.ContentProcessing -eq $false) -and ($null -ne $ContentProcessingComponent1)) { + Remove-SPEnterpriseSearchComponent -Identity $ContentProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false + } + $AnalyticsProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "AnalyticsProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if (($params.AnalyticsProcessing -eq $false) -and ($null -ne $AnalyticsProcessingComponent1)) { + Remove-SPEnterpriseSearchComponent -Identity $AnalyticsProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false + } + $QueryProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "QueryProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + if (($params.QueryProcessing -eq $false) -and ($null -ne $QueryProcessingComponent1)) { + Remove-SPEnterpriseSearchComponent -Identity $QueryProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false + } + + Set-SPEnterpriseSearchTopology -Identity $newTopology + } + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $ServiceAppName, + [parameter(Mandatory = $true)] [System.Boolean] $Admin, + [parameter(Mandatory = $true)] [System.Boolean] $Crawler, + [parameter(Mandatory = $true)] [System.Boolean] $ContentProcessing, + [parameter(Mandatory = $true)] [System.Boolean] $AnalyticsProcessing, + [parameter(Mandatory = $true)] [System.Boolean] $QueryProcessing, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.UInt32] $FirstPartitionIndex, + [parameter(Mandatory = $true)] [System.String] $FirstPartitionDirectory, + [parameter(Mandatory = $true)] [System.String] $FirstPartitionServers + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Ensure", "Admin", "Crawler", "ContentProcessing", "AnalyticsProcessing", "QueryProcessing") +} + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof new file mode 100644 index 000000000..3653c5439 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof @@ -0,0 +1,17 @@ +/* +*/ +[ClassVersion("1.0.0.0"), FriendlyName("xSPSearchRoles")] +class MSFT_xSPSearchRoles : OMI_BaseResource +{ + [Key] String ServiceAppName; + [Required] Boolean Admin; + [Required] Boolean Crawler; + [Required] Boolean ContentProcessing; + [Required] Boolean AnalyticsProcessing; + [Required] Boolean QueryProcessing; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; + [Write] Uint32 FirstPartitionIndex; + [Write] String FirstPartitionDirectory; + [Write] String FirstPartitionServers; +}; \ No newline at end of file diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 1e048964c..a28603460 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -66,6 +66,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 new file mode 100644 index 000000000..90ddb862d --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 @@ -0,0 +1,247 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPSearchRoles" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPSearchRoles" { + InModuleScope $ModuleName { + $testParams = @{ + ServiceAppName = "Search Service Application" + Admin = $true + Crawler = $true + ContentProcessing = $true + AnalyticsProcessing = $true + QueryProcessing = $true + Ensure = "Present" + FirstPartitionIndex = "0" + FirstPartitionDirectory = "C:\ExamplePath" + FirstPartitionServers = $env:COMPUTERNAME + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + Mock New-PSSession { + return $null + } + Mock New-Item { return @{} } + Mock Get-SPEnterpriseSearchServiceInstance { + return @{ + Server = @{ + Address = $env:COMPUTERNAME + } + Status = "Online" + } + } + Mock Get-SPEnterpriseSearchServiceApplication { + return @{ + ActiveTopology = @{} + } + } + + Add-Type -TypeDefinition "public class AdminComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class CrawlComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class ContentProcessingComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class AnalyticsProcessingComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class QueryProcessingComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + + $adminComponent = New-Object AdminComponent1 + $adminComponent.ServerName = $env:COMPUTERNAME + $adminComponent.ComponentId = [Guid]::NewGuid() + + $crawlComponent = New-Object CrawlComponent1 + $crawlComponent.ServerName = $env:COMPUTERNAME + $crawlComponent.ComponentId = [Guid]::NewGuid() + + $contentProcessingComponent = New-Object ContentProcessingComponent1 + $contentProcessingComponent.ServerName = $env:COMPUTERNAME + $contentProcessingComponent.ComponentId = [Guid]::NewGuid() + + $analyticsProcessingComponent = New-Object AnalyticsProcessingComponent1 + $analyticsProcessingComponent.ServerName = $env:COMPUTERNAME + $analyticsProcessingComponent.ComponentId = [Guid]::NewGuid() + + $queryProcessingComponent = New-Object QueryProcessingComponent1 + $queryProcessingComponent.ServerName = $env:COMPUTERNAME + $queryProcessingComponent.ComponentId = [Guid]::NewGuid() + + Mock Start-SPEnterpriseSearchServiceInstance { return $null } + Mock New-SPEnterpriseSearchTopology { return @{} } + Mock New-SPEnterpriseSearchAdminComponent { return @{} } + Mock New-SPEnterpriseSearchCrawlComponent { return @{} } + Mock New-SPEnterpriseSearchContentProcessingComponent { return @{} } + Mock New-SPEnterpriseSearchAnalyticsProcessingComponent { return @{} } + Mock New-SPEnterpriseSearchQueryProcessingComponent { return @{} } + Mock New-SPEnterpriseSearchIndexComponent { return @{} } + Mock Set-SPEnterpriseSearchTopology { return @{} } + Mock Remove-SPEnterpriseSearchComponent { return $null } + + Context "No search topology has been applied" { + Mock Get-SPEnterpriseSearchComponent { + return @{} + } + + It "returns false values from the get method" { + $result = Get-TargetResource @testParams + $result.Admin | Should Be $false + $result.Crawler | Should Be $false + $result.ContentProcessing | Should Be $false + $result.AnalyticsProcessing | Should Be $false + $result.QueryProcessing | Should Be $false + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "sets the desired topology for the current server" { + Set-TargetResource @testParams + } + } + + Context "No search topology exist and the search service instance isnt running" { + Mock Get-SPEnterpriseSearchComponent { + return @{} + } + $Global:xSharePointSearchRoleInstanceCalLCount = 0 + Mock Get-SPEnterpriseSearchServiceInstance { + if ($Global:xSharePointSearchRoleInstanceCalLCount -eq 2) { + $Global:xSharePointSearchRoleInstanceCalLCount = 0 + return @{ + Status = "Online" + } + } else { + $Global:xSharePointSearchRoleInstanceCalLCount++ + return @{ + Status = "Offline" + } + } + } + + It "sets the desired topology for the current server and starts the search service instance" { + Set-TargetResource @testParams + Assert-MockCalled Start-SPEnterpriseSearchServiceInstance + } + + } + + Context "A search topology has been applied but it is not correct" { + + Mock Get-SPEnterpriseSearchServiceInstance { + return @{ + Server = @{ + Address = $env:COMPUTERNAME + } + Status = "Online" + } + } + + It "adds a missing admin component" { + Mock Get-SPEnterpriseSearchComponent { + return @($crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) + } + Set-TargetResource @testParams + Assert-MockCalled New-SPEnterpriseSearchAdminComponent + } + + It "adds a missing crawl component" { + Mock Get-SPEnterpriseSearchComponent { + return @($adminComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) + } + Set-TargetResource @testParams + Assert-MockCalled New-SPEnterpriseSearchCrawlComponent + } + + It "adds a missing content processing component" { + Mock Get-SPEnterpriseSearchComponent { + return @($adminComponent, $crawlComponent, $analyticsProcessingComponent, $queryProcessingComponent) + } + Set-TargetResource @testParams + Assert-MockCalled New-SPEnterpriseSearchContentProcessingComponent + } + + It "adds a missing analytics processing component" { + Mock Get-SPEnterpriseSearchComponent { + return @($adminComponent, $crawlComponent, $contentProcessingComponent, $queryProcessingComponent) + } + Set-TargetResource @testParams + Assert-MockCalled New-SPEnterpriseSearchAnalyticsProcessingComponent + } + + It "adds a missing query processing component" { + Mock Get-SPEnterpriseSearchComponent { + return @($adminComponent, $crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent) + } + Set-TargetResource @testParams + Assert-MockCalled New-SPEnterpriseSearchQueryProcessingComponent + } + + $testParams = @{ + ServiceAppName = "Search Service Application" + Admin = $false + Crawler = $false + ContentProcessing = $false + AnalyticsProcessing = $false + QueryProcessing = $false + Ensure = "Absent" + FirstPartitionIndex = "0" + FirstPartitionDirectory = "C:\ExamplePath" + FirstPartitionServers = $env:COMPUTERNAME + } + + Mock Get-SPEnterpriseSearchComponent { + return @($adminComponent, $crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) + } + + It "Removes components that shouldn't be on this server" { + Set-TargetResource @testParams + Assert-MockCalled Remove-SPEnterpriseSearchComponent -Times 5 + } + + + } + + Context "The correct topology on this server exists" { + Mock Get-SPEnterpriseSearchComponent { + return @($adminComponent, $crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) + } + + Mock Get-SPEnterpriseSearchServiceInstance { + return @{ + Server = @{ + Address = $env:COMPUTERNAME + } + Status = "Online" + } + } + + $testParams = @{ + ServiceAppName = "Search Service Application" + Admin = $true + Crawler = $true + ContentProcessing = $true + AnalyticsProcessing = $true + QueryProcessing = $true + Ensure = "Present" + FirstPartitionIndex = "0" + FirstPartitionDirectory = "C:\ExamplePath" + FirstPartitionServers = $env:COMPUTERNAME + } + + It "returns true from the test method" { + Test-TargetResource @testParams -Verbose | Should Be $true + } + } + } +} \ No newline at end of file From 3b406a654169d5f94943692fe494905e2402397c Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 18:35:51 +1100 Subject: [PATCH 012/147] Fixed bug where InstallAccount isn't ignored in property check --- .../Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index fa7b44dc9..00d906fd2 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -38,7 +38,7 @@ function Invoke-xSharePointCommand() { param ( [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $Credential, - [parameter(Mandatory = $false)] [HashTable] $Arguments, + [parameter(Mandatory = $false)] [Object[]] $Arguments, [parameter(Mandatory = $true)] [ScriptBlock] $ScriptBlock ) @@ -154,7 +154,7 @@ function Test-xSharePointSpecificParameters() { } $KeyList | ForEach-Object { - if ($_ -ne "Verbose") { + if (($_ -ne "Verbose") -or ($_ -ne "InstallAccount")) { if (($CurrentValues.ContainsKey($_) -eq $false) -or ($CurrentValues.$_ -ne $DesiredValues.$_)) { if ($DesiredValues.ContainsKey($_)) { $desiredType = $DesiredValues.$_.GetType() @@ -177,7 +177,6 @@ function Test-xSharePointSpecificParameters() { } } } - } return $returnValue } From 26f04d897a466a01592b01bdd4b4ce85036d42e9 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 18:36:48 +1100 Subject: [PATCH 013/147] Fixed typo in MOF schema --- .../MSFT_xSPSecureStoreServiceApp.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof index 86f8c38ac..083cc00d7 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof @@ -26,7 +26,7 @@ class MSFT_xSPSecureStoreServiceApp : OMI_BaseResource [Write, EmbeddedInstance("MSFT_Credential")] String DatabaseCredentials; [Write] string DatabaseName; [Write] string DatabaseServer; - [Write, ValueMap {"Windows","SQL"}, Value{"Windows","SQL"}] string DatabaseAuthenticationType; + [Write, ValueMap {"Windows","SQL"}, Values{"Windows","SQL"}] string DatabaseAuthenticationType; [Write] string FailoverDatabaseServer; [Write] boolean PartitionMode; [Write] boolean Sharing; From 61057305d7de5b8368019e18a2d3cc5ed8561175 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 18:37:21 +1100 Subject: [PATCH 014/147] Formatting fixes --- .../MSFT_xSPSearchRoles.psm1 | 4 +-- .../xSharePoint.xSPSearchRoles.Tests.ps1 | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 index dfbeab730..6da016658 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 @@ -42,7 +42,7 @@ function Get-TargetResource FirstPartitionIndex = $params.FirstPartitionIndex FirstPartitionDirectory = $params.FirstPartitionDirectory FirstPartitionServers = $params.FirstPartitionServers - Ensure = $params.Ensure + Ensure = $params.Ensure } } $currentTopology = $ssa.ActiveTopology @@ -80,7 +80,7 @@ function Get-TargetResource FirstPartitionIndex = $params.FirstPartitionIndex FirstPartitionDirectory = $params.FirstPartitionDirectory FirstPartitionServers = $params.FirstPartitionServers - Ensure = $params.Ensure + Ensure = $params.Ensure } } return $result diff --git a/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 index 90ddb862d..30bc87fcc 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 @@ -213,20 +213,20 @@ Describe "xSPSearchRoles" { } Context "The correct topology on this server exists" { - Mock Get-SPEnterpriseSearchComponent { + Mock Get-SPEnterpriseSearchComponent { return @($adminComponent, $crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) } - Mock Get-SPEnterpriseSearchServiceInstance { - return @{ - Server = @{ - Address = $env:COMPUTERNAME - } - Status = "Online" - } - } + Mock Get-SPEnterpriseSearchServiceInstance { + return @{ + Server = @{ + Address = $env:COMPUTERNAME + } + Status = "Online" + } + } - $testParams = @{ + $testParams = @{ ServiceAppName = "Search Service Application" Admin = $true Crawler = $true @@ -239,9 +239,9 @@ Describe "xSPSearchRoles" { FirstPartitionServers = $env:COMPUTERNAME } - It "returns true from the test method" { - Test-TargetResource @testParams -Verbose | Should Be $true - } - } + It "returns true from the test method" { + Test-TargetResource @testParams -Verbose | Should Be $true + } + } } } \ No newline at end of file From 2181dae67b68cc7e66246560490a672729deb1de Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 19:09:06 +1100 Subject: [PATCH 015/147] Updated DCache tests to reflect recent fix to setting memory size --- ...Point.xSPDistributedCacheService.Tests.ps1 | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPDistributedCacheService.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPDistributedCacheService.Tests.ps1 index 668ee24db..450ce8645 100644 --- a/Tests/xSharePoint/xSharePoint.xSPDistributedCacheService.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPDistributedCacheService.Tests.ps1 @@ -53,11 +53,33 @@ Describe "xSPDistributedCacheService" { Add-Member ScriptMethod Update {} -PassThru | Add-Member ScriptMethod Deploy {} -PassThru }) - } } + } } + Mock Stop-SPServiceInstance { $Global:xSharePointDCacheOnline = $false } + Mock Start-SPServiceInstance { $Global:xSharePointDCacheOnline = $true } + + Mock Get-SPServiceInstance { + if ($Global:xSharePointDCacheOnline -eq $false) { + return @(New-Object Object | + Add-Member NoteProperty TypeName "Distributed Cache" -PassThru | + Add-Member NoteProperty Status "Disabled" -PassThru | + Add-Member NoteProperty Service "SPDistributedCacheService Name=AppFabricCachingService" -PassThru | + Add-Member NoteProperty Server @{ Name = $env:COMPUTERNAME } -PassThru | + Add-Member ScriptMethod Delete {} -PassThru) + } else { + return @(New-Object Object | + Add-Member NoteProperty TypeName "Distributed Cache" -PassThru | + Add-Member NoteProperty Status "Online" -PassThru | + Add-Member NoteProperty Service "SPDistributedCacheService Name=AppFabricCachingService" -PassThru | + Add-Member NoteProperty Server @{ Name = $env:COMPUTERNAME } -PassThru | + Add-Member ScriptMethod Delete {} -PassThru) + } + + } Context "Distributed cache is not configured" { Mock Use-CacheCluster { throw [Exception] "ERRPS001 Error in reading provider and connection string values." } - + $Global:xSharePointDCacheOnline = $false + It "returns null from the get method" { (Get-TargetResource @testParams).Ensure | Should Be "Absent" } @@ -73,6 +95,8 @@ Describe "xSPDistributedCacheService" { } Context "Distributed cache is configured correctly and running as required" { + $Global:xSharePointDCacheOnline = $true + Mock Get-AFCacheHostConfiguration { return @{ Size = $testParams.CacheSizeInMB }} @@ -84,6 +108,7 @@ Describe "xSPDistributedCacheService" { } Context "Distributed cache is configured but the required firewall rules are not deployed" { + $Global:xSharePointDCacheOnline = $true Mock Get-NetFirewallRule { return $null } It "returns false from the test method" { @@ -97,17 +122,13 @@ Describe "xSPDistributedCacheService" { } Context "Distributed cache is confgured but should not be running on this machine" { + $Global:xSharePointDCacheOnline = $true $testParams.Ensure = "Absent" Mock Get-AFCacheHostConfiguration { return @{ Size = $testParams.CacheSizeInMB }} Mock Get-CacheHost { return @{ PortNo = 22233 } } Mock Get-NetFirewallRule { return @{} } - Mock Get-SPServiceInstance { return @(New-Object Object | - Add-Member NoteProperty Service "SPDistributedCacheService Name=AppFabricCachingService" -PassThru | - Add-Member NoteProperty Server @{ Name = $env:COMPUTERNAME } -PassThru | - Add-Member ScriptMethod Delete {} -PassThru - )} Mock Remove-SPDistributedCacheServiceInstance { } It "returns false from the test method" { From 76a191a73be016cb0cda0ac91e6ff42d7f6474dd Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 19:13:33 +1100 Subject: [PATCH 016/147] Add code coverage for ServerRole parameter --- .../xSharePoint.xSPJoinFarm.Tests.ps1 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 index 91d3d969e..81e26a8bf 100644 --- a/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 @@ -71,6 +71,26 @@ Describe "xSPJoinFarm" { } } + if ($majorBuildNumber -eq 15) { + $testParams.Add("ServerRole", "WebFrontEnd") + + Context "only valid parameters for SharePoint 2013 are used" { + It "throws if server role is used in the get method" { + { Get-TargetResource @testParams } | Should Throw + } + + It "throws if server role is used in the test method" { + { Test-TargetResource @testParams } | Should Throw + } + + It "throws if server role is used in the set method" { + { Set-TargetResource @testParams } | Should Throw + } + } + + $testParams.Remove("ServerRole") + } + Context "no farm is configured locally and an unsupported version of SharePoint is installed on the server" { Mock Get-xSharePointInstalledProductVersion { return @{ FileMajorPart = 14 } } From 181cf0be5cb2b639c277f08fafd888ac3456c710 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 20:09:41 +1100 Subject: [PATCH 017/147] Updated single server example --- .../Examples/Single Server/SharePoint.ps1 | 513 +++++++++--------- .../Examples/Single Server/SharePoint.psd1 | 105 ++++ 2 files changed, 347 insertions(+), 271 deletions(-) create mode 100644 Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 diff --git a/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 b/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 index bdd56999e..854ee9815 100644 --- a/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 +++ b/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 @@ -1,29 +1,20 @@ Configuration SharePointServer { param ( - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $CredSSPDelegates, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $SPBinaryPath, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $ULSViewerPath, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $SPBinaryPathCredential, [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $FarmAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $InstallAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $ProductKey, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $DatabaseServer, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $FarmPassPhrase, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $SPSetupAccount, [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $WebPoolManagedAccount, [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $ServicePoolManagedAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $WebAppUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $TeamSiteUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $MySiteHostUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [int] $CacheSizeInMB + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $domainAdminCredential ) + + Import-DscResource -ModuleName PSDesiredStateConfiguration Import-DscResource -ModuleName xSharePoint Import-DscResource -ModuleName xWebAdministration Import-DscResource -ModuleName xCredSSP - Import-DscResource -ModuleName xDisk - node "localhost" - { + node $AllNodes.NodeName + { #********************************************************** # Server configuration # @@ -31,71 +22,10 @@ Configuration SharePointServer # server level configuration, such as disks, registry # settings etc. #********************************************************** - - xDisk LogsDisk { DiskNumber = 2; DriveLetter = "l" } - xDisk IndexDisk { DiskNumber = 3; DriveLetter = "i" } - xCredSSP CredSSPServer { Ensure = "Present"; Role = "Server" } - xCredSSP CredSSPClient { Ensure = "Present"; Role = "Client"; DelegateComputers = $CredSSPDelegates } - - - #********************************************************** - # Software downloads - # - # This section details where any binary downloads should - # be downloaded from and put locally on the server before - # installation takes place - #********************************************************** - - File SPBinaryDownload - { - DestinationPath = "C:\SPInstall" - Credential = $SPBinaryPathCredential - Ensure = "Present" - SourcePath = $SPBinaryPath - Type = "Directory" - Recurse = $true - } - File UlsViewerDownload - { - DestinationPath = "L:\UlsViewer.exe" - Credential = $SPBinaryPathCredential - Ensure = "Present" - SourcePath = $ULSViewerPath - Type = "File" - DependsOn = "[xDisk]LogsDisk" - } - - #********************************************************** - # Binary installation - # - # This section triggers installation of both SharePoint - # as well as the prerequisites required - #********************************************************** - xSPInstallPrereqs InstallPrerequisites - { - InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" - OnlineMode = $true - SQLNCli = "C:\SPInstall\prerequisiteinstallerfiles\sqlncli.msi" - PowerShell = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB2506143-x64.msu" - NETFX = "C:\SPInstall\prerequisiteinstallerfiles\dotNetFx45_Full_setup.exe" - IDFX = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB974405-x64.msu" - Sync = "C:\SPInstall\prerequisiteinstallerfiles\Synchronization.msi" - AppFabric = "C:\SPInstall\prerequisiteinstallerfiles\WindowsServerAppFabricSetup_x64.exe" - IDFX11 = "C:\SPInstall\prerequisiteinstallerfiles\MicrosoftIdentityExtensions-64.msi" - MSIPCClient = "C:\SPInstall\prerequisiteinstallerfiles\setup_msipc_x64.msi" - WCFDataServices = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices.exe" - KB2671763 = "C:\SPInstall\prerequisiteinstallerfiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe" - WCFDataServices56 = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices56.exe" - DependsOn = "[xSPClearRemoteSessions]ClearRemotePowerShellSessions" - } - xSPInstall InstallBinaries - { - BinaryDir = "C:\SPInstall" - ProductKey = $ProductKey - Ensure = "Present" - DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" - } - + + xCredSSP CredSSPServer { Ensure = "Present"; Role = "Server"; } + xCredSSP CredSSPClient { Ensure = "Present"; Role = "Client"; DelegateComputers = "*.$($ConfigurationData.NonNodeData.DomainDetails.DomainName)" } + #********************************************************** # IIS clean up # @@ -103,13 +33,13 @@ Configuration SharePointServer # pools from IIS as they are not required #********************************************************** - xWebAppPool RemoveDotNet2Pool { Name = ".NET v2.0"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDotNet2ClassicPool { Name = ".NET v2.0 Classic"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDotNet45Pool { Name = ".NET v4.5"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites"; } - xWebAppPool RemoveDotNet45ClassicPool { Name = ".NET v4.5 Classic"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites"; } - xWebAppPool RemoveClassicDotNetPool { Name = "Classic .NET AppPool"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDefaultAppPool { Name = "DefaultAppPool"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebSite RemoveDefaultWebSite { Name = "Default Web Site"; Ensure = "Absent"; PhysicalPath = "C:\inetpub\wwwroot"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } + xWebAppPool RemoveDotNet2Pool { Name = ".NET v2.0"; Ensure = "Absent" } + xWebAppPool RemoveDotNet2ClassicPool { Name = ".NET v2.0 Classic"; Ensure = "Absent" } + xWebAppPool RemoveDotNet45Pool { Name = ".NET v4.5"; Ensure = "Absent"; } + xWebAppPool RemoveDotNet45ClassicPool { Name = ".NET v4.5 Classic"; Ensure = "Absent"; } + xWebAppPool RemoveClassicDotNetPool { Name = "Classic .NET AppPool"; Ensure = "Absent" } + xWebAppPool RemoveDefaultAppPool { Name = "DefaultAppPool"; Ensure = "Absent" } + xWebSite RemoveDefaultWebSite { Name = "Default Web Site"; Ensure = "Absent"; PhysicalPath = "C:\inetpub\wwwroot" } #********************************************************** @@ -119,41 +49,37 @@ Configuration SharePointServer # provisions generic services and components used by the # whole farm #********************************************************** - xSPCreateFarm CreateSPFarm { - DatabaseServer = $DatabaseServer - FarmConfigDatabaseName = "SP_Config" - Passphrase = $FarmPassPhrase + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.FarmDatabaseServer + FarmConfigDatabaseName = $ConfigurationData.NonNodeData.SharePoint.Farm.ConfigurationDatabase + Passphrase = $ConfigurationData.NonNodeData.SharePoint.Farm.Passphrase FarmAccount = $FarmAccount - InstallAccount = $InstallAccount - AdminContentDatabaseName = "SP_AdminContent" - DependsOn = "[xSPInstall]InstallBinaries" + PsDscRunAsCredential = $SPSetupAccount + AdminContentDatabaseName = $ConfigurationData.NonNodeData.SharePoint.Farm.AdminContentDatabase } xSPManagedAccount ServicePoolManagedAccount { - AccountName = $ServicePoolManagedAccount.UserName - Account = $ServicePoolManagedAccount - Schedule = "" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" + AccountName = $ServicePoolManagedAccount.UserName + Account = $ServicePoolManagedAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" } xSPManagedAccount WebPoolManagedAccount { - AccountName = $WebPoolManagedAccount.UserName - Account = $WebPoolManagedAccount - Schedule = "" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" + AccountName = $WebPoolManagedAccount.UserName + Account = $WebPoolManagedAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" } xSPDiagnosticLoggingSettings ApplyDiagnosticLogSettings { - InstallAccount = $InstallAccount - LogPath = "L:\ULSLogs" - LogSpaceInGB = 10 + PsDscRunAsCredential = $SPSetupAccount + LogPath = $ConfigurationData.NonNodeData.SharePoint.DiagnosticLogs.Path + LogSpaceInGB = $ConfigurationData.NonNodeData.SharePoint.DiagnosticLogs.MaxSize AppAnalyticsAutomaticUploadEnabled = $false CustomerExperienceImprovementProgramEnabled = $true - DaysToKeepLogs = 7 + DaysToKeepLogs = $ConfigurationData.NonNodeData.SharePoint.DiagnosticLogs.DaysToKeep DownloadErrorReportingUpdatesEnabled = $false ErrorReportingAutomaticUploadEnabled = $false ErrorReportingEnabled = $false @@ -172,28 +98,29 @@ Configuration SharePointServer xSPUsageApplication UsageApplication { Name = "Usage Service Application" - DatabaseName = "SP_Usage" + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.UsageLogs.DatabaseName UsageLogCutTime = 5 - UsageLogLocation = "L:\UsageLogs" + UsageLogLocation = $ConfigurationData.NonNodeData.SharePoint.UsageLogs.Path UsageLogMaxFileSizeKB = 1024 - InstallAccount = $InstallAccount + PsDscRunAsCredential = $SPSetupAccount DependsOn = "[xSPCreateFarm]CreateSPFarm" } xSPStateServiceApp StateServiceApp { - Name = "State Service Application" - DatabaseName = "SP_State" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" + Name = "State Service Application" + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.StateService.DatabaseName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" } xSPDistributedCacheService EnableDistributedCache { - Name = "AppFabricCachingService" - Ensure = "Present" - CacheSizeInMB = $CacheSizeInMB - ServiceAccount = $ServicePoolManagedAccount.UserName - InstallAccount = $InstallAccount - DependsOn = @('[xSPCreateFarm]CreateSPFarm','[xSPManagedAccount]ServicePoolManagedAccount') + Name = "AppFabricCachingService" + Ensure = "Present" + CacheSizeInMB = 1024 + ServiceAccount = $ServicePoolManagedAccount.UserName + PsDscRunAsCredential = $SPSetupAccount + CreateFirewallRules = $true + DependsOn = @('[xSPCreateFarm]CreateSPFarm','[xSPManagedAccount]ServicePoolManagedAccount') } #********************************************************** @@ -204,46 +131,71 @@ Configuration SharePointServer # application settings #********************************************************** - xSPWebApplication HostNameSiteCollectionWebApp - { - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Sites" - ApplicationPoolAccount = $WebPoolManagedAccount.UserName - AllowAnonymous = $false - AuthenticationMethod = "NTLM" - DatabaseName = "SP_Content_01" - DatabaseServer = $DatabaseServer - Url = $WebAppUrl - Port = 80 - InstallAccount = $InstallAccount - DependsOn = "[xSPManagedAccount]WebPoolManagedAccount" - } - xSPManagedPath TeamsManagedPath - { - WebAppUrl = "http://$WebAppUrl" - InstallAccount = $InstallAccount - RelativeUrl = "teams" - Explicit = $false - HostHeader = $true - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" - } - xSPManagedPath PersonalManagedPath - { - WebAppUrl = "http://$WebAppUrl" - InstallAccount = $InstallAccount - RelativeUrl = "personal" - Explicit = $false - HostHeader = $true - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" - } - xSPCacheAccounts SetCacheAccounts - { - WebAppUrl = "http://$WebAppUrl" - SuperUserAlias = "DEMO\svxSPSuperUser" - SuperReaderAlias = "DEMO\svxSPReader" - InstallAccount = $InstallAccount - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" - } + foreach($webApp in $ConfigurationData.NonNodeData.SharePoint.WebApplications) { + $webAppInternalName = $webApp.Name.Replace(" ", "") + xSPWebApplication $webAppInternalName + { + Name = $webApp.Name + ApplicationPool = $webApp.AppPool + ApplicationPoolAccount = $webApp.APpPoolAccount + AllowAnonymous = $webApp.Anonymous + AuthenticationMethod = $webApp.Authentication + DatabaseName = $webApp.DatabaseName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ContentDatabaseServer + Url = $webApp.Url + Port = [Uri]::new($webApp.Url).Port + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPManagedAccount]WebPoolManagedAccount" + } + + foreach($managedPath in $webApp.ManagedPaths) { + xSPManagedPath "$($webAppInternalName)Path$($managedPath.Path)" + { + WebAppUrl = $webApp.Url + PsDscRunAsCredential = $SPSetupAccount + RelativeUrl = $managedPath.Path + Explicit = $managedPath.Explicit + HostHeader = $webApp.UseHostNamedSiteCollections + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } + + xSPCacheAccounts "$($webAppInternalName)CacheAccounts" + { + WebAppUrl = $webApp.Url + SuperUserAlias = $webApp.SuperUser + SuperReaderAlias = $webApp.SuperReader + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + + foreach($siteCollection in $webApp.SiteCollections) { + $internalSiteName = "$($webAppInternalName)Site$($siteCollection.Name.Replace(' ', ''))" + if ($webApp.UseHostNamedSiteCollections -eq $true) { + xSPSite $internalSiteName + { + Url = $siteCollection.Url + OwnerAlias = $siteCollection.Owner + HostHeaderWebApplication = $webApp.Url + Name = $siteCollection.Name + Template = $siteCollection.Template + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } else { + xSPSite $internalSiteName + { + Url = $siteCollection.Url + OwnerAlias = $siteCollection.Owner + Name = $siteCollection.Name + Template = $siteCollection.Template + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } + } + } + #********************************************************** # Service instances @@ -254,48 +206,68 @@ Configuration SharePointServer xSPServiceInstance ClaimsToWindowsTokenServiceInstance { - Name = "Claims to Windows Token Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPServiceInstance UserProfileServiceInstance - { - Name = "User Profile Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPServiceInstance SecureStoreServiceInstance - { - Name = "Secure Store Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPServiceInstance ManagedMetadataServiceInstance - { - Name = "Managed Metadata Web Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPServiceInstance BCSServiceInstance - { - Name = "Business Data Connectivity Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPUserProfileSyncService UserProfileSyncService - { - UserProfileServiceAppName = "User Profile Service Application" - Ensure = "Present" - FarmAccount = $FarmAccount - InstallAccount = $InstallAccount - DependsOn = "[xSPUserProfileServiceApp]UserProfileServiceApp" + Name = "Claims to Windows Token Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" } + # App server service instances + if ($Node.ServiceRoles.AppServer -eq $true) { + xSPServiceInstance UserProfileServiceInstance + { + Name = "User Profile Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + xSPServiceInstance SecureStoreServiceInstance + { + Name = "Secure Store Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + + xSPUserProfileSyncService UserProfileSyncService + { + UserProfileServiceAppName = "User Profile Service Application" + Ensure = "Present" + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPUserProfileServiceApp]UserProfileServiceApp" + } + } + + # Front end service instances + if ($Node.ServiceRoles.WebFrontEnd -eq $true) { + xSPServiceInstance ManagedMetadataServiceInstance + { + Name = "Managed Metadata Web Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + xSPServiceInstance BCSServiceInstance + { + Name = "Business Data Connectivity Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + } + + # Search front or back end instances + if ($Node.ServiceRoles.SearchFrontEnd -eq $true -or $Node.ServiceRoles.SearchBackEnd -eq $true) { + xSPServiceInstance SearchServiceInstance + { + Name = "SharePoint Server Search" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + } + #********************************************************** # Service applications # @@ -303,91 +275,90 @@ Configuration SharePointServer # dependencies #********************************************************** + $serviceAppPoolName = "SharePoint Service Applications" xSPServiceAppPool MainServiceAppPool { - Name = "SharePoint Service Applications" - ServiceAccount = $ServicePoolManagedAccount.UserName - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" + Name = $serviceAppPoolName + ServiceAccount = $ServicePoolManagedAccount.UserName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" } xSPUserProfileServiceApp UserProfileServiceApp { - Name = "User Profile Service Application" - ApplicationPool = "SharePoint Service Applications" - MySiteHostLocation = "http://$MySiteHostUrl" - ProfileDBName = "SP_UserProfiles" - ProfileDBServer = $DatabaseServer - SocialDBName = "SP_Social" - SocialDBServer = $DatabaseServer - SyncDBName = "SP_ProfileSync" - SyncDBServer = $DatabaseServer - FarmAccount = $FarmAccount - InstallAccount = $InstallAccount - DependsOn = @('[xSPServiceAppPool]MainServiceAppPool', '[xSPManagedPath]PersonalManagedPath', '[xSPSite]MySiteHost', '[xSPManagedMetaDataServiceApp]ManagedMetadataServiceApp', '[xSPSearchServiceApp]SearchServiceApp') + Name = "User Profile Service Application" + ApplicationPool = $serviceAppPoolName + MySiteHostLocation = $ConfigurationData.NonNodeData.SharePoint.UserProfileService.MySiteUrl + ProfileDBName = $ConfigurationData.NonNodeData.SharePoint.UserProfileService.ProfileDB + ProfileDBServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + SocialDBName = $ConfigurationData.NonNodeData.SharePoint.UserProfileService.SocialDB + SocialDBServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + SyncDBName = $ConfigurationData.NonNodeData.SharePoint.UserProfileService.SyncDB + SyncDBServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = @('[xSPServiceAppPool]MainServiceAppPool', '[xSPManagedMetaDataServiceApp]ManagedMetadataServiceApp', '[xSPSearchServiceApp]SearchServiceApp') } xSPSecureStoreServiceApp SecureStoreServiceApp { - Name = "Secure Store Service Application" - ApplicationPool = "SharePoint Service Applications" - AuditingEnabled = $true - AuditlogMaxSize = 30 - DatabaseName = "SP_SecureStore" - InstallAccount = $InstallAccount - DependsOn = "[xSPServiceAppPool]MainServiceAppPool" + Name = "Secure Store Service Application" + ApplicationPool = $serviceAppPoolName + AuditingEnabled = $true + AuditlogMaxSize = 30 + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.SecureStoreService.DatabaseName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPServiceAppPool]MainServiceAppPool" } xSPManagedMetaDataServiceApp ManagedMetadataServiceApp { - Name = "Managed Metadata Service Application" - InstallAccount = $InstallAccount - ApplicationPool = "SharePoint Service Applications" - DatabaseServer = $DatabaseServer - DatabaseName = "SP_ManagedMetadata" - DependsOn = "[xSPServiceAppPool]MainServiceAppPool" - } - xSPSearchServiceApp SearchServiceApp - { - Name = "Search Service Application" - DatabaseName = "SP_Search" - ApplicationPool = "SharePoint Service Applications" - InstallAccount = $InstallAccount - DependsOn = "[xSPServiceAppPool]MainServiceAppPool" + Name = "Managed Metadata Service Application" + PsDscRunAsCredential = $SPSetupAccount + ApplicationPool = $serviceAppPoolName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.ManagedMetadataService.DatabaseName + DependsOn = "[xSPServiceAppPool]MainServiceAppPool" } - xSPBCSServiceApp BCSServiceApp - { - Name = "BCS Service Application" - ApplicationPool = "SharePoint Service Applications" - DatabaseName = "SP_BCS" - DatabaseServer = $DatabaseServer - InstallAccount = $InstallAccount - DependsOn = @('[xSPServiceAppPool]MainServiceAppPool', '[xSPSecureStoreServiceApp]SecureStoreServiceApp') - } - - #********************************************************** - # Site Collections - # - # This section contains the site collections to provision - #********************************************************** - - xSPSite TeamSite + xSPBCSServiceApp BCSServiceApp { - Url = "http://$TeamSiteUrl" - OwnerAlias = $InstallAccount.UserName - HostHeaderWebApplication = "http://$WebAppUrl" - Name = "Team Sites" - Template = "STS#0" - InstallAccount = $InstallAccount - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" + Name = "BCS Service Application" + ApplicationPool = $serviceAppPoolName + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.BCSService.DatabaseName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + PsDscRunAsCredential = $SPSetupAccount + DependsOn = @('[xSPServiceAppPool]MainServiceAppPool', '[xSPSecureStoreServiceApp]SecureStoreServiceApp') } - xSPSite MySiteHost - { - Url = "http://$MySiteHostUrl" - OwnerAlias = $InstallAccount.UserName - HostHeaderWebApplication = "http://$WebAppUrl" - Name = "My Site Host" - Template = "SPSMSITEHOST#0" - InstallAccount = $InstallAccount - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" + xSPSearchServiceApp SearchServiceApp + { + Name = "Search Service Application" + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.Search.DatabaseName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + ApplicationPool = $serviceAppPoolName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPServiceAppPool]MainServiceAppPool" } + xSPSearchRoles LocalSearchRoles + { + Ensure = "Present" + Admin = $true + Crawler = $true + ContentProcessing = $true + AnalyticsProcessing = $true + QueryProcessing = $true + ServiceAppName = "Search Service Application" + PsDscRunAsCredential = $SPSetupAccount + FirstPartitionIndex = 0 + FirstPartitionDirectory = "$($ConfigurationData.NonNodeData.SharePoint.Search.IndexRootPath.TrimEnd("\"))\0" + FirstPartitionServers = $env:COMPUTERNAME + DependsOn = "[xSPSearchServiceApp]SearchServiceApp" + } + xSPSearchIndexPartition MainSearchPartition + { + Ensure = "Present" + Servers = $env:COMPUTERNAME + Index = 1 + RootDirectory = "$($ConfigurationData.NonNodeData.SharePoint.Search.IndexRootPath.TrimEnd("\"))\1" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPSearchRoles]LocalSearchRoles" + } #********************************************************** # Local configuration manager settings diff --git a/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 b/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 new file mode 100644 index 000000000..d98b62047 --- /dev/null +++ b/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 @@ -0,0 +1,105 @@ +@{ + AllNodes = @( + @{ + NodeName = "*" + }, + @{ + NodeName = "sharepoint1" + ServiceRoles = @{ + WebFrontEnd = $true + DistributedCache = $true + SearchFrontEnd = $true + SearchBackEnd = $true + AppServer = $true + } + } + ) + NonNodeData = @{ + DomainDetails = @{ + DomainName = "contoso.local" + NetbiosName = "DSC" + } + SQLServer = @{ + ContentDatabaseServer = "sql1.contoso.local" + SearchDatabaseServer = "sql1.contoso.local" + ServiceAppDatabaseServer = "sql1.contoso.local" + FarmDatabaseServer = "sql1.contoso.local" + } + SharePoint = @{ + Farm = @{ + ConfigurationDatabase = "SP_Config" + Passphrase = "ExamplePassphase!" + AdminContentDatabase = "SP_AdminContent" + } + DiagnosticLogs = @{ + Path = "L:\ULSLogs" + MaxSize = 10 + DaysToKeep = 7 + } + UsageLogs = @{ + DatabaseName = "SP_Usage" + Path = "L:\UsageLogs" + } + StateService = @{ + DatabaseName = "SP_State" + } + WebApplications = @( + @{ + Name = "SharePoint Sites" + DatabaeName = "SP_Content_01" + Url = "http://sites.sharepoint.contoso.local" + Authentication = "NTLM" + Anonymous = $false + AppPool = "SharePoint Sites" + AppPoolAccount = "DSC\svcSPWebApp" + SuperUser = "DSC\svcSPSuperUser" + SuperReader = "DSC\svcSPReader" + UseHostNamedSiteCollections = $true + ManagedPaths = @( + @{ + Path = "teams" + Explicit = $false + }, + @{ + Path = "personal" + Explicit = $false + } + ) + SiteCollections = @( + @{ + Url = "http://sites.sharepoint.contoso.local" + Owner = "DSC\svcSPFarm" + Name = "Team Sites" + Template = "STS#0" + }, + @{ + Url = "http://my.sharepoint.contoso.local" + Owner = "DSC\svcSPFarm" + Name = "My Sites" + Template = "SPSMSITEHOST#0" + } + ) + } + ) + UserProfileService = @{ + MySiteUrl = "http://my.sharepoint.contoso.local" + ProfileDB = "SP_UserProfiles" + SocialDB = "SP_Social" + SyncDB = "SP_ProfileSync" + } + SecureStoreService = @{ + DatabaseName = "SP_SecureStore" + } + ManagedMetadataService = @{ + DatabaseName = "SP_ManagedMetadata" + } + BCSService = @{ + DatabaseName = "SP_BCS" + } + Search = @{ + DatabaseName = "SP_Search" + IndexRootPath = "I:\SearchPartitions" + } + } + } +} \ No newline at end of file From fefc4e3dcfbed5863dc648e7f06e2195382dc59b Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 20:10:41 +1100 Subject: [PATCH 018/147] Updated example values --- .../Examples/Single Server/SharePoint.psd1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 b/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 index d98b62047..58b1a654e 100644 --- a/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 +++ b/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 @@ -17,7 +17,7 @@ NonNodeData = @{ DomainDetails = @{ DomainName = "contoso.local" - NetbiosName = "DSC" + NetbiosName = "Contoso" } SQLServer = @{ ContentDatabaseServer = "sql1.contoso.local" @@ -32,13 +32,13 @@ AdminContentDatabase = "SP_AdminContent" } DiagnosticLogs = @{ - Path = "L:\ULSLogs" + Path = "C:\ULSLogs" MaxSize = 10 DaysToKeep = 7 } UsageLogs = @{ DatabaseName = "SP_Usage" - Path = "L:\UsageLogs" + Path = "C:\UsageLogs" } StateService = @{ DatabaseName = "SP_State" @@ -51,9 +51,9 @@ Authentication = "NTLM" Anonymous = $false AppPool = "SharePoint Sites" - AppPoolAccount = "DSC\svcSPWebApp" - SuperUser = "DSC\svcSPSuperUser" - SuperReader = "DSC\svcSPReader" + AppPoolAccount = "Contoso\svcSPWebApp" + SuperUser = "Contoso\svcSPSuperUser" + SuperReader = "Contoso\svcSPReader" UseHostNamedSiteCollections = $true ManagedPaths = @( @{ @@ -68,13 +68,13 @@ SiteCollections = @( @{ Url = "http://sites.sharepoint.contoso.local" - Owner = "DSC\svcSPFarm" + Owner = "Contoso\svcSPFarm" Name = "Team Sites" Template = "STS#0" }, @{ Url = "http://my.sharepoint.contoso.local" - Owner = "DSC\svcSPFarm" + Owner = "Contoso\svcSPFarm" Name = "My Sites" Template = "SPSMSITEHOST#0" } @@ -98,7 +98,7 @@ } Search = @{ DatabaseName = "SP_Search" - IndexRootPath = "I:\SearchPartitions" + IndexRootPath = "C:\SearchPartitions" } } } From 4df31670d6a425e3838edbeb7bf4f88f54bb6889 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 20:12:09 +1100 Subject: [PATCH 019/147] Formatting fixes --- .../Examples/Single Server/SharePoint.ps1 | 274 +++++++++--------- .../Examples/Single Server/SharePoint.psd1 | 202 ++++++------- 2 files changed, 238 insertions(+), 238 deletions(-) diff --git a/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 b/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 index 854ee9815..42829dede 100644 --- a/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 +++ b/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 @@ -8,7 +8,7 @@ Configuration SharePointServer [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $domainAdminCredential ) - Import-DscResource -ModuleName PSDesiredStateConfiguration + Import-DscResource -ModuleName PSDesiredStateConfiguration Import-DscResource -ModuleName xSharePoint Import-DscResource -ModuleName xWebAdministration Import-DscResource -ModuleName xCredSSP @@ -131,70 +131,70 @@ Configuration SharePointServer # application settings #********************************************************** - foreach($webApp in $ConfigurationData.NonNodeData.SharePoint.WebApplications) { - $webAppInternalName = $webApp.Name.Replace(" ", "") - xSPWebApplication $webAppInternalName - { - Name = $webApp.Name - ApplicationPool = $webApp.AppPool - ApplicationPoolAccount = $webApp.APpPoolAccount - AllowAnonymous = $webApp.Anonymous - AuthenticationMethod = $webApp.Authentication - DatabaseName = $webApp.DatabaseName - DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ContentDatabaseServer - Url = $webApp.Url - Port = [Uri]::new($webApp.Url).Port - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPManagedAccount]WebPoolManagedAccount" - } + foreach($webApp in $ConfigurationData.NonNodeData.SharePoint.WebApplications) { + $webAppInternalName = $webApp.Name.Replace(" ", "") + xSPWebApplication $webAppInternalName + { + Name = $webApp.Name + ApplicationPool = $webApp.AppPool + ApplicationPoolAccount = $webApp.APpPoolAccount + AllowAnonymous = $webApp.Anonymous + AuthenticationMethod = $webApp.Authentication + DatabaseName = $webApp.DatabaseName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ContentDatabaseServer + Url = $webApp.Url + Port = [Uri]::new($webApp.Url).Port + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPManagedAccount]WebPoolManagedAccount" + } - foreach($managedPath in $webApp.ManagedPaths) { - xSPManagedPath "$($webAppInternalName)Path$($managedPath.Path)" - { - WebAppUrl = $webApp.Url - PsDscRunAsCredential = $SPSetupAccount - RelativeUrl = $managedPath.Path - Explicit = $managedPath.Explicit - HostHeader = $webApp.UseHostNamedSiteCollections - DependsOn = "[xSPWebApplication]$webAppInternalName" - } - } - - xSPCacheAccounts "$($webAppInternalName)CacheAccounts" - { - WebAppUrl = $webApp.Url - SuperUserAlias = $webApp.SuperUser - SuperReaderAlias = $webApp.SuperReader - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPWebApplication]$webAppInternalName" - } + foreach($managedPath in $webApp.ManagedPaths) { + xSPManagedPath "$($webAppInternalName)Path$($managedPath.Path)" + { + WebAppUrl = $webApp.Url + PsDscRunAsCredential = $SPSetupAccount + RelativeUrl = $managedPath.Path + Explicit = $managedPath.Explicit + HostHeader = $webApp.UseHostNamedSiteCollections + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } + + xSPCacheAccounts "$($webAppInternalName)CacheAccounts" + { + WebAppUrl = $webApp.Url + SuperUserAlias = $webApp.SuperUser + SuperReaderAlias = $webApp.SuperReader + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } - foreach($siteCollection in $webApp.SiteCollections) { - $internalSiteName = "$($webAppInternalName)Site$($siteCollection.Name.Replace(' ', ''))" - if ($webApp.UseHostNamedSiteCollections -eq $true) { - xSPSite $internalSiteName - { - Url = $siteCollection.Url - OwnerAlias = $siteCollection.Owner - HostHeaderWebApplication = $webApp.Url - Name = $siteCollection.Name - Template = $siteCollection.Template - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPWebApplication]$webAppInternalName" - } - } else { - xSPSite $internalSiteName - { - Url = $siteCollection.Url - OwnerAlias = $siteCollection.Owner - Name = $siteCollection.Name - Template = $siteCollection.Template - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPWebApplication]$webAppInternalName" - } - } - } - } + foreach($siteCollection in $webApp.SiteCollections) { + $internalSiteName = "$($webAppInternalName)Site$($siteCollection.Name.Replace(' ', ''))" + if ($webApp.UseHostNamedSiteCollections -eq $true) { + xSPSite $internalSiteName + { + Url = $siteCollection.Url + OwnerAlias = $siteCollection.Owner + HostHeaderWebApplication = $webApp.Url + Name = $siteCollection.Name + Template = $siteCollection.Template + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } else { + xSPSite $internalSiteName + { + Url = $siteCollection.Url + OwnerAlias = $siteCollection.Owner + Name = $siteCollection.Name + Template = $siteCollection.Template + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } + } + } #********************************************************** @@ -212,61 +212,61 @@ Configuration SharePointServer DependsOn = "[xSPCreateFarm]CreateSPFarm" } - # App server service instances - if ($Node.ServiceRoles.AppServer -eq $true) { - xSPServiceInstance UserProfileServiceInstance - { - Name = "User Profile Service" - Ensure = "Present" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPServiceInstance SecureStoreServiceInstance - { - Name = "Secure Store Service" - Ensure = "Present" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } + # App server service instances + if ($Node.ServiceRoles.AppServer -eq $true) { + xSPServiceInstance UserProfileServiceInstance + { + Name = "User Profile Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + xSPServiceInstance SecureStoreServiceInstance + { + Name = "Secure Store Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } - xSPUserProfileSyncService UserProfileSyncService - { - UserProfileServiceAppName = "User Profile Service Application" - Ensure = "Present" - FarmAccount = $FarmAccount - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPUserProfileServiceApp]UserProfileServiceApp" - } - } - + xSPUserProfileSyncService UserProfileSyncService + { + UserProfileServiceAppName = "User Profile Service Application" + Ensure = "Present" + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPUserProfileServiceApp]UserProfileServiceApp" + } + } + # Front end service instances - if ($Node.ServiceRoles.WebFrontEnd -eq $true) { - xSPServiceInstance ManagedMetadataServiceInstance - { - Name = "Managed Metadata Web Service" - Ensure = "Present" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPServiceInstance BCSServiceInstance - { - Name = "Business Data Connectivity Service" - Ensure = "Present" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - } + if ($Node.ServiceRoles.WebFrontEnd -eq $true) { + xSPServiceInstance ManagedMetadataServiceInstance + { + Name = "Managed Metadata Web Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + xSPServiceInstance BCSServiceInstance + { + Name = "Business Data Connectivity Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + } - # Search front or back end instances - if ($Node.ServiceRoles.SearchFrontEnd -eq $true -or $Node.ServiceRoles.SearchBackEnd -eq $true) { - xSPServiceInstance SearchServiceInstance - { - Name = "SharePoint Server Search" - Ensure = "Present" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - } + # Search front or back end instances + if ($Node.ServiceRoles.SearchFrontEnd -eq $true -or $Node.ServiceRoles.SearchBackEnd -eq $true) { + xSPServiceInstance SearchServiceInstance + { + Name = "SharePoint Server Search" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" + } + } #********************************************************** # Service applications @@ -275,7 +275,7 @@ Configuration SharePointServer # dependencies #********************************************************** - $serviceAppPoolName = "SharePoint Service Applications" + $serviceAppPoolName = "SharePoint Service Applications" xSPServiceAppPool MainServiceAppPool { Name = $serviceAppPoolName @@ -317,7 +317,7 @@ Configuration SharePointServer DatabaseName = $ConfigurationData.NonNodeData.SharePoint.ManagedMetadataService.DatabaseName DependsOn = "[xSPServiceAppPool]MainServiceAppPool" } - xSPBCSServiceApp BCSServiceApp + xSPBCSServiceApp BCSServiceApp { Name = "BCS Service Application" ApplicationPool = $serviceAppPoolName @@ -330,35 +330,35 @@ Configuration SharePointServer { Name = "Search Service Application" DatabaseName = $ConfigurationData.NonNodeData.SharePoint.Search.DatabaseName - DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer ApplicationPool = $serviceAppPoolName PsDscRunAsCredential = $SPSetupAccount DependsOn = "[xSPServiceAppPool]MainServiceAppPool" } - xSPSearchRoles LocalSearchRoles - { - Ensure = "Present" + xSPSearchRoles LocalSearchRoles + { + Ensure = "Present" Admin = $true - Crawler = $true - ContentProcessing = $true - AnalyticsProcessing = $true - QueryProcessing = $true - ServiceAppName = "Search Service Application" - PsDscRunAsCredential = $SPSetupAccount + Crawler = $true + ContentProcessing = $true + AnalyticsProcessing = $true + QueryProcessing = $true + ServiceAppName = "Search Service Application" + PsDscRunAsCredential = $SPSetupAccount FirstPartitionIndex = 0 - FirstPartitionDirectory = "$($ConfigurationData.NonNodeData.SharePoint.Search.IndexRootPath.TrimEnd("\"))\0" - FirstPartitionServers = $env:COMPUTERNAME + FirstPartitionDirectory = "$($ConfigurationData.NonNodeData.SharePoint.Search.IndexRootPath.TrimEnd("\"))\0" + FirstPartitionServers = $env:COMPUTERNAME DependsOn = "[xSPSearchServiceApp]SearchServiceApp" - } - xSPSearchIndexPartition MainSearchPartition - { - Ensure = "Present" - Servers = $env:COMPUTERNAME - Index = 1 + } + xSPSearchIndexPartition MainSearchPartition + { + Ensure = "Present" + Servers = $env:COMPUTERNAME + Index = 1 RootDirectory = "$($ConfigurationData.NonNodeData.SharePoint.Search.IndexRootPath.TrimEnd("\"))\1" PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPSearchRoles]LocalSearchRoles" - } + DependsOn = "[xSPSearchRoles]LocalSearchRoles" + } #********************************************************** # Local configuration manager settings diff --git a/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 b/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 index 58b1a654e..3815a2719 100644 --- a/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 +++ b/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 @@ -1,105 +1,105 @@ @{ AllNodes = @( - @{ - NodeName = "*" - }, - @{ - NodeName = "sharepoint1" - ServiceRoles = @{ - WebFrontEnd = $true - DistributedCache = $true - SearchFrontEnd = $true - SearchBackEnd = $true - AppServer = $true - } - } + @{ + NodeName = "*" + }, + @{ + NodeName = "sharepoint1" + ServiceRoles = @{ + WebFrontEnd = $true + DistributedCache = $true + SearchFrontEnd = $true + SearchBackEnd = $true + AppServer = $true + } + } ) - NonNodeData = @{ - DomainDetails = @{ - DomainName = "contoso.local" - NetbiosName = "Contoso" - } - SQLServer = @{ - ContentDatabaseServer = "sql1.contoso.local" - SearchDatabaseServer = "sql1.contoso.local" - ServiceAppDatabaseServer = "sql1.contoso.local" - FarmDatabaseServer = "sql1.contoso.local" - } - SharePoint = @{ - Farm = @{ - ConfigurationDatabase = "SP_Config" - Passphrase = "ExamplePassphase!" - AdminContentDatabase = "SP_AdminContent" - } - DiagnosticLogs = @{ - Path = "C:\ULSLogs" - MaxSize = 10 - DaysToKeep = 7 - } - UsageLogs = @{ - DatabaseName = "SP_Usage" - Path = "C:\UsageLogs" - } - StateService = @{ - DatabaseName = "SP_State" - } - WebApplications = @( - @{ - Name = "SharePoint Sites" - DatabaeName = "SP_Content_01" - Url = "http://sites.sharepoint.contoso.local" - Authentication = "NTLM" - Anonymous = $false - AppPool = "SharePoint Sites" - AppPoolAccount = "Contoso\svcSPWebApp" - SuperUser = "Contoso\svcSPSuperUser" - SuperReader = "Contoso\svcSPReader" - UseHostNamedSiteCollections = $true - ManagedPaths = @( - @{ - Path = "teams" - Explicit = $false - }, - @{ - Path = "personal" - Explicit = $false - } - ) - SiteCollections = @( - @{ - Url = "http://sites.sharepoint.contoso.local" - Owner = "Contoso\svcSPFarm" - Name = "Team Sites" - Template = "STS#0" - }, - @{ - Url = "http://my.sharepoint.contoso.local" - Owner = "Contoso\svcSPFarm" - Name = "My Sites" - Template = "SPSMSITEHOST#0" - } - ) - } - ) - UserProfileService = @{ - MySiteUrl = "http://my.sharepoint.contoso.local" - ProfileDB = "SP_UserProfiles" - SocialDB = "SP_Social" - SyncDB = "SP_ProfileSync" - } - SecureStoreService = @{ - DatabaseName = "SP_SecureStore" - } - ManagedMetadataService = @{ - DatabaseName = "SP_ManagedMetadata" - } - BCSService = @{ - DatabaseName = "SP_BCS" - } - Search = @{ - DatabaseName = "SP_Search" - IndexRootPath = "C:\SearchPartitions" - } - } - } + NonNodeData = @{ + DomainDetails = @{ + DomainName = "contoso.local" + NetbiosName = "Contoso" + } + SQLServer = @{ + ContentDatabaseServer = "sql1.contoso.local" + SearchDatabaseServer = "sql1.contoso.local" + ServiceAppDatabaseServer = "sql1.contoso.local" + FarmDatabaseServer = "sql1.contoso.local" + } + SharePoint = @{ + Farm = @{ + ConfigurationDatabase = "SP_Config" + Passphrase = "ExamplePassphase!" + AdminContentDatabase = "SP_AdminContent" + } + DiagnosticLogs = @{ + Path = "C:\ULSLogs" + MaxSize = 10 + DaysToKeep = 7 + } + UsageLogs = @{ + DatabaseName = "SP_Usage" + Path = "C:\UsageLogs" + } + StateService = @{ + DatabaseName = "SP_State" + } + WebApplications = @( + @{ + Name = "SharePoint Sites" + DatabaeName = "SP_Content_01" + Url = "http://sites.sharepoint.contoso.local" + Authentication = "NTLM" + Anonymous = $false + AppPool = "SharePoint Sites" + AppPoolAccount = "Contoso\svcSPWebApp" + SuperUser = "Contoso\svcSPSuperUser" + SuperReader = "Contoso\svcSPReader" + UseHostNamedSiteCollections = $true + ManagedPaths = @( + @{ + Path = "teams" + Explicit = $false + }, + @{ + Path = "personal" + Explicit = $false + } + ) + SiteCollections = @( + @{ + Url = "http://sites.sharepoint.contoso.local" + Owner = "Contoso\svcSPFarm" + Name = "Team Sites" + Template = "STS#0" + }, + @{ + Url = "http://my.sharepoint.contoso.local" + Owner = "Contoso\svcSPFarm" + Name = "My Sites" + Template = "SPSMSITEHOST#0" + } + ) + } + ) + UserProfileService = @{ + MySiteUrl = "http://my.sharepoint.contoso.local" + ProfileDB = "SP_UserProfiles" + SocialDB = "SP_Social" + SyncDB = "SP_ProfileSync" + } + SecureStoreService = @{ + DatabaseName = "SP_SecureStore" + } + ManagedMetadataService = @{ + DatabaseName = "SP_ManagedMetadata" + } + BCSService = @{ + DatabaseName = "SP_BCS" + } + Search = @{ + DatabaseName = "SP_Search" + IndexRootPath = "C:\SearchPartitions" + } + } + } } \ No newline at end of file From 56ad0205b57f8aa63b2a7f6b31f7c65305caea8f Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 20:49:05 +1100 Subject: [PATCH 020/147] Added to get method to return list of servers for index --- .../MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 index 6da016658..427c76c64 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 @@ -69,6 +69,15 @@ function Get-TargetResource $QueryProcessingExists = $true } + $indexComps = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology ` + | Where-Object {($_.GetType().Name -eq "IndexComponent") ` + -and ($_.IndexPartitionOrdinal -eq $params.Index)} + + $servers = "" + foreach ($indexComp in $indexComps) { + $servers += $indexComp.ServerName + "," + } + return @{ ServiceAppName = $params.ServiceAppName Admin = $AdminExists @@ -79,7 +88,7 @@ function Get-TargetResource InstallAccount = $params.InstallAccount FirstPartitionIndex = $params.FirstPartitionIndex FirstPartitionDirectory = $params.FirstPartitionDirectory - FirstPartitionServers = $params.FirstPartitionServers + FirstPartitionServers = $servers.TrimEnd(",") Ensure = $params.Ensure } } @@ -162,7 +171,7 @@ function Set-TargetResource if($null -eq $IndexComponent1) { Write-Verbose "Adding First search indedx at partition $($params.FirstPartitionIndex)" - $servers = $params.FirstPartitionServers.Split(',', [StringSplitOptions]::RemoveEmptyEntries) + $servers = $params.FirstPartitionServers.Replace(" ", "").Split(',', [StringSplitOptions]::RemoveEmptyEntries) foreach($server in $servers) { $InvokeCommandArgs = @{ ArgumentList = @($params.FirstPartitionDirectory) From 7ec1d89976b3c5cb32e83a8c4d207c099411cdac Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 20:53:11 +1100 Subject: [PATCH 021/147] Formatting fix --- .../DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 index 427c76c64..e648bbe18 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 @@ -69,11 +69,11 @@ function Get-TargetResource $QueryProcessingExists = $true } - $indexComps = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology ` + $indexComps = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology ` | Where-Object {($_.GetType().Name -eq "IndexComponent") ` -and ($_.IndexPartitionOrdinal -eq $params.Index)} - $servers = "" + $servers = "" foreach ($indexComp in $indexComps) { $servers += $indexComp.ServerName + "," } From d4516f58fc155489b37c18c4e05295f0c787dbb1 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 15 Nov 2015 10:12:48 +0000 Subject: [PATCH 022/147] adding validation and making xSPPasswordSettings parameters optional --- .../MSFT_xSPPasswordChangeSettings.psm1 | 40 +++++++++++-------- ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 2 +- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 850d5fac4..31f0093cb 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -5,9 +5,9 @@ function Get-TargetResource param ( [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries ) Write-Verbose -Message "Retrieving farm wide automatic password change settings" @@ -18,11 +18,10 @@ function Get-TargetResource $farm = Get-SPFarm if ($null -eq $farm ) { return $null } return @{ - - MailAddress = $farm.PasswordChangeEmailAddress - PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime - NumberOfRetries= $farm.PasswordChangeMaximumTries - DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail + MailAddress = $farm.PasswordChangeEmailAddress + PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime + NumberOfRetries= $farm.PasswordChangeMaximumTries + DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail } } return $result @@ -34,9 +33,9 @@ function Set-TargetResource param ( [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,356 )][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99 )][System.UInt32] $NumberOfRetries ) Write-Verbose -Message "Updating farm wide automatic password change settings" @@ -45,10 +44,17 @@ function Set-TargetResource $farm = Get-SPFarm if ($null -eq $farm ) { return $null } + $farm.PasswordChangeEmailAddress=$params.MailAddress; - $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds - $farm.PasswordChangeMaximumTries=$params.NumberOfRetries - $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry + if($params.PasswordChangeWaitTimeSeconds -ne $null){ + $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds + } + if($params.NumberOfRetries -ne $null){ + $farm.PasswordChangeMaximumTries=$params.NumberOfRetries + } + if($params.DaysBeforeExpiry -ne $null){ + $farm.DaysBeforePasswordExpirationToSendEmail=$params.DaysBeforeExpiry + } $farm.Update(); } @@ -62,9 +68,9 @@ function Test-TargetResource param ( [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 0048f3148..0175e8e6f 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -18,7 +18,7 @@ Describe "xSPPasswordChangeSettings" { MailAddress = "e@mail.com" DaysBeforeExpiry = 7 PasswordChangeWaitTimeSeconds = 60 - NumberOfRetries = 3 + } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") From 75174261323d6c99891adaa6df2f467f8cfaec82 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 22:11:32 +1100 Subject: [PATCH 023/147] Added search partition resource --- .../MSFT_xSPSearchIndexPartition.psm1 | 124 +++++++++++++++++ .../MSFT_xSPSearchIndexPartition.schema.mof | 11 ++ Modules/xSharePoint/xSharePoint.pssproj | 7 + Tests/Tests.pssproj | 1 + ...arePoint.xSPSearchIndexPartition.Tests.ps1 | 125 ++++++++++++++++++ 5 files changed, 268 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 new file mode 100644 index 000000000..0009c614a --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 @@ -0,0 +1,124 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.UInt32] $Index, + [parameter(Mandatory = $true)] [System.String] $Servers, + [parameter(Mandatory = $true)] [System.String] $RootDirectory, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure + ) + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $ConfirmPreference = 'None' + + $ssa = Get-SPEnterpriseSearchServiceApplication + $indexComps = Get-SPEnterpriseSearchComponent -SearchTopology $ssa.ActiveTopology ` + | Where-Object {($_.GetType().Name -eq "IndexComponent") ` + -and ($_.IndexPartitionOrdinal -eq $params.Index)} + + if (($indexComps -eq $null) -or ($indexComps.Count -eq 0)) { return @{ + Index = -1 + Servers = $params.Servers + RootDirectory = $null + InstallAccount = $params.InstallAccount + Ensure = "Absent" + } } + + $servers = "" + foreach ($indexComp in $indexComps) { + $servers += $indexComp.ServerName + "," + } + + return @{ + Index = $params.Index + Servers = $servers.TrimEnd(",") + RootDirectory = $params.RootDirectory + InstallAccount = $params.InstallAccount + Ensure = "Present" + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.UInt32] $Index, + [parameter(Mandatory = $true)] [System.String] $Servers, + [parameter(Mandatory = $true)] [System.String] $RootDirectory, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure + ) + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $ConfirmPreference = 'None' + + $ssa = Get-SPEnterpriseSearchServiceApplication + $newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $ssa.ActiveTopology + + $servers = $params["Servers"].Replace(" ", "").Split(",", [StringSplitOptions]::RemoveEmptyEntries) + + foreach($server in $servers) { + $ssi = Get-SPEnterpriseSearchServiceInstance -Identity $server + + if($ssi.Status -eq "Offline") { + Write-Verbose "Start Search Service Instance on $server" + Start-SPEnterpriseSearchServiceInstance -Identity $ssi + } + + #Wait for Search Service Instance to come online + $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; + do { + $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; + Write-Verbose "Waiting for service on $server - current status is $($online.Status)" + Start-Sleep -Seconds 10 + } + until ($online.Status -eq "Online") + + if ($params.Ensure -eq "Present") { + Write-Verbose "Creating $($params.RootDirectory) on $server" + $InvokeCommandArgs = @{ + ArgumentList = @($params.RootDirectory) + } + $session = New-PSSession -ComputerName $server -Name "Microsoft.SharePoint.DSC.SearchIndexSetup" -SessionOption (New-PSSessionOption -OperationTimeout 0 -IdleTimeout 60000) + if ($null -ne $session) { $InvokeCommandArgs.Add("Session", $session) } + Invoke-Command @InvokeCommandArgs -ScriptBlock { + New-Item $args[0] -ItemType Directory -Force + } + New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $ssi -IndexPartition $params.Index -RootDirectory $params.RootDirectory + } + else { + $IndexComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | ? {($_.GetType().Name -eq "IndexComponent") -and ($_.ServerName -eq $($ssi.Server.Address)) -and ($_.IndexPartitionOrdinal -eq $params.Index)} + if($IndexComponent1) { + $IndexComponent1 | Remove-SPEnterpriseSearchComponent -SearchTopology $newTopology -confirm:$false + } + } + } + Set-SPEnterpriseSearchTopology -Identity $newTopology + } +} + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.UInt32] $Index, + [parameter(Mandatory = $true)] [System.String] $Servers, + [parameter(Mandatory = $true)] [System.String] $RootDirectory, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure + ) + $CurrentValues = Get-TargetResource @PSBoundParameters + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Ensure", "Servers") +} + +Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof new file mode 100644 index 000000000..bb62f3994 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof @@ -0,0 +1,11 @@ +/* +*/ +[ClassVersion("1.0.0.0"), FriendlyName("xSPSearchIndexPartition")] +class MSFT_xSPSearchIndexPartition : OMI_BaseResource +{ + [Key] Uint32 Index; + [Required] String Servers; + [Required] String RootDirectory; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; +}; \ No newline at end of file diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index dd7740cee..dfcaede53 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -62,6 +62,7 @@ + @@ -72,6 +73,7 @@ + @@ -103,6 +105,8 @@ + + @@ -123,10 +127,13 @@ + + + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index a28603460..e100fcf55 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -66,6 +66,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 new file mode 100644 index 000000000..e20c5c6be --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 @@ -0,0 +1,125 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPSearchIndexPartition" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPSearchIndexPartition" { + InModuleScope $ModuleName { + $testParams = @{ + Index = "0" + Servers = $env:COMPUTERNAME + RootDirectory = "C:\SearchIndex\0" + Ensure = "Present" + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + Mock New-PSSession { + return $null + } + Mock New-Item { return @{} } + Mock Get-SPEnterpriseSearchServiceApplication { + return @{ + ActiveTopology = @{} + } + } + Mock New-SPEnterpriseSearchTopology { return @{} } + + $Global:xSharePointSearchRoleInstanceCallCount = 0 + Mock Get-SPEnterpriseSearchServiceInstance { + if ($Global:xSharePointSearchRoleInstanceCallCount -eq 2) { + $Global:xSharePointSearchRoleInstanceCallCount = 0 + return @{ + Server = @{ + Address = $env:COMPUTERNAME + } + Status = "Online" + } + } else { + $Global:xSharePointSearchRoleInstanceCallCount++ + return @{ + Server = @{ + Address = $env:COMPUTERNAME + } + Status = "Offline" + } + } + } + Mock Start-SPEnterpriseSearchServiceInstance { return $null } + Mock New-SPEnterpriseSearchIndexComponent { return $null } + Mock Remove-SPEnterpriseSearchComponent { return $null } + Mock Set-SPEnterpriseSearchTopology { return $null } + + Add-Type -TypeDefinition "public class IndexComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;} public System.Int32 IndexPartitionOrdinal {get; set;}}" + $indexComponent = New-Object IndexComponent + $indexComponent.ServerName = $env:COMPUTERNAME + $indexComponent.IndexPartitionOrdinal = 0 + + Context "Search index doesn't exist and it should" { + Mock Get-SPEnterpriseSearchComponent { return @() } + $Global:xSharePointSearchRoleInstanceCallCount = 0 + + It "returns absent from the get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be "Absent" + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "creates the search index in the set method" { + Set-TargetResource @testParams + Assert-MockCalled New-SPEnterpriseSearchIndexComponent + } + } + + Context "Search index does exist and it should" { + Mock Get-SPEnterpriseSearchComponent { return @($indexComponent) } + + It "returns present from the get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be "Present" + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + $testParams.Ensure = "Absent" + + Context "Search index exists and it shouldn't" { + Mock Get-SPEnterpriseSearchComponent { return @($indexComponent) } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "removes the search index in the set method" { + Set-TargetResource @testParams + Assert-MockCalled Remove-SPEnterpriseSearchComponent + } + } + + Context "Search index doesn't exist and it shouldn't" { + Mock Get-SPEnterpriseSearchComponent { return @() } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + } +} \ No newline at end of file From 428eebe38589a0c4f6f9604ba0c84b2af6f78f89 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 23:36:25 +1100 Subject: [PATCH 024/147] Added script to generate help files in to build package --- Tests/Generate-xSharePointHelpFiles.ps1 | 38 +++++++++++++++++++++++++ Tests/Generate-xSharePointWikiPages.ps1 | 4 +-- Tests/Tests.pssproj | 1 + appveyor.yml | 5 +++- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 Tests/Generate-xSharePointHelpFiles.ps1 diff --git a/Tests/Generate-xSharePointHelpFiles.ps1 b/Tests/Generate-xSharePointHelpFiles.ps1 new file mode 100644 index 000000000..1a08a8572 --- /dev/null +++ b/Tests/Generate-xSharePointHelpFiles.ps1 @@ -0,0 +1,38 @@ +param +( + [parameter(Mandatory = $true)] [System.String] $OutPutPath +) + +Import-Module (Join-Path $PSScriptRoot "xSharePoint\xSharePoint.TestHelpers.psm1") + +$repoDir = Join-Path $PSScriptRoot "..\" -Resolve + +Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` + ForEach-Object { + $result = Get-MofSchemaObject $_.FullName + Write-Output "Generating help document for $($result.FriendlyName)" + + $output = @" +NAME + $($result.FriendlyName) + +PARAMETERS +"@ + [Environment]::NewLine + + foreach($property in $result.Attributes) { + $output += " $($property.Name) ($($property.State), $($property.DataType)" + if ([string]::IsNullOrEmpty($property.ValueMap) -ne $true) { + $output += ", Allowed values: " + $property.ValueMap | ForEach-Object { + $output += $_ + ", " + } + $output = $output.TrimEnd(" ") + $output = $output.TrimEnd(",") + } + $output += ")" + [Environment]::NewLine + } + + $output += [Environment]::NewLine + $result.Documentation.Replace("**Description**", "DESCRIPTION").Replace("**Example**","EXAMPLE") + + $output | Out-File -FilePath (Join-Path $OutPutPath "about_$($result.FriendlyName).help.txt") -Encoding utf8 -Force + } \ No newline at end of file diff --git a/Tests/Generate-xSharePointWikiPages.ps1 b/Tests/Generate-xSharePointWikiPages.ps1 index 67204587f..59221e2e8 100644 --- a/Tests/Generate-xSharePointWikiPages.ps1 +++ b/Tests/Generate-xSharePointWikiPages.ps1 @@ -9,9 +9,9 @@ $repoDir = Join-Path $PSScriptRoot "..\" -Resolve Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` ForEach-Object { - Write-Output "Generating wiki page for $($result.FriendlyName)" $result = Get-MofSchemaObject $_.FullName - + Write-Output "Generating wiki page for $($result.FriendlyName)" + $output = "**Parameters**" + [Environment]::NewLine + [Environment]::NewLine foreach($property in $result.Attributes) { diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index e100fcf55..6606ac3b5 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -59,6 +59,7 @@ + diff --git a/appveyor.yml b/appveyor.yml index f37a60a92..d45f76a78 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,10 @@ test_script: after_test: - ps: | - Remove-Item (Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.pssproj") + New-Item "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint\en-US" -ItemType Directory + & "$env:APPVEYOR_BUILD_FOLDER\Tests\Generate-xSharePointHelpFiles.ps1" -OutputPath "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint\en-US" + + Remove-Item (Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.pssproj") $manifest = Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.psd1" (Get-Content $manifest -Raw).Replace("0.7.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest Add-Type -assemblyname System.IO.Compression.FileSystem From 50dfc7deb97c9e410f94ed6f188adf78dcefe0f3 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 15 Nov 2015 23:37:17 +1100 Subject: [PATCH 025/147] Fixed spacing --- Tests/Generate-xSharePointHelpFiles.ps1 | 4 ++-- Tests/Generate-xSharePointWikiPages.ps1 | 2 +- appveyor.yml | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/Generate-xSharePointHelpFiles.ps1 b/Tests/Generate-xSharePointHelpFiles.ps1 index 1a08a8572..a18677d2c 100644 --- a/Tests/Generate-xSharePointHelpFiles.ps1 +++ b/Tests/Generate-xSharePointHelpFiles.ps1 @@ -10,9 +10,9 @@ $repoDir = Join-Path $PSScriptRoot "..\" -Resolve Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` ForEach-Object { $result = Get-MofSchemaObject $_.FullName - Write-Output "Generating help document for $($result.FriendlyName)" + Write-Output "Generating help document for $($result.FriendlyName)" - $output = @" + $output = @" NAME $($result.FriendlyName) diff --git a/Tests/Generate-xSharePointWikiPages.ps1 b/Tests/Generate-xSharePointWikiPages.ps1 index 59221e2e8..de22eb371 100644 --- a/Tests/Generate-xSharePointWikiPages.ps1 +++ b/Tests/Generate-xSharePointWikiPages.ps1 @@ -10,7 +10,7 @@ $repoDir = Join-Path $PSScriptRoot "..\" -Resolve Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` ForEach-Object { $result = Get-MofSchemaObject $_.FullName - Write-Output "Generating wiki page for $($result.FriendlyName)" + Write-Output "Generating wiki page for $($result.FriendlyName)" $output = "**Parameters**" + [Environment]::NewLine + [Environment]::NewLine diff --git a/appveyor.yml b/appveyor.yml index d45f76a78..689433c22 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,10 +22,10 @@ test_script: after_test: - ps: | - New-Item "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint\en-US" -ItemType Directory - & "$env:APPVEYOR_BUILD_FOLDER\Tests\Generate-xSharePointHelpFiles.ps1" -OutputPath "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint\en-US" + New-Item "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint\en-US" -ItemType Directory + & "$env:APPVEYOR_BUILD_FOLDER\Tests\Generate-xSharePointHelpFiles.ps1" -OutputPath "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint\en-US" - Remove-Item (Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.pssproj") + Remove-Item (Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.pssproj") $manifest = Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.psd1" (Get-Content $manifest -Raw).Replace("0.7.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest Add-Type -assemblyname System.IO.Compression.FileSystem From d981a299df24f9b5df884731faecef4cb8b5594b Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 16 Nov 2015 00:01:14 +1100 Subject: [PATCH 026/147] Updated documentation for search roles --- .../MSFT_xSPSearchIndexPartition.schema.mof | 20 +++++++++++++++ .../MSFT_xSPSearchRoles.schema.mof | 25 +++++++++++++++++++ .../MSFT_xSPSearchServiceApp.schema.mof | 3 --- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof index bb62f3994..d1cb08771 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof @@ -1,4 +1,24 @@ /* +**Description** + +This resource is responsible for creating search indexes. +It works by creating the index topology components and updating the topology from the server that runs this resource. +For this reason this resource only needs to run from one server and not from each server which will host the index component. +The search service application and existing search topology must be deployed before creating additional indexes. +The first index will be created through the use of the xSPSearchRoles resource. +Additional search index partitions can be created through using this resource. + +**Example** + + xSPSearchIndexPartition MainSearchPartition + { + Ensure = "Present" + Servers = "Server2,Server3" + Index = 1 + RootDirectory = "I:\SearchIndexes\1" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPSearchRoles]LocalSearchRoles" + } */ [ClassVersion("1.0.0.0"), FriendlyName("xSPSearchIndexPartition")] class MSFT_xSPSearchIndexPartition : OMI_BaseResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof index 3653c5439..2b5e7fb5c 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof @@ -1,4 +1,29 @@ /* +**Description** + +This resource is responsible for provisioning a search topology in to the current farm. +It allows the configuration to dictate the search topology roles that the current server should be running. +Any combination of roles can be specified and the topology will be upaded to reflect the current servers new roles. +If this is the first server to apply topology to a farm, then at least one search index must be provided. +To this end, the FirstPartitionIndex, FirstPartitionDirectory and FirstPartitionServers allow configuring where the first index partition will belong. +This will behave the same as the xSPSearchIndexPartition resource. + +**Example** + + xSPSearchRoles LocalSearchRoles + { + Ensure = "Present" + Admin = $true + Crawler = $true + ContentProcessing = $true + AnalyticsProcessing = $true + QueryProcessing = $true + ServiceAppName = "Search Service Application" + PsDscRunAsCredential = $SPSetupAccount + FirstPartitionIndex = 0 + FirstPartitionDirectory = "I:\SearchIndexes\0" + FirstPartitionServers = "Server1,Server2" + } */ [ClassVersion("1.0.0.0"), FriendlyName("xSPSearchRoles")] class MSFT_xSPSearchRoles : OMI_BaseResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.schema.mof index 314007287..3928e8293 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.schema.mof @@ -6,9 +6,6 @@ The current version lets you specify the database name and server, as well as th If the application pool is changed the DSC resource will set it back as per what is set in the resource. The database name parameter is used as the prefix for all search databases (so you will end up with one for the admin database which matches the name, and then "_analyticsreportingstore", "_crawlstore" and "_linkstore" databases as well). -In the current version of the module, it is not possible to apply a search topology via DSC, only provision the service application. -This is something that is coming in a future release. - **Example** xSPSearchServiceApp SearchServiceApp From 682f80fcc1bb8dfaa4c9739bc089fa2a26f1e483 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 16 Nov 2015 00:03:29 +1100 Subject: [PATCH 027/147] Fixed spacing --- .../MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof index 2b5e7fb5c..1069183b6 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof @@ -22,7 +22,7 @@ This will behave the same as the xSPSearchIndexPartition resource. PsDscRunAsCredential = $SPSetupAccount FirstPartitionIndex = 0 FirstPartitionDirectory = "I:\SearchIndexes\0" - FirstPartitionServers = "Server1,Server2" + FirstPartitionServers = "Server1,Server2" } */ [ClassVersion("1.0.0.0"), FriendlyName("xSPSearchRoles")] From 848d85571169441e39135c7d509ea1c4907116b6 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 16 Nov 2015 00:09:17 +1100 Subject: [PATCH 028/147] Fixed formatting of output --- Tests/Generate-xSharePointHelpFiles.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Tests/Generate-xSharePointHelpFiles.ps1 b/Tests/Generate-xSharePointHelpFiles.ps1 index a18677d2c..f49dde77a 100644 --- a/Tests/Generate-xSharePointHelpFiles.ps1 +++ b/Tests/Generate-xSharePointHelpFiles.ps1 @@ -12,12 +12,9 @@ Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` $result = Get-MofSchemaObject $_.FullName Write-Output "Generating help document for $($result.FriendlyName)" - $output = @" -NAME - $($result.FriendlyName) - -PARAMETERS -"@ + [Environment]::NewLine + $output = "NAME" + [Environment]::NewLine + $output += " $($result.FriendlyName)" + [Environment]::NewLine + [Environment]::NewLine + $output += "PARAMETERS" + [Environment]::NewLine foreach($property in $result.Attributes) { $output += " $($property.Name) ($($property.State), $($property.DataType)" From 719cce7a16f6b556cad540bb758b4060a013e772 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 16 Nov 2015 00:12:24 +1100 Subject: [PATCH 029/147] Fixed formatting --- Tests/Generate-xSharePointHelpFiles.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Generate-xSharePointHelpFiles.ps1 b/Tests/Generate-xSharePointHelpFiles.ps1 index f49dde77a..7d8c524f1 100644 --- a/Tests/Generate-xSharePointHelpFiles.ps1 +++ b/Tests/Generate-xSharePointHelpFiles.ps1 @@ -13,8 +13,8 @@ Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` Write-Output "Generating help document for $($result.FriendlyName)" $output = "NAME" + [Environment]::NewLine - $output += " $($result.FriendlyName)" + [Environment]::NewLine + [Environment]::NewLine - $output += "PARAMETERS" + [Environment]::NewLine + $output += " $($result.FriendlyName)" + [Environment]::NewLine + [Environment]::NewLine + $output += "PARAMETERS" + [Environment]::NewLine foreach($property in $result.Attributes) { $output += " $($property.Name) ($($property.State), $($property.DataType)" From d767d7400f7c332b8b95e21740230a13df3dbcb2 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 01:01:18 +0000 Subject: [PATCH 030/147] addressing Brian's comments --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 18 +++++------------- .../Examples/Single Server/Caller.ps1 | 3 --- .../xSharePoint.Util/xSharePoint.Util.psm1 | 5 +---- ...arePoint.xSPOutgoingEmailSettings.Tests.ps1 | 15 +++++++++------ ...rePoint.xSPPasswordChangeSettings.Tests.ps1 | 9 ++++++++- 5 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 Modules/xSharePoint/Examples/Single Server/Caller.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 index 124000077..862e8437b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -18,13 +18,10 @@ function Get-TargetResource $params = $args[0] $webApp = $null - if([string]::IsNullOrEmpty($params.WebAppUrl)){ - $webApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } - }else{ - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration - } + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + if ($null -eq $webApp ) { - throw "Web Application $webAppUrl not found" + return $null } return @{ WebAppUrl = $webApp.Url @@ -53,13 +50,8 @@ function Set-TargetResource Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $webApp = $null - if([string]::IsNullOrEmpty($params.WebAppUrl)){ - Write-Verbose -Message "retrieving global(CA) settings" - $webApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } - }else{ - Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration - } + Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration if($null -eq $webApp) { throw "Web Application $webAppUrl not found" diff --git a/Modules/xSharePoint/Examples/Single Server/Caller.ps1 b/Modules/xSharePoint/Examples/Single Server/Caller.ps1 deleted file mode 100644 index 8b65a099b..000000000 --- a/Modules/xSharePoint/Examples/Single Server/Caller.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -# -# Caller.ps1 -# diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index e1874bbaf..e6c9dc35b 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -26,10 +26,7 @@ function Get-xSharePointAssemblyVersion() { ) return (Get-Command $PathToAssembly).FileVersionInfo.FileMajorPart } -function Get-UtilAsScriptBlock(){ - $content = Get-Content (Resolve-Path .\xSharePoint.psd1) - write-host [Scriptblock]::Create($content ) -} + function Get-xSharePointInstalledProductVersion() { $pathToSearch = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\*\ISAPI\Microsoft.SharePoint.dll" diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index 7b049d724..f274d31b7 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -35,12 +35,12 @@ Describe "xSPOutgoingEmailSettings" { Mock Get-SPWebApplication -MockWith { return $null } - It "throws exception from the get method" { - {Get-TargetResource @testParams} | Should Throw + It "returns null from the get method" { + Get-TargetResource @testParams | Should be $null } - It "throws exception from the test method" { - { Test-TargetResource @testParams } | Should Throw + It "returns false from the test method" { + Test-TargetResource @testParams | Should be $false } } @@ -64,7 +64,7 @@ Describe "xSPOutgoingEmailSettings" { Test-TargetResource @testParams | Should Be $true } - } + } Context " Properties update tests " { @@ -78,7 +78,8 @@ Describe "xSPOutgoingEmailSettings" { } $result = $result | Add-Member ScriptMethod UpdateMailSettings { param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) - return ; } -passThru + $Global:UpdateMailSettingsCalled = $true; + return ; } -passThru return $result } @@ -87,8 +88,10 @@ Describe "xSPOutgoingEmailSettings" { } It "calls the new and set methods from the set function" { + $Global:UpdateMailSettingsCalled=$false; Set-TargetResource @testParams Assert-MockCalled Get-SPWebApplication + $Global:UpdateMailSettingsCalled | Should Be $true } } diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 0175e8e6f..f4b74ca28 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -72,7 +72,11 @@ Describe "xSPPasswordChangeSettings" { PasswordChangeMaximumTries=0 DaysBeforePasswordExpirationToSendEmail=0 } - $result = $result | Add-Member ScriptMethod Update { return $true} -passThru + $result = $result | Add-Member ScriptMethod Update { + $Global:UpdateCalledSPFarmUpdateCalled = $true; + return $true; + + } -passThru return $result } @@ -85,8 +89,11 @@ Describe "xSPPasswordChangeSettings" { } It "calls the new and set methods from the set function" { + $Global:UpdateCalledSPFarmUpdateCalled =$false; Set-TargetResource @testParams + Assert-MockCalled Get-SPFarm + $Global:UpdateCalledSPFarmUpdateCalled | Should Be $true } } From cc7c7c67ce99f5e6c80d6259fa8ce18490cae74e Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 01:03:55 +0000 Subject: [PATCH 031/147] fixing formatting issues on test files --- .../xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 | 2 +- .../xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index f274d31b7..747f3d304 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -91,7 +91,7 @@ Describe "xSPOutgoingEmailSettings" { $Global:UpdateMailSettingsCalled=$false; Set-TargetResource @testParams Assert-MockCalled Get-SPWebApplication - $Global:UpdateMailSettingsCalled | Should Be $true + $Global:UpdateMailSettingsCalled | Should Be $true } } diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index f4b74ca28..2ca671f37 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -91,7 +91,6 @@ Describe "xSPPasswordChangeSettings" { It "calls the new and set methods from the set function" { $Global:UpdateCalledSPFarmUpdateCalled =$false; Set-TargetResource @testParams - Assert-MockCalled Get-SPFarm $Global:UpdateCalledSPFarmUpdateCalled | Should Be $true } From b05dfa5e70b5ba572fafb21664b9f992ebe4b547 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 01:07:57 +0000 Subject: [PATCH 032/147] converting more tabs to 4 spaces.... hate you Brian --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 130 +++++++++--------- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 10 +- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 index 862e8437b..3d7d575ab 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -1,84 +1,84 @@ function Get-TargetResource { - [CmdletBinding()] - [OutputType([System.Collections.Hashtable])] - param - ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, - [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet - - ) + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + + ) - Write-Verbose -Message "Retrieving outgoing email settings configuration " + Write-Verbose -Message "Retrieving outgoing email settings configuration " - $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - - $webApp = $null - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $webApp = $null + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration - if ($null -eq $webApp ) { - return $null - } - return @{ - WebAppUrl = $webApp.Url - SMTPServer= $webApp.OutboundMailServiceInstance - FromAddress= $webApp.OutboundMailSenderAddress - ReplyToAddress= $webApp.OutboundMailReplyToAddress - CharacterSet = $webApp.OutboundMailCodePage - } - } - return $result + if ($null -eq $webApp ) { + return $null + } + return @{ + WebAppUrl = $webApp.Url + SMTPServer= $webApp.OutboundMailServiceInstance + FromAddress= $webApp.OutboundMailSenderAddress + ReplyToAddress= $webApp.OutboundMailReplyToAddress + CharacterSet = $webApp.OutboundMailCodePage + } + } + return $result } function Set-TargetResource { - [CmdletBinding()] - param - ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, - [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet - ) + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + ) - Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" - Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - $webApp = $null - Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration - if($null -eq $webApp) - { - throw "Web Application $webAppUrl not found" - } - $webApp.UpdateMailSettings($params.SMTPServer, $params.FromAddress, $params.ReplyToAddress, $params.CharacterSet) - } + Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" + Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $webApp = $null + Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + if($null -eq $webApp) + { + throw "Web Application $webAppUrl not found" + } + $webApp.UpdateMailSettings($params.SMTPServer, $params.FromAddress, $params.ReplyToAddress, $params.CharacterSet) + } } function Test-TargetResource { - [CmdletBinding()] - [OutputType([System.Boolean])] - param - ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, - [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet - ) + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + ) - $CurrentValues = Get-TargetResource @PSBoundParameters - Write-Verbose -Message "Comparing Current and Target Outgoing email settings" - if ($null -eq $CurrentValues) { return $false } - - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("WebAppUrl", "SMTPServer","FromAddress","ReplyToAddress","CharacterSet") + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Comparing Current and Target Outgoing email settings" + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("WebAppUrl", "SMTPServer","FromAddress","ReplyToAddress","CharacterSet") } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index dd3663744..2d6785787 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -1,10 +1,10 @@ [ClassVersion("1.0.0.0"), FriendlyName("xSPOutgoingEmailSettings")] class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource { - [key] string WebAppUrl; - [Write] string SMTPServer; - [Write] string FromAddress; - [Write] string ReplyToAddress; - [Write] string CharacterSet; + [key] string WebAppUrl; + [Write] string SMTPServer; + [Write] string FromAddress; + [Write] string ReplyToAddress; + [Write] string CharacterSet; }; From a85ecc73f40e90059fceaefafd1cf702954bd874 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 16 Nov 2015 14:08:45 +1100 Subject: [PATCH 033/147] Fixed issue with detection of search role components --- .../MSFT_xSPSearchRoles.psm1 | 20 +++++++++---------- .../xSharePoint.xSPSearchRoles.Tests.ps1 | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 index e648bbe18..0cd672943 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 @@ -48,23 +48,23 @@ function Get-TargetResource $currentTopology = $ssa.ActiveTopology #Make sure what we expect to be there is - $AdminComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "AdminComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $AdminComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "AdminComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if($AdminComponent1) { $AdminExists = $true } - $CrawlComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "CrawlComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $CrawlComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "CrawlComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if($CrawlComponent1) { $CrawlerExists = $true } - $ContentProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "ContentProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $ContentProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "ContentProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if($ContentProcessingComponent1) { $ContentProcessingExists = $true } - $AnalyticsProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "AnalyticsProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $AnalyticsProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "AnalyticsProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if($AnalyticsProcessingComponent1) { $AnalyticsProcessingExists = $true } - $QueryProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "QueryProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $QueryProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "QueryProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if($QueryProcessingComponent1) { $QueryProcessingExists = $true } @@ -197,23 +197,23 @@ function Set-TargetResource } Set-SPEnterpriseSearchTopology -Identity $newTopology } else { - $AdminComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "AdminComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $AdminComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "AdminComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if (($params.Admin -eq $false) -and ($null -ne $AdminComponent1)) { Remove-SPEnterpriseSearchComponent -Identity $AdminComponent1.ComponentId -SearchTopology $newTopology -confirm:$false } - $CrawlComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "CrawlComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $CrawlComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "CrawlComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if (($params.Crawler -eq $false) -and ($null -ne $CrawlComponent1)) { Remove-SPEnterpriseSearchComponent -Identity $CrawlComponent1.ComponentId -SearchTopology $newTopology -confirm:$false } - $ContentProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "ContentProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $ContentProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "ContentProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if (($params.ContentProcessing -eq $false) -and ($null -ne $ContentProcessingComponent1)) { Remove-SPEnterpriseSearchComponent -Identity $ContentProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false } - $AnalyticsProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "AnalyticsProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $AnalyticsProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "AnalyticsProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if (($params.AnalyticsProcessing -eq $false) -and ($null -ne $AnalyticsProcessingComponent1)) { Remove-SPEnterpriseSearchComponent -Identity $AnalyticsProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false } - $QueryProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "QueryProcessingComponent1") -and ($_.ServerName -eq $($ssi.Server.Address))} + $QueryProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "QueryProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} if (($params.QueryProcessing -eq $false) -and ($null -ne $QueryProcessingComponent1)) { Remove-SPEnterpriseSearchComponent -Identity $QueryProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false } diff --git a/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 index 30bc87fcc..b59ad1f0b 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 @@ -50,29 +50,29 @@ Describe "xSPSearchRoles" { } } - Add-Type -TypeDefinition "public class AdminComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - Add-Type -TypeDefinition "public class CrawlComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - Add-Type -TypeDefinition "public class ContentProcessingComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - Add-Type -TypeDefinition "public class AnalyticsProcessingComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - Add-Type -TypeDefinition "public class QueryProcessingComponent1 { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class AdminComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class CrawlComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class ContentProcessingComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class AnalyticsProcessingComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" + Add-Type -TypeDefinition "public class QueryProcessingComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - $adminComponent = New-Object AdminComponent1 + $adminComponent = New-Object AdminComponent $adminComponent.ServerName = $env:COMPUTERNAME $adminComponent.ComponentId = [Guid]::NewGuid() - $crawlComponent = New-Object CrawlComponent1 + $crawlComponent = New-Object CrawlComponent $crawlComponent.ServerName = $env:COMPUTERNAME $crawlComponent.ComponentId = [Guid]::NewGuid() - $contentProcessingComponent = New-Object ContentProcessingComponent1 + $contentProcessingComponent = New-Object ContentProcessingComponent $contentProcessingComponent.ServerName = $env:COMPUTERNAME $contentProcessingComponent.ComponentId = [Guid]::NewGuid() - $analyticsProcessingComponent = New-Object AnalyticsProcessingComponent1 + $analyticsProcessingComponent = New-Object AnalyticsProcessingComponent $analyticsProcessingComponent.ServerName = $env:COMPUTERNAME $analyticsProcessingComponent.ComponentId = [Guid]::NewGuid() - $queryProcessingComponent = New-Object QueryProcessingComponent1 + $queryProcessingComponent = New-Object QueryProcessingComponent $queryProcessingComponent.ServerName = $env:COMPUTERNAME $queryProcessingComponent.ComponentId = [Guid]::NewGuid() From 73448724c7b356121b6059fe2c456f1527545a60 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 16 Nov 2015 14:09:28 +1100 Subject: [PATCH 034/147] Fixed issue with property skipping in test parameter method --- .../xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 00d906fd2..825be2900 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -154,7 +154,7 @@ function Test-xSharePointSpecificParameters() { } $KeyList | ForEach-Object { - if (($_ -ne "Verbose") -or ($_ -ne "InstallAccount")) { + if (($_ -ne "Verbose") -and ($_ -ne "InstallAccount")) { if (($CurrentValues.ContainsKey($_) -eq $false) -or ($CurrentValues.$_ -ne $DesiredValues.$_)) { if ($DesiredValues.ContainsKey($_)) { $desiredType = $DesiredValues.$_.GetType() From 33dee6ecc85747d3e2d6901f0f3e9621b1b6b86f Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 12:34:18 +0000 Subject: [PATCH 035/147] adding BlockedFileTypes --- .../MSFT_xSPWebApplication.psm1 | 28 +++- ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 6 +- .../xSharePoint.xSPWebApplication.Tests.ps1 | 120 ++++++++++++++++++ 3 files changed, 146 insertions(+), 8 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 1b519c8a6..f152c1963 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -15,7 +15,8 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes ) Write-Verbose -Message "Getting web application '$Name'" @@ -44,6 +45,7 @@ function Get-TargetResource Port = (New-Object System.Uri $wa.Url).Port AuthenticationMethod = $localAuthMode InstallAccount = $params.InstallAccount + BlockedFileTypes = $wa.BlockedFileExtensions } } return $result @@ -66,7 +68,8 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes ) Write-Verbose -Message "Creating web application '$Name'" @@ -74,6 +77,12 @@ function Set-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] + $blockedFileTypes = $null + if($params.ContainsKey("BlockedFileTypes")) + { + $blockedFileTypes =$params.BlockedFileTypes + $params.Remove("BlockedFileTypes") + } $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { @@ -92,9 +101,17 @@ function Set-TargetResource $params.Remove("AllowAnonymous") | Out-Null $params.Add("AllowAnonymousAccess", $true) } - - New-SPWebApplication @params + + $wa = New-SPWebApplication @params } + write-host "bla" + write-debug "bla" + if($blockedFileTypes -ne $null){ + $wa.BlockedFileExtensions.RemoveAll(); + $blockedFileTypes| % {$wa.BlockedFileExtensions.Add($_) } + $wa.Update() + } + } } @@ -116,7 +133,8 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 2ca671f37..0f19af5e3 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -73,7 +73,7 @@ Describe "xSPPasswordChangeSettings" { DaysBeforePasswordExpirationToSendEmail=0 } $result = $result | Add-Member ScriptMethod Update { - $Global:UpdateCalledSPFarmUpdateCalled = $true; + $Global:SPFarmUpdateCalled = $true; return $true; } -passThru @@ -89,10 +89,10 @@ Describe "xSPPasswordChangeSettings" { } It "calls the new and set methods from the set function" { - $Global:UpdateCalledSPFarmUpdateCalled =$false; + $Global:SPFarmUpdateCalled =$false; Set-TargetResource @testParams Assert-MockCalled Get-SPFarm - $Global:UpdateCalledSPFarmUpdateCalled | Should Be $true + $Global:SPFarmUpdateCalled | Should Be $true } } diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 9bcb0d0bf..583af04e9 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -32,6 +32,7 @@ Describe "xSPWebApplication" { Mock New-SPAuthenticationProvider { } Mock New-SPWebApplication { } + Context "The web application that uses NTLM doesn't exist but should" { Mock Get-SPWebApplication { return $null } @@ -150,5 +151,124 @@ Describe "xSPWebApplication" { Test-TargetResource @testParams | Should Be $true } } + + Context "backwards compatibility: set target resorce works with null/missing BlockedFileTypes" { + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } + Mock Get-SPWebApplication { + $result = @(@{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + }) + $blockedFileTypes= @(); + $blockedFileTypes= $blockedFileTypes | Add-Member ScriptMethod RemoveAll { + $Global:BlockedFilesRemoveAllCalled = $true; + return $true; + } -passThru + $blockedFileTypes= $blockedFileTypes | Add-Member ScriptMethod Add { + param( [string]$fileType) + $Global:BlockedFilesAddCalled = $true; + return $true; + } -passThru + $result= $result | Add-Member -MemberType MemberSet -value $blockedFileTypes -Name "BlockedFileExtensions" + $result = $result | Add-Member -MemberType ScriptMethod Update { + $Global:SPWebApplicationUpdateCalled = $true; + return $true; + + } -PassThru + return $result; + } + + It "calls the new cmdlet from the set method and does not touch blockedFileExtensions" { + $Global:SPWebApplicationUpdateCalled = $false; + $Global:BlockedFilesAddCalled = $false; + $Global:BlockedFilesRemoveAllCalled = $false; + Set-TargetResource @testParams + $Global:BlockedFilesAddCalled| Should be $false; + $Global:BlockedFilesRemoveAllCalled| Should be $false; + $Global:SPWebApplicationUpdateCalled| Should be $false; + Assert-MockCalled New-SPWebApplication + } + + } + + $testParams = @{ + Name = "Managed Metadata Service App" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + BlockedFileTypes = @("java", "vbs") + } + + + Context "set target resorce works with blockedFileTypes" { + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } + + Mock Get-SPWebApplication { $result= @(@{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + }) + + $blockedFileTypes = new-object PSObject + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod RemoveAll { + $Global:BlockedFilesRemoveAllCalled = $true; + return $true; + } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { + param( [string]$fileType) + $Global:BlockedFilesAddCalled = $true; + return $true; + } -passThru + + $result=$result| Add-Member ScriptMethod Update { + $Global:SPWebApplicationUpdateCalled = $true; + return $true; + } -PassThru + + $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru + + return $result + } + + It "calls the new cmdlet from the set method and does update blockedFileExtensions" { + $Global:BlockedFilesAddCalled = $false; + $Global:BlockedFilesRemoveAllCalled = $false; + Set-TargetResource @testParams + $Global:BlockedFilesAddCalled| Should be $true; + $Global:BlockedFilesRemoveAllCalled| Should be $true; + $Global:SPWebApplicationUpdateCalled| Should be $true; + + Assert-MockCalled Get-SPWebApplication + } + + } + + } } \ No newline at end of file From ee6599e4ac2a906ff8a0a24d0e21e2403990efe6 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 13:25:50 +0000 Subject: [PATCH 036/147] Added blocked file types, integration and unit tested --- .../MSFT_xSPWebApplication.psm1 | 2 +- .../MSFT_xSPWebApplication.schema.mof | 1 + .../xSharePoint.xSPWebApplication.Tests.ps1 | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index f152c1963..4c06b4dfb 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -107,7 +107,7 @@ function Set-TargetResource write-host "bla" write-debug "bla" if($blockedFileTypes -ne $null){ - $wa.BlockedFileExtensions.RemoveAll(); + $wa.BlockedFileExtensions.Clear(); $blockedFileTypes| % {$wa.BlockedFileExtensions.Add($_) } $wa.Update() } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index fc82bdb44..da434a758 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -13,5 +13,6 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Path; [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Write] string BlockedFileTypes[]; }; diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 583af04e9..d520bfb12 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -184,7 +184,7 @@ Describe "xSPWebApplication" { } -passThru $result= $result | Add-Member -MemberType MemberSet -value $blockedFileTypes -Name "BlockedFileExtensions" $result = $result | Add-Member -MemberType ScriptMethod Update { - $Global:SPWebApplicationUpdateCalled = $true; + $Global:BlockedFilesClearCalled = $true; return $true; } -PassThru @@ -194,10 +194,10 @@ Describe "xSPWebApplication" { It "calls the new cmdlet from the set method and does not touch blockedFileExtensions" { $Global:SPWebApplicationUpdateCalled = $false; $Global:BlockedFilesAddCalled = $false; - $Global:BlockedFilesRemoveAllCalled = $false; + $Global:BlockedFilesClearCalled = $false; Set-TargetResource @testParams $Global:BlockedFilesAddCalled| Should be $false; - $Global:BlockedFilesRemoveAllCalled| Should be $false; + $Global:BlockedFilesClearCalled| Should be $false; $Global:SPWebApplicationUpdateCalled| Should be $false; Assert-MockCalled New-SPWebApplication } @@ -236,8 +236,8 @@ Describe "xSPWebApplication" { }) $blockedFileTypes = new-object PSObject - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod RemoveAll { - $Global:BlockedFilesRemoveAllCalled = $true; + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { + $Global:BlockedFilesClearCalled = $true; return $true; } -passThru $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { @@ -258,10 +258,10 @@ Describe "xSPWebApplication" { It "calls the new cmdlet from the set method and does update blockedFileExtensions" { $Global:BlockedFilesAddCalled = $false; - $Global:BlockedFilesRemoveAllCalled = $false; + $Global:BlockedFilesClearCalled = $false; Set-TargetResource @testParams $Global:BlockedFilesAddCalled| Should be $true; - $Global:BlockedFilesRemoveAllCalled| Should be $true; + $Global:BlockedFilesClearCalled| Should be $true; $Global:SPWebApplicationUpdateCalled| Should be $true; Assert-MockCalled Get-SPWebApplication From a4b76d78bd4148c68294742d988ccf3f2986aefa Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 17 Nov 2015 11:40:50 +1100 Subject: [PATCH 037/147] comments addressed, but no test done. commiting so code is available on integration server --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 27 +++++++-------- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 1 + .../MSFT_xSPPasswordChangeSettings.psm1 | 13 +++++--- .../MSFT_xSPPasswordChangeSettings.schema.mof | 1 + .../MSFT_xSPWebApplication.psm1 | 33 ++++++++++++++----- .../MSFT_xSPWebApplication.schema.mof | 2 ++ ...rePoint.xSPOutgoingEmailSettings.Tests.ps1 | 8 ++--- .../xSharePoint.xSPWebApplication.Tests.ps1 | 25 +++++++++----- 8 files changed, 71 insertions(+), 39 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 index 3d7d575ab..ec120c409 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -8,27 +8,26 @@ function Get-TargetResource [parameter(Mandatory = $true)] [System.String] $SMTPServer, [parameter(Mandatory = $true)] [System.String] $FromAddress, [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Retrieving outgoing email settings configuration " - $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - - $webApp = $null - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration -ErrorAction SilentlyContinue if ($null -eq $webApp ) { return $null } return @{ - WebAppUrl = $webApp.Url - SMTPServer= $webApp.OutboundMailServiceInstance - FromAddress= $webApp.OutboundMailSenderAddress - ReplyToAddress= $webApp.OutboundMailReplyToAddress - CharacterSet = $webApp.OutboundMailCodePage + WebAppUrl = $webApp.Url + SMTPServer= $webApp.OutboundMailServiceInstance + FromAddress= $webApp.OutboundMailSenderAddress + ReplyToAddress= $webApp.OutboundMailReplyToAddress + CharacterSet = $webApp.OutboundMailCodePage } } return $result @@ -43,11 +42,12 @@ function Set-TargetResource [parameter(Mandatory = $true)] [System.String] $SMTPServer, [parameter(Mandatory = $true)] [System.String] $FromAddress, [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" - Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $webApp = $null Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" @@ -71,7 +71,8 @@ function Test-TargetResource [parameter(Mandatory = $true)] [System.String] $SMTPServer, [parameter(Mandatory = $true)] [System.String] $FromAddress, [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index 2d6785787..f1b5295c6 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -6,5 +6,6 @@ class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource [Write] string FromAddress; [Write] string ReplyToAddress; [Write] string CharacterSet; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 31f0093cb..ef256a103 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -7,12 +7,13 @@ function Get-TargetResource [parameter(Mandatory = $true)][System.String] $MailAddress, [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Retrieving farm wide automatic password change settings" - $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $farm = Get-SPFarm @@ -35,13 +36,14 @@ function Set-TargetResource [parameter(Mandatory = $true)][System.String] $MailAddress, [parameter(Mandatory = $false)][ValidateRange(0,356 )][System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99 )][System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,99 )][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Updating farm wide automatic password change settings" Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $farm = Get-SPFarm + $farm = Get-SPFarm -ErrorAction Continue if ($null -eq $farm ) { return $null } @@ -70,7 +72,8 @@ function Test-TargetResource [parameter(Mandatory = $true)][System.String] $MailAddress, [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index 3ac447092..294cd6b19 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -5,4 +5,5 @@ class MSFT_xSPPasswordChangeSettings : OMI_BaseResource [Write] Uint32 DaysBeforeExpiry; [Write] Uint32 PasswordChangeWaitTimeSeconds; [Write] Uint32 NumberOfRetries; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 4c06b4dfb..f20b2a8e1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -16,7 +16,8 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, + [parameter(Mandatory = $false)][string[]] $AllowedFileTypes ) Write-Verbose -Message "Getting web application '$Name'" @@ -69,7 +70,8 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, + [parameter(Mandatory = $false)][string[]] $AllowedFileTypes ) Write-Verbose -Message "Creating web application '$Name'" @@ -83,6 +85,12 @@ function Set-TargetResource $blockedFileTypes =$params.BlockedFileTypes $params.Remove("BlockedFileTypes") } + $allowedFileTypes = $null + if($params.ContainsKey("AllowedFileTypes")) + { + $allowedFileTypes =$params.BlockedFileTypes + $params.Remove("AllowedFileTypes") + } $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { @@ -104,14 +112,22 @@ function Set-TargetResource $wa = New-SPWebApplication @params } - write-host "bla" - write-debug "bla" - if($blockedFileTypes -ne $null){ - $wa.BlockedFileExtensions.Clear(); - $blockedFileTypes| % {$wa.BlockedFileExtensions.Add($_) } + $blockedFileTypes| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } + } + $allowedFileTypes| % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } + } + if(($allowedFileTypes -ne $null) -or ($blockedFileTypes -ne $null)){ $wa.Update() } + + } } @@ -134,7 +150,8 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, + [parameter(Mandatory = $false)][string[]] $AllowedFileTypes ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index da434a758..56bb066da 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -14,5 +14,7 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Write] string BlockedFileTypes[]; + [Write] string AllowedFileTypes[]; + }; diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index 747f3d304..f3e206d1e 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -15,7 +15,7 @@ Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName Describe "xSPOutgoingEmailSettings" { InModuleScope $ModuleName { $testParams = @{ - WebAppUrl = "http://sp2013.australiasoutheast.cloudapp.azure.com" + WebAppUrl = "http://sharepoint.contoso.com" SMTPServer = "smtp.contoso.com" FromAddress = "from@email.com" ReplyToAddress = "reply@email.com" @@ -36,7 +36,7 @@ Describe "xSPOutgoingEmailSettings" { } It "returns null from the get method" { - Get-TargetResource @testParams | Should be $null + Get-TargetResource @testParams | Should BeNullOrEmpty } It "returns false from the test method" { @@ -48,7 +48,7 @@ Describe "xSPOutgoingEmailSettings" { Context " Properties match" { Mock Get-SPWebApplication { return @{ - Url= "http://sp2013.australiasoutheast.cloudapp.azure.com" + Url= "http://sharepoint.contoso.com" OutboundMailServiceInstance= "smtp.contoso.com" OutboundMailSenderAddress = "from@email.com" OutboundMailReplyToAddress= "reply@email.com" @@ -70,7 +70,7 @@ Describe "xSPOutgoingEmailSettings" { Context " Properties update tests " { Mock Get-SPWebApplication { $result = @{ - Url= "http://sp2013.australiasoutheast.cloudapp.azure.com" + Url= "http://sharepoint.contoso.com" OutboundMailServiceInstance= "smtp2.contoso.com" OutboundMailSenderAddress = "from@email.com" OutboundMailReplyToAddress= "reply@email.com" diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index d520bfb12..f78d25f2c 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -211,6 +211,7 @@ Describe "xSPWebApplication" { Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" BlockedFileTypes = @("java", "vbs") + AllowedFileTypes = @("exe", "vbs") } @@ -234,26 +235,32 @@ Describe "xSPWebApplication" { ) Url = $testParams.Url }) - $blockedFileTypes = new-object PSObject - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Remove { $Global:BlockedFilesClearCalled = $true; return $true; } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Contains { + param($extension) + if($extension -eq "exe"){ + return $true + } + return $false + } + $Global:BlockedFilesContainsCalled = $true; + return $true; + } -passThru $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { param( [string]$fileType) $Global:BlockedFilesAddCalled = $true; return $true; } -passThru - $result=$result| Add-Member ScriptMethod Update { $Global:SPWebApplicationUpdateCalled = $true; return $true; - } -PassThru - - $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru - - return $result + } -PassThru + $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru + return $result } It "calls the new cmdlet from the set method and does update blockedFileExtensions" { @@ -261,7 +268,7 @@ Describe "xSPWebApplication" { $Global:BlockedFilesClearCalled = $false; Set-TargetResource @testParams $Global:BlockedFilesAddCalled| Should be $true; - $Global:BlockedFilesClearCalled| Should be $true; + $Global:BlockedFilesContainsCalled| Should be $true; $Global:SPWebApplicationUpdateCalled| Should be $true; Assert-MockCalled Get-SPWebApplication From bec372042673c54c122caa8dfdb057fea75129b1 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Tue, 17 Nov 2015 01:05:34 +0000 Subject: [PATCH 038/147] Unit tests updated, integration tests done. --- .../MSFT_xSPWebApplication.psm1 | 20 +++++++++++-------- .../xSharePoint.xSPWebApplication.Tests.ps1 | 7 +++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index f20b2a8e1..29fca0a98 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -80,15 +80,15 @@ function Set-TargetResource $params = $args[0] $blockedFileTypes = $null + $allowedFileTypes = $null if($params.ContainsKey("BlockedFileTypes")) { $blockedFileTypes =$params.BlockedFileTypes $params.Remove("BlockedFileTypes") } - $allowedFileTypes = $null if($params.ContainsKey("AllowedFileTypes")) { - $allowedFileTypes =$params.BlockedFileTypes + $allowedFileTypes =$params.AllowedFileTypes $params.Remove("AllowedFileTypes") } @@ -112,14 +112,18 @@ function Set-TargetResource $wa = New-SPWebApplication @params } - $blockedFileTypes| % { - if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; + if($blockedFileTypes -ne $null){ + $blockedFileTypes| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } } } - $allowedFileTypes| % { - if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) + if($allowedFileTypes -ne $null){ + $allowedFileTypes| % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } } } if(($allowedFileTypes -ne $null) -or ($blockedFileTypes -ne $null)){ diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index f78d25f2c..f98961d86 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -240,15 +240,14 @@ Describe "xSPWebApplication" { $Global:BlockedFilesClearCalled = $true; return $true; } -passThru - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Contains { + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod ContainExtension { param($extension) + $Global:BlockedFilesContainsCalled = $true; if($extension -eq "exe"){ return $true } return $false - } - $Global:BlockedFilesContainsCalled = $true; - return $true; + } -passThru $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { param( [string]$fileType) From 5bf425fda7d3824d41fbe2ebe6a3059158afd6c1 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 17 Nov 2015 15:39:18 +1100 Subject: [PATCH 039/147] fixing formatting, again. --- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index f1b5295c6..b6f92db87 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -6,6 +6,6 @@ class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource [Write] string FromAddress; [Write] string ReplyToAddress; [Write] string CharacterSet; - [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; From 28ad68844189a73d29cff5ea7adfacacb4885d17 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 17 Nov 2015 15:42:59 +1100 Subject: [PATCH 040/147] trying formatting again (.mof files were not converting tabs to 4 spaces.) --- .../MSFT_xSPPasswordChangeSettings.schema.mof | 2 +- .../MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index 294cd6b19..3ff4a1652 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -5,5 +5,5 @@ class MSFT_xSPPasswordChangeSettings : OMI_BaseResource [Write] Uint32 DaysBeforeExpiry; [Write] Uint32 PasswordChangeWaitTimeSeconds; [Write] Uint32 NumberOfRetries; - [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 56bb066da..2bf064823 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -14,7 +14,7 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Write] string BlockedFileTypes[]; - [Write] string AllowedFileTypes[]; + [Write] string AllowedFileTypes[]; }; From dafdbdd318ef34a74ef34094c161df1ddf52fd26 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 18 Nov 2015 12:21:33 +0000 Subject: [PATCH 041/147] Added xSPAntivirusSettings and xSPFarmAdministrators Added the resources xSPAntivirusSettings and xSPFarmAdministrators (still under discussion, currently only a demo) --- .../MSFT_xSPAntivirusSettings.psm1 | 113 ++++++++++++++++++ .../MSFT_xSPAntivirusSettings.schema.mof | Bin 0 -> 854 bytes .../MSFT_xSPFarmAdministrators.psm1 | Bin 0 -> 17184 bytes .../MSFT_xSPFarmAdministrators.schema.mof | Bin 0 -> 678 bytes .../xSharePoint.Util/xSharePoint.Util.psm1 | 7 +- 5 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 new file mode 100644 index 000000000..2941a1de6 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 @@ -0,0 +1,113 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting antivirus configuration settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + + # Get a reference to the Administration WebService + $admService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService + + if ($null -eq $admService) { return $null } + + return @{ + # Set the antivirus settings + AllowDownloadInfected = $admService.AntivirusSettings.AllowDownload + ScanOnDownload = $admService.AntivirusSettings.DownloadScanEnabled + ScanOnUpload = $admService.AntivirusSettings.UploadScanEnabled + AttemptToClean = $admService.AntivirusSettings.CleaningEnabled + NumberOfThreads = $admService.AntivirusSettings.NumberOfThreads + TimeoutDuration = $admService.AntivirusSettings.Timeout.TotalSeconds + InstallAccount = $params.InstallAccount + } + } + + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting antivirus configuration settings" + + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + Write-Verbose -Message "Start update" + # Load the SharePoint Assembly, using old style for backward compatibility with V1 + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + + # Get a reference to the Administration WebService + $admService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService + + # Set the antivirus settings + if ($params.ContainsKey("AllowDownloadInfected")) { + Write-Verbose -Message "Setting Allow Download" + $admService.AntivirusSettings.AllowDownload = $params.AllowDownloadInfected + } + if ($params.ContainsKey("ScanOnDownload")) { $admService.AntivirusSettings.DownloadScanEnabled = $params.ScanOnDownload } + if ($params.ContainsKey("ScanOnUpload")) { $admService.AntivirusSettings.UploadScanEnabled = $params.ScanOnUpload } + if ($params.ContainsKey("AttemptToClean")) { $admService.AntivirusSettings.CleaningEnabled = $params.AttemptToClean } + if ($params.ContainsKey("NumberOfThreads")) { $admService.AntivirusSettings.NumberOfThreads = $params.NumberOfThreads } + if ($params.ContainsKey("TimeoutDuration")) { + $timespan = New-TimeSpan -Seconds $params.TimeoutDuration + $admService.AntivirusSettings.Timeout = $timespan + } + + $admService.Update() + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Testing antivirus configuration settings" + $CurrentValues = Get-TargetResource @PSBoundParameters + + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof new file mode 100644 index 0000000000000000000000000000000000000000..0b8c87fdb151c816b0b53d66d14aee3fe4c45b47 GIT binary patch literal 854 zcmbV~OH0E*6ot=P@IQpE6h!RCg|1??P{dYjY8OQ$CTT6CX-QIR5&ydS-AQRd@lhEj zb0>4px#vFK-*&a5ff`B`s$ktJQO-HmRGIcvQ(cETTJM_nbs$eoyvF!uioq_`20!6$ zh-Ywl&Zt|Cea+KuuXG_YmD48X{+PxSjK|;7mC~@;&{;(s#8e!T!e7 z)9jxtJ~)fN_@btTvLUe}Dw}Mr&UYP2=-mt}AcD<8RfV7P?9o^2a9zjLE8u4Rw|bXo zw5o?#)f{cZ)CN1z16(;h9m4#GWr||@`8|_O<;4ma<7>6B+7zg;p4tr9bZ+LW;dsrn jn$(cYtC_U^m%LhrBX~DF)&(D~$YpA{O3~};v?==l4J?gg literal 0 HcmV?d00001 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 new file mode 100644 index 0000000000000000000000000000000000000000..618ca5c05595a071db0674d5278a00114fd9526b GIT binary patch literal 17184 zcmeHOTW=Fb6rSfw{SPa5ACeYZ{D4w%DNxiFA`;*sLX}Az&CP3+>zh~h{mZD2GfRIT?T}ifb0@gdr-$gD+_E&e zAK-e&{EmBa(Z`c1o_s| zMOvizYtQV#`tCue11me099jDity8k}CtA!HEga!PKV~`KFLv#n|KtVQ9HGjmT`l<)8~t2kA-=Fs~Ko6(EBm|`F><+qQ8k}%~79y`~8=e zr#WaHqm+0axp@yN-dL(Wg7eq5^#PyC@1qV~yzrmX@YHIu`@wRVXfU8&dKf_1()mXfb zem;0_$7q=~)C$-m0Y3C|QzfF1)ZI?Qsuh7Pi z%@fFAVrAg!Htj98XV-@2498Os)*+tdO3jf)N|WOw%%I9UHMRhsGtf@!j9bXj)`YLNlXGW&A4YP zVQx1-QoaQ+gA?r$T@JqFD(&+&^b=+%;z#1#dtNQg#mtg2g7SOtuj}ls-V$i+I$f1T(`Uth*bilFo2|j|^i2R)VIch##>XzvJ2~g#qc+W93ZT~5*!11fv98`3<<(RE-`Wp3UDpQcBFlP~kh7N>7Uay1 zM7vv{C6-@KD=MEHZq#}ITszIRo3^<2b?p2l)N>s@_1ZoG4j|TaW0T9*xZ{Q>MD(8K zB&W5D)xNf-|KZ3awh)&sLfjmW?dmZ=-mjaCKjPk+k4RFojr~vba~n}5jq_6Y?9}El zS+{byY<)SYPE_VypcanT8E@-Hwz3w<@owK@!?`W*)0Uqn&|dXFudNb3QTMGppPg9a;BfIA%B-#$6J>}w$!NkI^BCEHN&DYK1p)Oa8)ZsjF z+mSl#ZPQ4d&X{e+>yZ9>X{kSHyxu%Yw;OdfkIf;XSv5k}Y4W

2yxw#N1W|^+Mxnb}G=k~Bzaqh%B70xZ z9P@PD4jGPT{nno?=j7(Ws9!Rc%Ui@B@#^~la1rOp+FgG?#5`b=U4Gn6!+n0lY7^{M ztL_$bt5iOk+OFeo*YUUO_-*Xu)99dCsL5Efu+eCNm?E{RvCsEhhvdRh{B|urH3K7S zL7}8rF2v6%{9o09%L?h>ht$gyORul$-4L)N2fM@H14gr*KX&LIri#c#Nf}$ZZeN7d;5xt4J{D=xD!V0 zGH=gnn`ujQt@yU6b@YD~U)DN#pH9o@ddwax2XW@k`Dlm?+V;_~x6AR-u+Mr9Renxd zo38L&m$}2Q%^$CJmQd{|_QNU;@pCNWn5z-b!mK+FBs-D!5Ow9mBKNT!CeK9H&l$z% zy;4#65$0pA`n*+o&WmHk)z4Vf?;qyMCQp0u9L~+qiIQo0KQUh!n4z#{`KR4o`6maE3_AGZ;LNKE>J@=QakxsT#`c V0iN@Oj5{s;J)Y)fG$})V{{y;>@R$Gq literal 0 HcmV?d00001 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof new file mode 100644 index 0000000000000000000000000000000000000000..2af8ede60ca029a2ecc2974a4c631e6530db13bf GIT binary patch literal 678 zcmb`FK}*9x5QX2l;D1d>*Sl>BgUQ4|YZH5tuzq6<49-+l1 zvtowXKja%Q(Vylsmk0Z9Qm>!79`i7EU5(pcZuRLpb7Tc32UYMln8U}jwZ57>1(+V1 P5_idX&BV6*(;V9Y7NKw$ literal 0 HcmV?d00001 diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index fa7b44dc9..621c6e58f 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -154,7 +154,7 @@ function Test-xSharePointSpecificParameters() { } $KeyList | ForEach-Object { - if ($_ -ne "Verbose") { + if (($_ -ne "Verbose") -and ($_ -ne "InstallAccount")) { if (($CurrentValues.ContainsKey($_) -eq $false) -or ($CurrentValues.$_ -ne $DesiredValues.$_)) { if ($DesiredValues.ContainsKey($_)) { $desiredType = $DesiredValues.$_.GetType() @@ -170,6 +170,11 @@ function Test-xSharePointSpecificParameters() { $returnValue = $false } } + "Int16" { + if (($DesiredValues.$fieldName -eq 0) -and ($CurrentValues.$fieldName -eq $null)) {} else { + $returnValue = $false + } + } default { $returnValue = $false } From 18b50f091bb4c399440c93b19cc4cc97ecb920e3 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Thu, 19 Nov 2015 16:03:00 +0100 Subject: [PATCH 042/147] Converted files to UTF-8 Converted files to UTF-8 --- .../MSFT_xSPAntivirusSettings.schema.mof | Bin 854 -> 413 bytes .../MSFT_xSPFarmAdministrators.psm1 | Bin 17184 -> 8367 bytes .../MSFT_xSPFarmAdministrators.schema.mof | Bin 678 -> 327 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof index 0b8c87fdb151c816b0b53d66d14aee3fe4c45b47..03bfc3fb846cef64c0717f80bcb390003b3985b9 100644 GIT binary patch literal 413 zcmZ{g!Ab)$5Qgu0ieXPJ6tNc%?rFQVut>Y&ZuL+~iOEz0*-1$z)*`;U*@|GLojJ}o z{|}#7l~#uEggzKYgKT_t-ETG=!OR;ZZ4V3C;UN2H9tvXfZhQ<4G8=jg*>EjX{|@tJ z)^5%ra0~Uk+Dv4?M+`1{h2m2{n$GRJ29Kcpn@6d`UuFb% o>83U6iULbg$>Pyd=}}{HDQyx64g2I0j*PX1QZ5qb;wu;88$&RPy#N3J literal 854 zcmbV~OH0E*6ot=P@IQpE6h!RCg|1??P{dYjY8OQ$CTT6CX-QIR5&ydS-AQRd@lhEj zb0>4px#vFK-*&a5ff`B`s$ktJQO-HmRGIcvQ(cETTJM_nbs$eoyvF!uioq_`20!6$ zh-Ywl&Zt|Cea+KuuXG_YmD48X{+PxSjK|;7mC~@;&{;(s#8e!T!e7 z)9jxtJ~)fN_@btTvLUe}Dw}Mr&UYP2=-mt}AcD<8RfV7P?9o^2a9zjLE8u4Rw|bXo zw5o?#)f{cZ)CN1z16(;h9m4#GWr||@`8|_O<;4ma<7>6B+7zg;p4tr9bZ+LW;dsrn jn$(cYtC_U^m%LhrBX~DF)&(D~$YpA{O3~};v?==l4J?gg diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 index 618ca5c05595a071db0674d5278a00114fd9526b..77d0480a5e9b2d1792c87ae8820da2b90ba80645 100644 GIT binary patch literal 8367 zcmeHNTW{Mo6n^)wAUr+TTP5@dtV0v8?Sd_9P^axf5Dbh&+gfGOC8?%CmjAwU4kePh zM5&jc7pz9%BoYtL?K>A9c2$+B$z{o22os-jwHD@;(6Umgm|Ra7e9jiztPtifFSEQ{ z&*ta$>C4LODsy_Z6SK4Bl{R9VEM!p#+D#|FalJA8q7dgb!Hz4wCDIvv)7JD*7@=mz zyv(?f>WV#Kkx`YHpR;D)rBT57oJD`~t$1`N^@Z7#m7Qx*p5vB4hD?QfQmimYRe9?ZC>WuDD;w^TIxs%T@?m=c2s_l??n7@ zx#3Ej$h2a-g+Lb8bZT^0E|)-VRVX3wOwu;3j&c z&!RR98;@uhB}}DC=HItBODYXkOnSF}7#!Z4KM~Gz@^r%to*}Ju_Dpn2}JBAY9pHZZ_c>$BzNGn$Gd^8$hDM$N)g&k7!XT1xeuz zFDjwyaBdep_OzFWENQyo}sN zyk}8a6-6jJuI$L)hmK}zN`6p`(v8pw`%|)2rO1&xudNdAs~pOdSMr7lsNDfh_F|Vw zFb(2~_$KT`sFj4$l}hkB^d%nz+ONnNpH=gk z<%sejLT=Z;Wsy1^HTKI_GiSntoXX<0VUNN8tVM?eeK%p^h=Ls!*yGJHsY0p(=V4~O zHAed$je<;#huOx<@mBCp6 zSr1l|ahZ6b1kbM6uw2V``ECaQ^cE*Jj%fh*Pmbx1eIVc-FrGg-mPg<`0^s`48Um)H z&JciWs&N1Zv9}k72Sh?2QQ)<@zXAAm`i?u0awl@@L^51D!sNmp4!_v_JP39J`;VsS zj=xFghfdKg6xUWANzZ#>+4b)uAjXlv6|-frK2RVwY~KQ03^90A57aOn5P1xgP$ z?L+mc(Dxp<9ZFdUUVb02*>hKKVEA<(yb%EyDE-ciX?rHGp+@it8;Aef(Yt4Wkx=c| zo1roj9E-lSvvj-lXy$gU#(S{s>E!7?>Y6iq`w%_M&d)h854IWvKM|%We$RKVf8EQ8 zj%vu8-$+vnlQx*p(zqPjS~6kVx@gP5d~G9>p@*g;_@d+7pvS&%KTB-w@GMM0Zql}= z7e`vZaW8)1w(g7g?moR-;I}46_}RW2?T>XZ*Au#lVY4%TmDg%(>I)=~*!y1r1x?fK zmp{I-qRE6>>$At_7NV#%!8F*&_4&VxtJxHeSJT!Y8cEz$4s7_DE|fgmkmqfeO0;^_ zbeWx-p}~tK%DYI0A0Ju;-uvJ!DjoboD}iCcShj?XX<$Bi>+KVch+e~}X%@N7A5EwB zUwf8n>jduXe{*thA9qrj_*iCDA?zTE#m}3o#~-`@BVqC{y4B-5 literal 17184 zcmeHOTW=Fb6rSfw{SPa5ACeYZ{D4w%DNxiFA`;*sLX}Az&CP3+>zh~h{mZD2GfRIT?T}ifb0@gdr-$gD+_E&e zAK-e&{EmBa(Z`c1o_s| zMOvizYtQV#`tCue11me099jDity8k}CtA!HEga!PKV~`KFLv#n|KtVQ9HGjmT`l<)8~t2kA-=Fs~Ko6(EBm|`F><+qQ8k}%~79y`~8=e zr#WaHqm+0axp@yN-dL(Wg7eq5^#PyC@1qV~yzrmX@YHIu`@wRVXfU8&dKf_1()mXfb zem;0_$7q=~)C$-m0Y3C|QzfF1)ZI?Qsuh7Pi z%@fFAVrAg!Htj98XV-@2498Os)*+tdO3jf)N|WOw%%I9UHMRhsGtf@!j9bXj)`YLNlXGW&A4YP zVQx1-QoaQ+gA?r$T@JqFD(&+&^b=+%;z#1#dtNQg#mtg2g7SOtuj}ls-V$i+I$f1T(`Uth*bilFo2|j|^i2R)VIch##>XzvJ2~g#qc+W93ZT~5*!11fv98`3<<(RE-`Wp3UDpQcBFlP~kh7N>7Uay1 zM7vv{C6-@KD=MEHZq#}ITszIRo3^<2b?p2l)N>s@_1ZoG4j|TaW0T9*xZ{Q>MD(8K zB&W5D)xNf-|KZ3awh)&sLfjmW?dmZ=-mjaCKjPk+k4RFojr~vba~n}5jq_6Y?9}El zS+{byY<)SYPE_VypcanT8E@-Hwz3w<@owK@!?`W*)0Uqn&|dXFudNb3QTMGppPg9a;BfIA%B-#$6J>}w$!NkI^BCEHN&DYK1p)Oa8)ZsjF z+mSl#ZPQ4d&X{e+>yZ9>X{kSHyxu%Yw;OdfkIf;XSv5k}Y4W

2yxw#N1W|^+Mxnb}G=k~Bzaqh%B70xZ z9P@PD4jGPT{nno?=j7(Ws9!Rc%Ui@B@#^~la1rOp+FgG?#5`b=U4Gn6!+n0lY7^{M ztL_$bt5iOk+OFeo*YUUO_-*Xu)99dCsL5Efu+eCNm?E{RvCsEhhvdRh{B|urH3K7S zL7}8rF2v6%{9o09%L?h>ht$gyORul$-4L)N2fM@H14gr*KX&LIri#c#Nf}$ZZeN7d;5xt4J{D=xD!V0 zGH=gnn`ujQt@yU6b@YD~U)DN#pH9o@ddwax2XW@k`Dlm?+V;_~x6AR-u+Mr9Renxd zo38L&m$}2Q%^$CJmQd{|_QNU;@pCNWn5z-b!mK+FBs-D!5Ow9mBKNT!CeK9H&l$z% zy;4#65$0pA`n*+o&WmHk)z4Vf?;qyMCQp0u9L~+qiIQo0KQUh!n4z#{`KR4o`6maE3_AGZ;LNKE>J@=QakxsT#`c V0iN@Oj5{s;J)Y)fG$})V{{y;>@R$Gq diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof index 2af8ede60ca029a2ecc2974a4c631e6530db13bf..8145a76d9a7c1add0bc6999711cf1ba50350559a 100644 GIT binary patch literal 327 zcmaiv!3x4K5Jd0!iqMln5xv@z77InHVnq+7NK6(9q#M|zposr&TG3O{-P_JvW`Ekt zw?%$l3I}^|wj~Md!FZTz4fmRto-|&0=aRh7C(<6iLIKSsq^s&*>cQqHO{?G^wz>^q oF<%7_r9kEAyg(WH_JvXc1?aUfq3I`S<0i(zfUm_DmRi0pzG{i~s-t literal 678 zcmb`FK}*9x5QX2l;D1d>*Sl>BgUQ4|YZH5tuzq6<49-+l1 zvtowXKja%Q(Vylsmk0Z9Qm>!79`i7EU5(pcZuRLpb7Tc32UYMln8U}jwZ57>1(+V1 P5_idX&BV6*(;V9Y7NKw$ From 90873176831d2f52affc50444445f062981e989f Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Thu, 19 Nov 2015 16:09:56 +0100 Subject: [PATCH 043/147] Revert "Converted files to UTF-8" This reverts commit 18b50f091bb4c399440c93b19cc4cc97ecb920e3. --- .../MSFT_xSPAntivirusSettings.schema.mof | Bin 413 -> 854 bytes .../MSFT_xSPFarmAdministrators.psm1 | Bin 8367 -> 17184 bytes .../MSFT_xSPFarmAdministrators.schema.mof | Bin 327 -> 678 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof index 03bfc3fb846cef64c0717f80bcb390003b3985b9..0b8c87fdb151c816b0b53d66d14aee3fe4c45b47 100644 GIT binary patch literal 854 zcmbV~OH0E*6ot=P@IQpE6h!RCg|1??P{dYjY8OQ$CTT6CX-QIR5&ydS-AQRd@lhEj zb0>4px#vFK-*&a5ff`B`s$ktJQO-HmRGIcvQ(cETTJM_nbs$eoyvF!uioq_`20!6$ zh-Ywl&Zt|Cea+KuuXG_YmD48X{+PxSjK|;7mC~@;&{;(s#8e!T!e7 z)9jxtJ~)fN_@btTvLUe}Dw}Mr&UYP2=-mt}AcD<8RfV7P?9o^2a9zjLE8u4Rw|bXo zw5o?#)f{cZ)CN1z16(;h9m4#GWr||@`8|_O<;4ma<7>6B+7zg;p4tr9bZ+LW;dsrn jn$(cYtC_U^m%LhrBX~DF)&(D~$YpA{O3~};v?==l4J?gg literal 413 zcmZ{g!Ab)$5Qgu0ieXPJ6tNc%?rFQVut>Y&ZuL+~iOEz0*-1$z)*`;U*@|GLojJ}o z{|}#7l~#uEggzKYgKT_t-ETG=!OR;ZZ4V3C;UN2H9tvXfZhQ<4G8=jg*>EjX{|@tJ z)^5%ra0~Uk+Dv4?M+`1{h2m2{n$GRJ29Kcpn@6d`UuFb% o>83U6iULbg$>Pyd=}}{HDQyx64g2I0j*PX1QZ5qb;wu;88$&RPy#N3J diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 index 77d0480a5e9b2d1792c87ae8820da2b90ba80645..618ca5c05595a071db0674d5278a00114fd9526b 100644 GIT binary patch literal 17184 zcmeHOTW=Fb6rSfw{SPa5ACeYZ{D4w%DNxiFA`;*sLX}Az&CP3+>zh~h{mZD2GfRIT?T}ifb0@gdr-$gD+_E&e zAK-e&{EmBa(Z`c1o_s| zMOvizYtQV#`tCue11me099jDity8k}CtA!HEga!PKV~`KFLv#n|KtVQ9HGjmT`l<)8~t2kA-=Fs~Ko6(EBm|`F><+qQ8k}%~79y`~8=e zr#WaHqm+0axp@yN-dL(Wg7eq5^#PyC@1qV~yzrmX@YHIu`@wRVXfU8&dKf_1()mXfb zem;0_$7q=~)C$-m0Y3C|QzfF1)ZI?Qsuh7Pi z%@fFAVrAg!Htj98XV-@2498Os)*+tdO3jf)N|WOw%%I9UHMRhsGtf@!j9bXj)`YLNlXGW&A4YP zVQx1-QoaQ+gA?r$T@JqFD(&+&^b=+%;z#1#dtNQg#mtg2g7SOtuj}ls-V$i+I$f1T(`Uth*bilFo2|j|^i2R)VIch##>XzvJ2~g#qc+W93ZT~5*!11fv98`3<<(RE-`Wp3UDpQcBFlP~kh7N>7Uay1 zM7vv{C6-@KD=MEHZq#}ITszIRo3^<2b?p2l)N>s@_1ZoG4j|TaW0T9*xZ{Q>MD(8K zB&W5D)xNf-|KZ3awh)&sLfjmW?dmZ=-mjaCKjPk+k4RFojr~vba~n}5jq_6Y?9}El zS+{byY<)SYPE_VypcanT8E@-Hwz3w<@owK@!?`W*)0Uqn&|dXFudNb3QTMGppPg9a;BfIA%B-#$6J>}w$!NkI^BCEHN&DYK1p)Oa8)ZsjF z+mSl#ZPQ4d&X{e+>yZ9>X{kSHyxu%Yw;OdfkIf;XSv5k}Y4W

2yxw#N1W|^+Mxnb}G=k~Bzaqh%B70xZ z9P@PD4jGPT{nno?=j7(Ws9!Rc%Ui@B@#^~la1rOp+FgG?#5`b=U4Gn6!+n0lY7^{M ztL_$bt5iOk+OFeo*YUUO_-*Xu)99dCsL5Efu+eCNm?E{RvCsEhhvdRh{B|urH3K7S zL7}8rF2v6%{9o09%L?h>ht$gyORul$-4L)N2fM@H14gr*KX&LIri#c#Nf}$ZZeN7d;5xt4J{D=xD!V0 zGH=gnn`ujQt@yU6b@YD~U)DN#pH9o@ddwax2XW@k`Dlm?+V;_~x6AR-u+Mr9Renxd zo38L&m$}2Q%^$CJmQd{|_QNU;@pCNWn5z-b!mK+FBs-D!5Ow9mBKNT!CeK9H&l$z% zy;4#65$0pA`n*+o&WmHk)z4Vf?;qyMCQp0u9L~+qiIQo0KQUh!n4z#{`KR4o`6maE3_AGZ;LNKE>J@=QakxsT#`c V0iN@Oj5{s;J)Y)fG$})V{{y;>@R$Gq literal 8367 zcmeHNTW{Mo6n^)wAUr+TTP5@dtV0v8?Sd_9P^axf5Dbh&+gfGOC8?%CmjAwU4kePh zM5&jc7pz9%BoYtL?K>A9c2$+B$z{o22os-jwHD@;(6Umgm|Ra7e9jiztPtifFSEQ{ z&*ta$>C4LODsy_Z6SK4Bl{R9VEM!p#+D#|FalJA8q7dgb!Hz4wCDIvv)7JD*7@=mz zyv(?f>WV#Kkx`YHpR;D)rBT57oJD`~t$1`N^@Z7#m7Qx*p5vB4hD?QfQmimYRe9?ZC>WuDD;w^TIxs%T@?m=c2s_l??n7@ zx#3Ej$h2a-g+Lb8bZT^0E|)-VRVX3wOwu;3j&c z&!RR98;@uhB}}DC=HItBODYXkOnSF}7#!Z4KM~Gz@^r%to*}Ju_Dpn2}JBAY9pHZZ_c>$BzNGn$Gd^8$hDM$N)g&k7!XT1xeuz zFDjwyaBdep_OzFWENQyo}sN zyk}8a6-6jJuI$L)hmK}zN`6p`(v8pw`%|)2rO1&xudNdAs~pOdSMr7lsNDfh_F|Vw zFb(2~_$KT`sFj4$l}hkB^d%nz+ONnNpH=gk z<%sejLT=Z;Wsy1^HTKI_GiSntoXX<0VUNN8tVM?eeK%p^h=Ls!*yGJHsY0p(=V4~O zHAed$je<;#huOx<@mBCp6 zSr1l|ahZ6b1kbM6uw2V``ECaQ^cE*Jj%fh*Pmbx1eIVc-FrGg-mPg<`0^s`48Um)H z&JciWs&N1Zv9}k72Sh?2QQ)<@zXAAm`i?u0awl@@L^51D!sNmp4!_v_JP39J`;VsS zj=xFghfdKg6xUWANzZ#>+4b)uAjXlv6|-frK2RVwY~KQ03^90A57aOn5P1xgP$ z?L+mc(Dxp<9ZFdUUVb02*>hKKVEA<(yb%EyDE-ciX?rHGp+@it8;Aef(Yt4Wkx=c| zo1roj9E-lSvvj-lXy$gU#(S{s>E!7?>Y6iq`w%_M&d)h854IWvKM|%We$RKVf8EQ8 zj%vu8-$+vnlQx*p(zqPjS~6kVx@gP5d~G9>p@*g;_@d+7pvS&%KTB-w@GMM0Zql}= z7e`vZaW8)1w(g7g?moR-;I}46_}RW2?T>XZ*Au#lVY4%TmDg%(>I)=~*!y1r1x?fK zmp{I-qRE6>>$At_7NV#%!8F*&_4&VxtJxHeSJT!Y8cEz$4s7_DE|fgmkmqfeO0;^_ zbeWx-p}~tK%DYI0A0Ju;-uvJ!DjoboD}iCcShj?XX<$Bi>+KVch+e~}X%@N7A5EwB zUwf8n>jduXe{*thA9qrj_*iCDA?zTE#m}3o#~-`@BVqC{y4B-5 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof index 8145a76d9a7c1add0bc6999711cf1ba50350559a..2af8ede60ca029a2ecc2974a4c631e6530db13bf 100644 GIT binary patch literal 678 zcmb`FK}*9x5QX2l;D1d>*Sl>BgUQ4|YZH5tuzq6<49-+l1 zvtowXKja%Q(Vylsmk0Z9Qm>!79`i7EU5(pcZuRLpb7Tc32UYMln8U}jwZ57>1(+V1 P5_idX&BV6*(;V9Y7NKw$ literal 327 zcmaiv!3x4K5Jd0!iqMln5xv@z77InHVnq+7NK6(9q#M|zposr&TG3O{-P_JvW`Ekt zw?%$l3I}^|wj~Md!FZTz4fmRto-|&0=aRh7C(<6iLIKSsq^s&*>cQqHO{?G^wz>^q oF<%7_r9kEAyg(WH_JvXc1?aUfq3I`S<0i(zfUm_DmRi0pzG{i~s-t From e81d2bc0018e48dc80e5b4d7df98e9ce8e7e94ba Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Thu, 19 Nov 2015 16:11:39 +0100 Subject: [PATCH 044/147] Revert "Revert "Converted files to UTF-8"" This reverts commit 90873176831d2f52affc50444445f062981e989f. --- .../MSFT_xSPAntivirusSettings.schema.mof | Bin 854 -> 413 bytes .../MSFT_xSPFarmAdministrators.psm1 | Bin 17184 -> 8367 bytes .../MSFT_xSPFarmAdministrators.schema.mof | Bin 678 -> 327 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof index 0b8c87fdb151c816b0b53d66d14aee3fe4c45b47..03bfc3fb846cef64c0717f80bcb390003b3985b9 100644 GIT binary patch literal 413 zcmZ{g!Ab)$5Qgu0ieXPJ6tNc%?rFQVut>Y&ZuL+~iOEz0*-1$z)*`;U*@|GLojJ}o z{|}#7l~#uEggzKYgKT_t-ETG=!OR;ZZ4V3C;UN2H9tvXfZhQ<4G8=jg*>EjX{|@tJ z)^5%ra0~Uk+Dv4?M+`1{h2m2{n$GRJ29Kcpn@6d`UuFb% o>83U6iULbg$>Pyd=}}{HDQyx64g2I0j*PX1QZ5qb;wu;88$&RPy#N3J literal 854 zcmbV~OH0E*6ot=P@IQpE6h!RCg|1??P{dYjY8OQ$CTT6CX-QIR5&ydS-AQRd@lhEj zb0>4px#vFK-*&a5ff`B`s$ktJQO-HmRGIcvQ(cETTJM_nbs$eoyvF!uioq_`20!6$ zh-Ywl&Zt|Cea+KuuXG_YmD48X{+PxSjK|;7mC~@;&{;(s#8e!T!e7 z)9jxtJ~)fN_@btTvLUe}Dw}Mr&UYP2=-mt}AcD<8RfV7P?9o^2a9zjLE8u4Rw|bXo zw5o?#)f{cZ)CN1z16(;h9m4#GWr||@`8|_O<;4ma<7>6B+7zg;p4tr9bZ+LW;dsrn jn$(cYtC_U^m%LhrBX~DF)&(D~$YpA{O3~};v?==l4J?gg diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 index 618ca5c05595a071db0674d5278a00114fd9526b..77d0480a5e9b2d1792c87ae8820da2b90ba80645 100644 GIT binary patch literal 8367 zcmeHNTW{Mo6n^)wAUr+TTP5@dtV0v8?Sd_9P^axf5Dbh&+gfGOC8?%CmjAwU4kePh zM5&jc7pz9%BoYtL?K>A9c2$+B$z{o22os-jwHD@;(6Umgm|Ra7e9jiztPtifFSEQ{ z&*ta$>C4LODsy_Z6SK4Bl{R9VEM!p#+D#|FalJA8q7dgb!Hz4wCDIvv)7JD*7@=mz zyv(?f>WV#Kkx`YHpR;D)rBT57oJD`~t$1`N^@Z7#m7Qx*p5vB4hD?QfQmimYRe9?ZC>WuDD;w^TIxs%T@?m=c2s_l??n7@ zx#3Ej$h2a-g+Lb8bZT^0E|)-VRVX3wOwu;3j&c z&!RR98;@uhB}}DC=HItBODYXkOnSF}7#!Z4KM~Gz@^r%to*}Ju_Dpn2}JBAY9pHZZ_c>$BzNGn$Gd^8$hDM$N)g&k7!XT1xeuz zFDjwyaBdep_OzFWENQyo}sN zyk}8a6-6jJuI$L)hmK}zN`6p`(v8pw`%|)2rO1&xudNdAs~pOdSMr7lsNDfh_F|Vw zFb(2~_$KT`sFj4$l}hkB^d%nz+ONnNpH=gk z<%sejLT=Z;Wsy1^HTKI_GiSntoXX<0VUNN8tVM?eeK%p^h=Ls!*yGJHsY0p(=V4~O zHAed$je<;#huOx<@mBCp6 zSr1l|ahZ6b1kbM6uw2V``ECaQ^cE*Jj%fh*Pmbx1eIVc-FrGg-mPg<`0^s`48Um)H z&JciWs&N1Zv9}k72Sh?2QQ)<@zXAAm`i?u0awl@@L^51D!sNmp4!_v_JP39J`;VsS zj=xFghfdKg6xUWANzZ#>+4b)uAjXlv6|-frK2RVwY~KQ03^90A57aOn5P1xgP$ z?L+mc(Dxp<9ZFdUUVb02*>hKKVEA<(yb%EyDE-ciX?rHGp+@it8;Aef(Yt4Wkx=c| zo1roj9E-lSvvj-lXy$gU#(S{s>E!7?>Y6iq`w%_M&d)h854IWvKM|%We$RKVf8EQ8 zj%vu8-$+vnlQx*p(zqPjS~6kVx@gP5d~G9>p@*g;_@d+7pvS&%KTB-w@GMM0Zql}= z7e`vZaW8)1w(g7g?moR-;I}46_}RW2?T>XZ*Au#lVY4%TmDg%(>I)=~*!y1r1x?fK zmp{I-qRE6>>$At_7NV#%!8F*&_4&VxtJxHeSJT!Y8cEz$4s7_DE|fgmkmqfeO0;^_ zbeWx-p}~tK%DYI0A0Ju;-uvJ!DjoboD}iCcShj?XX<$Bi>+KVch+e~}X%@N7A5EwB zUwf8n>jduXe{*thA9qrj_*iCDA?zTE#m}3o#~-`@BVqC{y4B-5 literal 17184 zcmeHOTW=Fb6rSfw{SPa5ACeYZ{D4w%DNxiFA`;*sLX}Az&CP3+>zh~h{mZD2GfRIT?T}ifb0@gdr-$gD+_E&e zAK-e&{EmBa(Z`c1o_s| zMOvizYtQV#`tCue11me099jDity8k}CtA!HEga!PKV~`KFLv#n|KtVQ9HGjmT`l<)8~t2kA-=Fs~Ko6(EBm|`F><+qQ8k}%~79y`~8=e zr#WaHqm+0axp@yN-dL(Wg7eq5^#PyC@1qV~yzrmX@YHIu`@wRVXfU8&dKf_1()mXfb zem;0_$7q=~)C$-m0Y3C|QzfF1)ZI?Qsuh7Pi z%@fFAVrAg!Htj98XV-@2498Os)*+tdO3jf)N|WOw%%I9UHMRhsGtf@!j9bXj)`YLNlXGW&A4YP zVQx1-QoaQ+gA?r$T@JqFD(&+&^b=+%;z#1#dtNQg#mtg2g7SOtuj}ls-V$i+I$f1T(`Uth*bilFo2|j|^i2R)VIch##>XzvJ2~g#qc+W93ZT~5*!11fv98`3<<(RE-`Wp3UDpQcBFlP~kh7N>7Uay1 zM7vv{C6-@KD=MEHZq#}ITszIRo3^<2b?p2l)N>s@_1ZoG4j|TaW0T9*xZ{Q>MD(8K zB&W5D)xNf-|KZ3awh)&sLfjmW?dmZ=-mjaCKjPk+k4RFojr~vba~n}5jq_6Y?9}El zS+{byY<)SYPE_VypcanT8E@-Hwz3w<@owK@!?`W*)0Uqn&|dXFudNb3QTMGppPg9a;BfIA%B-#$6J>}w$!NkI^BCEHN&DYK1p)Oa8)ZsjF z+mSl#ZPQ4d&X{e+>yZ9>X{kSHyxu%Yw;OdfkIf;XSv5k}Y4W

2yxw#N1W|^+Mxnb}G=k~Bzaqh%B70xZ z9P@PD4jGPT{nno?=j7(Ws9!Rc%Ui@B@#^~la1rOp+FgG?#5`b=U4Gn6!+n0lY7^{M ztL_$bt5iOk+OFeo*YUUO_-*Xu)99dCsL5Efu+eCNm?E{RvCsEhhvdRh{B|urH3K7S zL7}8rF2v6%{9o09%L?h>ht$gyORul$-4L)N2fM@H14gr*KX&LIri#c#Nf}$ZZeN7d;5xt4J{D=xD!V0 zGH=gnn`ujQt@yU6b@YD~U)DN#pH9o@ddwax2XW@k`Dlm?+V;_~x6AR-u+Mr9Renxd zo38L&m$}2Q%^$CJmQd{|_QNU;@pCNWn5z-b!mK+FBs-D!5Ow9mBKNT!CeK9H&l$z% zy;4#65$0pA`n*+o&WmHk)z4Vf?;qyMCQp0u9L~+qiIQo0KQUh!n4z#{`KR4o`6maE3_AGZ;LNKE>J@=QakxsT#`c V0iN@Oj5{s;J)Y)fG$})V{{y;>@R$Gq diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof index 2af8ede60ca029a2ecc2974a4c631e6530db13bf..8145a76d9a7c1add0bc6999711cf1ba50350559a 100644 GIT binary patch literal 327 zcmaiv!3x4K5Jd0!iqMln5xv@z77InHVnq+7NK6(9q#M|zposr&TG3O{-P_JvW`Ekt zw?%$l3I}^|wj~Md!FZTz4fmRto-|&0=aRh7C(<6iLIKSsq^s&*>cQqHO{?G^wz>^q oF<%7_r9kEAyg(WH_JvXc1?aUfq3I`S<0i(zfUm_DmRi0pzG{i~s-t literal 678 zcmb`FK}*9x5QX2l;D1d>*Sl>BgUQ4|YZH5tuzq6<49-+l1 zvtowXKja%Q(Vylsmk0Z9Qm>!79`i7EU5(pcZuRLpb7Tc32UYMln8U}jwZ57>1(+V1 P5_idX&BV6*(;V9Y7NKw$ From 25297c7bcb88dba948c66f2908a2a9f3f2ad7981 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sat, 21 Nov 2015 11:48:51 +0000 Subject: [PATCH 045/147] adding workflow, throttling, general settings. --- .../MSFT_xSPWebApplication.Set.ps1 | 188 ++++++++++++++++++ Modules/xSharePoint/xSharePoint.psd1 | 1 + .../xSharePoint.xSPWebApplication.Tests.ps1 | 151 ++++++++------ 3 files changed, 281 insertions(+), 59 deletions(-) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 new file mode 100644 index 000000000..c3af6e4d3 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 @@ -0,0 +1,188 @@ +function Set-BlockedFiles($blockedFiles, $wa) +{ + + if($blockedFiles -eq $null){return;} + if($blockedFiles.Blocked -ne $null ){ + $wa.BlockedFileExtensions.Clear(); + $blockedFiles.Blocked| % { + $wa.BlockedFileExtensions.Add($_) ; + + } + } + if($blockedFiles.EnsureBlocked -ne $null){ + $blockedFiles.EnsureBlocked| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } + } + } + if($blockedFiles.EnsureAllowed -ne $null){ + $blockedFiles.EnsureAllowed | % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } + } + } + +} +function Get-ValueOrDefault($input, $attribute, $defaultValue) +{ + try{ + if($input."$attribute" -ne $null) + { + return $input."$attribute" + }else { + return $defaultValue + } + }catch + { + return $defaultValue + } +} +function Set-GeneralSettings($generalSettings, $wa) +{ + if($generalSettings -eq $null){ return;} + + #TODO: Quota Template + $wa.DefaultTimeZone =Get-ValueOrDefault $generalSettings "TimeZone" $wa.DefaultTimeZone + $wa.AlertsEnabled = Get-ValueOrDefault $generalSettings "Alerts" $wa.AlertsEnabled + $wa.AlertsMaximum = Get-ValueOrDefault $generalSettings "AlertsLimit" $wa.AlertsMaximum + $wa.SyndicationEnabled = Get-ValueOrDefault $generalSettings "RSS" $wa.RSS + $wa.MetaWeblogEnabled = Get-ValueOrDefault $generalSettings "BlogAPI" $wa.BlogAPI + $wa.MetaWeblogAuthenticationEnabled = Get-ValueOrDefault $generalSettings "BlogAPIAuthenticated" $wa.BlogAPIAuthenticated + $wa.BrowserFileHandling = Get-ValueOrDefault $generalSettings "BrowserFileHandling" $wa.BrowserFileHandling + $wa.FormDigestSettings.Enabled = Get-ValueOrDefault $generalSettings "SecurityValidation" $wa.FormDigestSettings.Enabled + $wa.MaximumFileSize = Get-ValueOrDefault $generalSettings "MaximumUploadSize" $wa.MaximumUploadSize + $wa.RecycleBinEnabled = Get-ValueOrDefault $generalSettings "RecycleBinEnabled" $wa.RecycleBinEnabled + $wa.RecycleBinCleanupEnabled = Get-ValueOrDefault $generalSettings "RecycleBinCleanupEnabled" $wa.RecycleBinCleanupEnabled + $wa.RecycleBinRetentionPeriod = Get-ValueOrDefault $generalSettings "RecycleBinRetentionPeriod" $wa.RecycleBinRetentionPeriod + $wa.SecondStageRecycleBinQuota = Get-ValueOrDefault $generalSettings "SecondStageRecycleBinEnabled" $wa.SecondStageRecycleBinQuota + $wa.BrowserCEIPEnabled = Get-ValueOrDefault $generalSettings "CustomerExperienceProgram" $wa.BrowserCEIPEnabled + $wa.PresenceEnabled = Get-ValueOrDefault $generalSettings "Presence" $wa.BrowserCEIPEnabled + $wa.Update(); +} +function Set-WorkflowSettings ($workflowSettings, $wa) +{ + if($workflowSettings -eq $null ){ return;} + if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ + $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; + } + if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ + $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; + } + if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ + $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; + } + + $wa.UpdateWorkflowConfigurationSettings(); + $wa.Update(); +} + +function Set-ThrottlingSettings ($throttlingSettings, $wa) +{ + if($throttlingSettings -eq $null){ return;} + if($throttlingSettings.ListViewThreshold -ne $null ){ + $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold + } + if($throttlingSettings.AllowObjectModelOverride -ne $null){ + $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride + } + if($throttlingSettings.AdminThreshold -ne $null){ + $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold + } + if($throttlingSettings.ListViewLookupThreshold -ne $null){ + $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold + } + if($throttlingSettings.HappyHourEnabled -ne $null){ + $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled + } + if($throttlingSettings.HappyHour -ne $null){ + $happyHour =$throttlingSettings.HappyHour; + if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ + if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ + $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour + $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute + $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration + }else{ + throw "the valid range hour, minute and duration is 0-24"; + } + + }else { + throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; + } + } + if($throttlingSettings.UniquePermissionThreshold){ + $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold + } + if($throttlingSettings.EventHandlersEnabled){ + $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled + } + if($throttlingSettings.RequestThrottling){ + $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling + } + if($throttlingSettings.ChangeLogEnabled){ + $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled + } + if($throttlingSettings.ChangeLogExpiryDays){ + $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays + } + $wa.Update(); +} + +function GetAndRemove-Parameter($params, $name){ + $result =$null + if($params.ContainsKey($name)) + { + $result = $params.$name + $params.Remove( $name) + } + return $result; +} +function Sanitize-ComplexTypes{ + param( + [Parameter(Position = 0)] + + $params + ) + +$blocked =GetAndRemove-Parameter $params "BlockedFileTypes" + return @{ + GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" + WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" + Extensions = GetAndRemove-Parameter $params "Extensions" + ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" + BlockedFileTypes = $blocked + } +} + + +$params = $args[0] + +$settings = Sanitize-ComplexTypes $params + +$wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue +if ($null -eq $wa) { + if ($params.ContainsKey("AuthenticationMethod") -eq $true) { + if ($params.AuthenticationMethod -eq "NTLM") { + $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos + } else { + $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication + } + $params.Remove("AuthenticationMethod") + $params.Add("AuthenticationProvider", $ap) + } + + if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } + if ($params.ContainsKey("AllowAnonymous")) { + $params.Remove("AllowAnonymous") | Out-Null + $params.Add("AllowAnonymousAccess", $true) + } + + $wa = New-SPWebApplication @params +} + +Set-ThrottlingSettings $settings.ThrottlingSettings $wa +Set-WorkflowSettings $settings.WorkflowSettings $wa +Set-BlockedFiles $settings.BlockedFileTypes $wa +Set-GeneralSettings $settings.GeneralSettings $wa + \ No newline at end of file diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index 7d7cf4054..6258016ac 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -98,5 +98,6 @@ AliasesToExport = '*' # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # DefaultCommandPrefix = '' + } diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index f98961d86..3ce3df3e4 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -21,6 +21,7 @@ Describe "xSPWebApplication" { Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") Mock Invoke-xSharePointCommand { @@ -32,7 +33,6 @@ Describe "xSPWebApplication" { Mock New-SPAuthenticationProvider { } Mock New-SPWebApplication { } - Context "The web application that uses NTLM doesn't exist but should" { Mock Get-SPWebApplication { return $null } @@ -151,74 +151,69 @@ Describe "xSPWebApplication" { Test-TargetResource @testParams | Should Be $true } } + - Context "backwards compatibility: set target resorce works with null/missing BlockedFileTypes" { - Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } - Mock Get-SPWebApplication { - $result = @(@{ - DisplayName = $testParams.Name - ApplicationPool = @{ - Name = $testParams.ApplicationPool - Username = $testParams.ApplicationPoolAccount - } - ContentDatabases = @( - @{ - Name = "SP_Content_01" - Server = "sql.domain.local" - } - ) - IisSettings = @( - @{ Path = "C:\inetpub\wwwroot\something" } - ) - Url = $testParams.Url - }) - $blockedFileTypes= @(); - $blockedFileTypes= $blockedFileTypes | Add-Member ScriptMethod RemoveAll { - $Global:BlockedFilesRemoveAllCalled = $true; - return $true; - } -passThru - $blockedFileTypes= $blockedFileTypes | Add-Member ScriptMethod Add { - param( [string]$fileType) - $Global:BlockedFilesAddCalled = $true; - return $true; - } -passThru - $result= $result | Add-Member -MemberType MemberSet -value $blockedFileTypes -Name "BlockedFileExtensions" - $result = $result | Add-Member -MemberType ScriptMethod Update { - $Global:BlockedFilesClearCalled = $true; - return $true; - - } -PassThru - return $result; - } - - It "calls the new cmdlet from the set method and does not touch blockedFileExtensions" { - $Global:SPWebApplicationUpdateCalled = $false; - $Global:BlockedFilesAddCalled = $false; - $Global:BlockedFilesClearCalled = $false; - Set-TargetResource @testParams - $Global:BlockedFilesAddCalled| Should be $false; - $Global:BlockedFilesClearCalled| Should be $false; - $Global:SPWebApplicationUpdateCalled| Should be $false; - Assert-MockCalled New-SPWebApplication - } - - } $testParams = @{ - Name = "Managed Metadata Service App" - ApplicationPool = "SharePoint Web Apps" + Name = "Complex types Web App" + ApplicationPool = "SharePoint complex type Web App" ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = @("java", "vbs") - AllowedFileTypes = @("exe", "vbs") - } + BlockedFileTypes = @{ + Blocked = @("java", "vbs", "exe","xxx") + EnsureBlocked = @("java", "rar", "exe","xxx") + EnsureAllowed = @("exe", "vbs","zip") + } + WorkflowSettings = @{ + ExternalWorkflowParticipantsEnabled=$false + UserDefinedWorkflowsEnabled=$true + EmailToNoPermissionWorkflowParticipantsEnable=$false + } + ThrottlingSettings = @{ + ListViewThreshold = 10000 + AllowObjectModelOverride = $true + AdminThreshold=55000 + ListViewLookupThreshold=10 + HappyHourEnabled= $true + HappyHour = @{ + Hour = 20 + Minute = 5 + Duration = 2 + } + UniquePermissionThreshold = 133000 + RequestThrottling=$false + ChangeLogEnabled=$true + ChangeLogExpiryDays = 19 + EventHandlersEnabled=$true + } + GeneralSettings=@{ + TimeZone = 10 + DefaultQuotaTemplate = "" + Alerts = $true + AlertsLimit = 10 + RSS = $true + BlogAPI = $true + BlogAPIAuthenticated = $true + BrowserFileHandling = "Permissive" + SecurityValidation = $true + RecycleBinEnabled = $true + SecondStageRecycleBinEnabled = $true + RecycleBinCleanupEnabled = $true + RecycleBinRetentionPeriod = 10 + SecondStageRecycleBinQuota = 500 + MaximumUploadSize = 555 + CustomerExperienceProgram = $true + PresenceEnabled = $true + } + } - Context "set target resorce works with blockedFileTypes" { + Context "set target resorce works with complex types filled in" { Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } - Mock Get-SPWebApplication { $result= @(@{ + $mockedapp= { + $result= @(@{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool @@ -234,13 +229,44 @@ Describe "xSPWebApplication" { @{ Path = "C:\inetpub\wwwroot\something" } ) Url = $testParams.Url + MaxItemsPerThrottledOperation=5000 + AllowOMCodeOverrideThrottleSettings=$true + MaxItemsPerThrottledOperationOverride = 10000 + MaxQueryLookupFields = 8 + UnthrottledPrivilegedOperationWindowEnabled =$true + DailyStartUnthrottledPrivilegedOperationsHour = $null + DailyStartUnthrottledPrivilegedOperationsMinute = $null + DailyUnthrottledPrivilegedOperationsDuration = $null + + MaxUniquePermScopesPerList = 50000 + EventHandlersEnabled = $true + HttpThrottleSettings = @{ + PerformThrottle = $true + } + FormDigestSettings = @{ + Enabled =$true + } + ChangeLogExpirationEnabled = $true + ChangeLogRetentionPeriod = New-TimeSpan -Days 10 }) + + $result= $result | Add-Member ScriptMethod UpdateWorkflowConfigurationSettings { + $Global:UpdateWorkflowCalled = $true; + } -PassThru + $blockedFileTypes = new-object PSObject + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Remove { + $Global:BlockedFilesRemoveCalled = $true; + return $true; + } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { $Global:BlockedFilesClearCalled = $true; return $true; } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod ContainExtension { + param($extension) $Global:BlockedFilesContainsCalled = $true; if($extension -eq "exe"){ @@ -254,6 +280,7 @@ Describe "xSPWebApplication" { $Global:BlockedFilesAddCalled = $true; return $true; } -passThru + $result=$result| Add-Member ScriptMethod Update { $Global:SPWebApplicationUpdateCalled = $true; return $true; @@ -261,14 +288,20 @@ Describe "xSPWebApplication" { $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru return $result } + Mock Get-SPWebApplication $mockedapp + Mock New-SPWebApplication $mockedapp It "calls the new cmdlet from the set method and does update blockedFileExtensions" { $Global:BlockedFilesAddCalled = $false; $Global:BlockedFilesClearCalled = $false; + $Global:BlockedFilesRemoveCalled = $false; + $Global:BlockedFilesContainsCalled = $false; + $Global:SPWebApplicationUpdateCalled =$false ; Set-TargetResource @testParams $Global:BlockedFilesAddCalled| Should be $true; $Global:BlockedFilesContainsCalled| Should be $true; $Global:SPWebApplicationUpdateCalled| Should be $true; + $Global:BlockedFilesRemoveCalled| Should be $true; Assert-MockCalled Get-SPWebApplication } From 539fcde9eba299e73f778b444f8a4d5255b6b279 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sat, 21 Nov 2015 11:57:07 +0000 Subject: [PATCH 046/147] resynching. added Web Application Settings for Workflow, Throttling, General and Blocked Files --- .../MSFT_xSPWebApplication.psm1 | 222 +++++++++++++++--- .../MSFT_xSPWebApplication.schema.mof | Bin 683 -> 5844 bytes 2 files changed, 189 insertions(+), 33 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 29fca0a98..7490ef62a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -1,3 +1,26 @@ +function GetAndRemove-Parameter($params, $name){ + $result =$null + if($params.ContainsKey($name)) + { + $result = $params.$name + $params.Remove( $name) + } + return $result; +} +function Sanitize-ComplexTypes{ + param( + [Parameter(Position = 0)] + $params + ) + return @{ + GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" + WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" + Extensions = GetAndRemove-Parameter $params "Extensions" + ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" + BlockedFileTypes = GetAndRemove-Parameter $params "BlockedFileTypes" + } +} + function Get-TargetResource { [CmdletBinding()] @@ -16,8 +39,10 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, - [parameter(Mandatory = $false)][string[]] $AllowedFileTypes + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) Write-Verbose -Message "Getting web application '$Name'" @@ -46,7 +71,6 @@ function Get-TargetResource Port = (New-Object System.Uri $wa.Url).Port AuthenticationMethod = $localAuthMode InstallAccount = $params.InstallAccount - BlockedFileTypes = $wa.BlockedFileExtensions } } return $result @@ -70,28 +94,21 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, - [parameter(Mandatory = $false)][string[]] $AllowedFileTypes + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) Write-Verbose -Message "Creating web application '$Name'" - + $settings = Sanitize-ComplexTypes $PSBoundParameters + $PSBoundParameters.Add("Settings", $settings) + Write-Verbose -Message "Creating web application '$Name'" $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - - $blockedFileTypes = $null - $allowedFileTypes = $null - if($params.ContainsKey("BlockedFileTypes")) - { - $blockedFileTypes =$params.BlockedFileTypes - $params.Remove("BlockedFileTypes") - } - if($params.ContainsKey("AllowedFileTypes")) - { - $allowedFileTypes =$params.AllowedFileTypes - $params.Remove("AllowedFileTypes") - } + $settings =$params.Settings + $params.Remove("Settings") | Out-Null $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { if ($params.ContainsKey("AuthenticationMethod") -eq $true) { @@ -112,26 +129,163 @@ function Set-TargetResource $wa = New-SPWebApplication @params } - if($blockedFileTypes -ne $null){ - $blockedFileTypes| % { - if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; - } +#region throttling settings + + $throttlingSettings = $settings.ThrottlingSettings + + if($throttlingSettings -ne $null){ + if($throttlingSettings.ListViewThreshold -ne $null ){ + $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold } - } - if($allowedFileTypes -ne $null){ - $allowedFileTypes| % { - if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) + if($throttlingSettings.AllowObjectModelOverride -ne $null){ + $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride + } + if($throttlingSettings.AdminThreshold -ne $null){ + $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold + } + if($throttlingSettings.ListViewLookupThreshold -ne $null){ + $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold + } + if($throttlingSettings.HappyHourEnabled -ne $null){ + $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled + } + if($throttlingSettings.HappyHour -ne $null){ + $happyHour =$throttlingSettings.HappyHour; + if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ + if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ + $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour + $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute + $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration + }else{ + throw "the valid hour, minute and duration range is 0-24"; + } + + }else { + throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; } } + if($throttlingSettings.UniquePermissionThreshold){ + $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold + } + if($throttlingSettings.EventHandlersEnabled){ + $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled + } + if($throttlingSettings.RequestThrottling){ + $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling + } + if($throttlingSettings.ChangeLogEnabled){ + $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled + } + if($throttlingSettings.ChangeLogExpiryDays){ + $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays + } } - if(($allowedFileTypes -ne $null) -or ($blockedFileTypes -ne $null)){ - $wa.Update() +#endregion +#region WorkflowSettings + #Set-WorkflowSettings $settings.WorkflowSettings $wa + $workflowSettings = $settings.WorkflowSettings + if($workflowSettings -ne $null ){ + if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ + $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; + } + if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ + $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; + } + if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ + $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; + } + + $wa.UpdateWorkflowConfigurationSettings(); } +#endregion + Write-Verbose "applying extended settings" +#region blockedFiles + $blockedFiles= $settings.BlockedFileTypes + if($blockedFiles -ne $null){ + if($blockedFiles.Blocked -ne $null ){ + $wa.BlockedFileExtensions.Clear(); + $blockedFiles.Blocked| % { + $wa.BlockedFileExtensions.Add($_) ; + } + } + if($blockedFiles.EnsureBlocked -ne $null){ + $blockedFiles.EnsureBlocked| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } + } + } + if($blockedFiles.EnsureAllowed -ne $null){ + $blockedFiles.EnsureAllowed | % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } + } + } + } +#endregion +#region General settings + + $generalSettings = $settings.GeneralSettings + if($generalSettings -ne $null){ + #TODO: Quota Template + if($generalSettings.TimeZone -ne $null){ + $wa.DefaultTimeZone =$generalSettings.TimeZone + } + if($generalSettings.Alerts -ne $null){ + $wa.AlertsEnabled = $generalSettings.Alerts + } + if($generalSettings.AlertsLimit -ne $null){ + $wa.AlertsMaximum = $generalSettings.AlertsLimit + } + if($generalSettings.RSS -ne $null){ + $wa.SyndicationEnabled = $generalSettings.RSS + } + if($generalSettings.AlertsLimit){ + $wa.MetaWeblogEnabled = $generalSettings.BlogAPI + } + if($generalSettings.BlogAPIAuthenticated){ + $wa.MetaWeblogAuthenticationEnabled = $generalSettings.BlogAPIAuthenticated + } + if($generalSettings.BrowserFileHandling){ + $wa.BrowserFileHandling = $generalSettings.BrowserFileHandling + } + if($generalSettings.SecurityValidation){ + $wa.FormDigestSettings.Enabled = $generalSettings.SecurityValidation + } + if($generalSettings.MaximumUploadSize){ + $wa.MaximumFileSize = $generalSettings.MaximumUploadSize + } + if($generalSettings.RecycleBinEnabled){ + $wa.RecycleBinEnabled = $generalSettings.RecycleBinEnabled + } + if($generalSettings.RecycleBinCleanupEnabled){ + $wa.RecycleBinCleanupEnabled = $generalSettings.RecycleBinCleanupEnabled + } + if($generalSettings.RecycleBinRetentionPeriod){ + $wa.RecycleBinRetentionPeriod = $generalSettings.RecycleBinRetentionPeriod + } + if($generalSettings.SecondStageRecycleBinEnabled){ + $wa.SecondStageRecycleBinQuota = $generalSettings.SecondStageRecycleBinEnabled + } + if($generalSettings.CustomerExperienceProgram){ + $wa.BrowserCEIPEnabled = $generalSettings.CustomerExperienceProgram + } + if($generalSettings.Presence -ne $null){ + $wa.PresenceEnabled = $generalSettings.Presence + } + } + if( ($settings.WorkflowSettings -ne $null) -or + ($settings.GeneralSettings -ne $null) -or + ($settings.ThrottlingSettings -ne $null) -or + ($settings.BlockedFileTypes -ne $null) + ){ + $wa.Update() + } +#endregion } } @@ -154,8 +308,10 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, - [parameter(Mandatory = $false)][string[]] $AllowedFileTypes + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 2bf0648237f415202e242dddf40f94c40a4aa806..0c937454310a0f0bb288498cc331bbf0369b1da5 100644 GIT binary patch literal 5844 zcmc&&T~8W86ur+)`X2~SZPGOTcx#^kv6_lf1x;#5v%rd5myZHgw@v?g+jC}Emzf=B z*+?`5S(m+M?mhRLe}B)VA+ZFq!0S{(nd38(sZ8XBROPL_mN)8Mm6y_!=kjdr`HHmU zM0TYk-{cloZCpn{3xUy*L}u!WGQX8%MfB@jZg5T{OMKsh+*18FkrBSHLw+g)xx#lt zImh=OHxEncE!-MT4f;@{8%v)*E4{YM-x*HnOAXA;aB2h|0EFgV~&k*sT5gF^3z>N{DK7RUmhEIj?;sn0P;_3(<|Bm|uV7Kth5ZAFB z$xnRF@ru+PAGWDy4bP92*UD*VqS)3RDE+VC)!73r&&M(IHUJA`C(q)U;()c{6?kjH zw!V6fJPl=E<@{2yI=~%PExRg}%PL*zDpp;}YrVNgy3jF_AK)%TjiguUA68tQ+2#CX zN76A6H8!Ku73V%pZL|iWnGreyDt$fz<38`KS8_9gTu8Two(T3QvV&6+Fi=LfrpgJ{ zGkRkJ?=xc9v3xo{UClWIe{*!Q3+TxXasq8xe^`@8(7LGp*uH6^%Q6q<$|JGZ_-(K< zSNH>*F;g5Z3)nGxv3+6}(mZbme=n5Y%sKm9KmYy{n9l)_V?^#$4)Jznh<)NFmg>lQ znr>6p(`M#$z{ePje+3&8eEM?4oSw9w0#uq9aqtD7?05mV4S~p+f*sk9XvY9M6=Q&r zfwv{WPw~mha!xAt#J3q9d)NT|V4z~H4$ddun(nVDT07>>P_YuI zZnoVsTxi^+^nAxD$?QoLZ#On`vTl3gvXiN|~2*Z?$dc z!M$kPcr{oyP&P95%cFN;M_#LJ7omN2ykpAz_ zd(Y`+EQm2H(1t77!*@5g<;DF03N#1FL@_6O=;5z8T0`n*nc$RI$Ho1`qh&1$<6yb{ zgQI)&98R|*VqgJA<(h(b@Q^#3859XJR&)7^O7-FCc>(V^*TBwLt6QX$_$SS$ROQlM zW54J|Xsx-01f@eH7>7JHSOy1e2H(29s0LXsWueEAgO0iJ@q61A;SFu6rXaeI6_>Se>wX|DEbC0-~yIK24<6V&Qay? Ki{>4Np7#wkM&;rF From 97e2018990b341e1075c612f8c9817010e2737c4 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Sun, 22 Nov 2015 09:04:42 +1100 Subject: [PATCH 047/147] fixing xSPWebApplication.schema encoding --- .../MSFT_xSPWebApplication.schema.mof | Bin 5844 -> 2838 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 0c937454310a0f0bb288498cc331bbf0369b1da5..a4907fe808bd39988432e9b9de995cd5a082d1ba 100644 GIT binary patch literal 2838 zcmbVOO;6iE5WVMDSUFJ%RkXd8QwX6!B;eu%q@oCI>>=5*-gWl_;v#-o5B*8~3!Qa# zV{b4hBFD_^+nKj-=K0^Bzc+nGl)3_`sNj3uPah9H9&|smQP$D2Kwxu*%3#uD^VaY$T}A2gZ~e4XvSLBP-~`PUoFPO_ow<&5)}5IS?QmOnj)b^3MSH5hdBf>| zlQ{!l-nD)I{b-QSAJbZW4?ajK!n9v-42p+23sRw%@hUxD{XflDkU}S58ed9fRAss%VgI`BRG^e`t zjW3g=^?%%Di(Y*CR;*|A5(Q%S(q?2To$W_ggc%r<;;CypNp*L>>nVPK?z2l!F1!`p z49}4ikNBc?F;^-?!K~|PZeUMA0;$1yE%9oaxpmgq;y&#X(lTXmM0p_SEg>P8;8~){ z0(Lu4XZ7taGlfHs0s`He)XA5iErWt1J5>0+6AWu>DU~AHpvPoIbCXXCCPOs|(_$$WlH>uT&yI0v+nfzyt;6qJbw4_>h#4!-Nsg-$jWyho)_7Cv z#~b4fggH=v*4$dc|G3xvb%^7$RsvD^%3^g(az1(QT z72()8CYsEVu?8#c2?=VBo}X|C&646~1KWYtbs!yqeD zWh^BBZJZa9^82*``wciq!hEDz`0j@8y}+Y1@V7(nyP)>+26X+Wzjs&g`U|!J=RQhp KtopcJ+t`2dfYP%7 literal 5844 zcmc&&T~8W86ur+)`X2~SZPGOTcx#^kv6_lf1x;#5v%rd5myZHgw@v?g+jC}Emzf=B z*+?`5S(m+M?mhRLe}B)VA+ZFq!0S{(nd38(sZ8XBROPL_mN)8Mm6y_!=kjdr`HHmU zM0TYk-{cloZCpn{3xUy*L}u!WGQX8%MfB@jZg5T{OMKsh+*18FkrBSHLw+g)xx#lt zImh=OHxEncE!-MT4f;@{8%v)*E4{YM-x*HnOAXA;aB2h|0EFgV~&k*sT5gF^3z>N{DK7RUmhEIj?;sn0P;_3(<|Bm|uV7Kth5ZAFB z$xnRF@ru+PAGWDy4bP92*UD*VqS)3RDE+VC)!73r&&M(IHUJA`C(q)U;()c{6?kjH zw!V6fJPl=E<@{2yI=~%PExRg}%PL*zDpp;}YrVNgy3jF_AK)%TjiguUA68tQ+2#CX zN76A6H8!Ku73V%pZL|iWnGreyDt$fz<38`KS8_9gTu8Two(T3QvV&6+Fi=LfrpgJ{ zGkRkJ?=xc9v3xo{UClWIe{*!Q3+TxXasq8xe^`@8(7LGp*uH6^%Q6q<$|JGZ_-(K< zSNH>*F;g5Z3)nGxv3+6}(mZbme=n5Y%sKm9KmYy{n9l)_V?^#$4)Jznh<)NFmg>lQ znr>6p(`M#$z{ePje+3&8eEM?4oSw9w0#uq9aqtD7?05mV4S~p+f*sk9XvY9M6=Q&r zfwv{WPw~mha!xAt#J3q9d)NT|V4z~H4$ddun(nVDT07>>P_YuI zZnoVsTxi^+^nAxD$?QoLZ#On`vTl3gvXiN|~2*Z?$dc z!M$kPcr{oyP&P95%cFN;M_#LJ7omN2yk Date: Sun, 22 Nov 2015 09:09:32 +1100 Subject: [PATCH 048/147] :( testing encoding to utf-8 again --- .../MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index a4907fe80..0e294dabd 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -17,7 +17,7 @@ Class MSFT_xSPWebApplicationHappyHour Class MSFT_xSPWebApplicationThrottling { [write]uint32 ListViewThreshold; - [write]boolean AllowObjectModelOverride; + [write]boolean AllowObjectModelOverride; [write]uint32 AdminThreshold; [write]uint32 ListViewLookupThreshold; [write]boolean HappyHourEnabled; From b63c94fa43ba44924aff4dee749feab37c93c3e5 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 22 Nov 2015 11:54:58 +1100 Subject: [PATCH 049/147] Added support for complex MOF types to the MOF parser --- Tests/Generate-xSharePointHelpFiles.ps1 | 2 +- Tests/Generate-xSharePointWikiPages.ps1 | 2 +- .../xSharePoint/xSharePoint.Global.Tests.ps1 | 12 +++--- .../xSharePoint/xSharePoint.TestHelpers.psm1 | 37 +++++++++++++------ 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Tests/Generate-xSharePointHelpFiles.ps1 b/Tests/Generate-xSharePointHelpFiles.ps1 index 7d8c524f1..6f30679e6 100644 --- a/Tests/Generate-xSharePointHelpFiles.ps1 +++ b/Tests/Generate-xSharePointHelpFiles.ps1 @@ -9,7 +9,7 @@ $repoDir = Join-Path $PSScriptRoot "..\" -Resolve Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` ForEach-Object { - $result = Get-MofSchemaObject $_.FullName + $result = (Get-MofSchemaObject $_.FullName) | Where-Object { $_.ClassName -eq $_.Name.Replace(".schema.mof", "") } Write-Output "Generating help document for $($result.FriendlyName)" $output = "NAME" + [Environment]::NewLine diff --git a/Tests/Generate-xSharePointWikiPages.ps1 b/Tests/Generate-xSharePointWikiPages.ps1 index de22eb371..1b3abe8b7 100644 --- a/Tests/Generate-xSharePointWikiPages.ps1 +++ b/Tests/Generate-xSharePointWikiPages.ps1 @@ -9,7 +9,7 @@ $repoDir = Join-Path $PSScriptRoot "..\" -Resolve Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` ForEach-Object { - $result = Get-MofSchemaObject $_.FullName + $result = (Get-MofSchemaObject $_.FullName) | Where-Object { $_.ClassName -eq $_.Name.Replace(".schema.mof", "") } Write-Output "Generating wiki page for $($result.FriendlyName)" $output = "**Parameters**" + [Environment]::NewLine + [Environment]::NewLine diff --git a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 index 88a73b344..12aa7e7b4 100644 --- a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 @@ -21,11 +21,13 @@ Describe 'xSharePoint whole of module tests' { $mofFiles | ForEach-Object { $fileHasInstallAccount = $false - $mofSchema = Get-MofSchemaObject $_.FullName - $installAccount = $mofSchema.Attributes | Where-Object { $_.Name -eq "InstallAccount" } - if (($null -ne $installAccount) -and ($installAccount.State -eq "Required")) { - $mofFilesWithNoInstallAccount += 1 - Write-Warning "File $($_.FullName) has InstallAccount listed as a required parameter. After v0.6 of xSharePoint this should be changed to 'write' instead of 'required'" + $mofSchemas = Get-MofSchemaObject $_.FullName + foreach($mofSchema in $mofSchemas) { + $installAccount = $mofSchema.Attributes | Where-Object { $_.Name -eq "InstallAccount" } + if (($null -ne $installAccount) -and ($installAccount.State -eq "Required")) { + $mofFilesWithNoInstallAccount += 1 + Write-Warning "File $($_.FullName) has InstallAccount listed as a required parameter. After v0.6 of xSharePoint this should be changed to 'write' instead of 'required'" + } } } $mofFilesWithNoInstallAccount | Should Be 0 diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 index f3403eec9..1b7fc8bd8 100644 --- a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 +++ b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 @@ -5,7 +5,9 @@ function Get-MofSchemaObject() { ) $contents = Get-Content $fileName - $results = @{ + $results = @() + + $currentResult = @{ ClassVersion = $null FriendlyName = $null ClassName = $null @@ -20,26 +22,38 @@ function Get-MofSchemaObject() { $currentlyInCommentBlock = $true } elseif($textLine.StartsWith("*/")) { $currentlyInCommentBlock = $false - $results.Documentation = $currentComment + $currentResult.Documentation = $currentComment } elseif($currentlyInCommentBlock -eq $true) { $currentComment += $textLine + [Environment]::NewLine - } elseif ($textLine.Contains("ClassVersion") -or $textLine.Contains("ClassVersion")) { + } elseif ($textLine -match "ClassVersion" -or $textLine -match "FriendlyName") { if ($textLine -match "ClassVersion(`"*.`")") { $start = $textLine.IndexOf("ClassVersion(`"") + 14 $end = $textLine.IndexOf("`")", $start) - $results.ClassVersion = $textLine.Substring($start, $end - $start) + $currentResult.ClassVersion = $textLine.Substring($start, $end - $start) } if ($textLine -match "FriendlyName(`"*.`")") { $start = $textLine.IndexOf("FriendlyName(`"") + 14 $end = $textLine.IndexOf("`")", $start) - $results.FriendlyName = $textLine.Substring($start, $end - $start) + $currentResult.FriendlyName = $textLine.Substring($start, $end - $start) } - } elseif ($textLine.Contains("class ")) { - $start = $textLine.IndexOf("class ") + 6 + } elseif ($textLine -match "class ") { + $start = $textLine.ToLower().IndexOf("class ") + 6 $end = $textLine.IndexOf(" ", $start) - $results.ClassName = $textLine.Substring($start, $end - $start) - } elseif ($textLine.Trim() -eq "{" -or $textLine.Trim() -eq "};" -or [string]::IsNullOrEmpty($textLine)) { + if ($end -eq -1) { + $end = $textLine.Length + } + $currentResult.ClassName = $textLine.Substring($start, $end - $start) + } elseif ($textLine.Trim() -eq "{" -or [string]::IsNullOrEmpty($textLine.Trim())) { + } elseif ($textLine.Trim() -eq "};") { + $results += $currentResult + $currentResult = @{ + ClassVersion = $null + FriendlyName = $null + ClassName = $null + Attributes = @() + Documentation = $null + } } else { $attributeValue = @{ State = $null @@ -76,7 +90,7 @@ function Get-MofSchemaObject() { $attributeValue.DataType = $nonMetadataObjects[1] $attributeValue.Name = $nonMetadataObjects[2] - $results.Attributes += $attributeValue + $currentResult.Attributes += $attributeValue } } return $results @@ -88,7 +102,8 @@ function Assert-MofSchemaScriptParameters() { [string]$mofFileName ) $hasErrors = $false - $mofData = Get-MofSchemaObject -fileName $mofFileName + $mofSchemas = Get-MofSchemaObject -fileName $mofFileName + $mofData = $mofSchemas | Where-Object { $_.ClassName -eq $mofFileName.Replace(".schema.mof", "") } $psFile = $mofFileName.Replace(".schema.mof", ".psm1") $tokens = $null From 18450e48d7f1bc1862fd69a3ed1ad79c50349ac3 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 22 Nov 2015 17:07:20 +1100 Subject: [PATCH 050/147] Fixed approach to provisioning remote index folders --- .../MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 index 0cd672943..2db6dfafd 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 @@ -173,14 +173,9 @@ function Set-TargetResource $servers = $params.FirstPartitionServers.Replace(" ", "").Split(',', [StringSplitOptions]::RemoveEmptyEntries) foreach($server in $servers) { - $InvokeCommandArgs = @{ - ArgumentList = @($params.FirstPartitionDirectory) - } - $session = New-PSSession -ComputerName $server -Name "Microsoft.SharePoint.DSC.SearchRolesSetup" -SessionOption (New-PSSessionOption -OperationTimeout 0 -IdleTimeout 60000) - if ($null -ne $session) { $InvokeCommandArgs.Add("Session", $session) } - Invoke-Command @InvokeCommandArgs -ScriptBlock { - New-Item $args[0] -ItemType Directory -Force - } + $networkPath = "\\$server\" + $params.FirstPartitionDirectory.Replace(":\", "$\") + New-Item $networkPath -ItemType Directory -Force + $indexSsi = Get-SPEnterpriseSearchServiceInstance -Identity $server if($indexSsi.Status -eq "Offline") { Write-Verbose "Start Search Service Instance" From 30cdd56fc06cf9b30d98dc1b0f90a6d83787edfc Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 22 Nov 2015 09:35:23 +0000 Subject: [PATCH 051/147] updating files with same changes as https://github.com/BrianFarnhill/xSharePoint/commit/b63c94fa43ba44924aff4dee749feab37c93c3e5 --- .../MSFT_xSPWebApplication.psm1 | 6 +-- .../MSFT_xSPWebApplication.schema.mof | 13 ++--- .../xSharePoint/xSharePoint.Global.Tests.ps1 | 15 +++--- .../xSharePoint/xSharePoint.TestHelpers.psm1 | 47 ++++++++++++++----- 4 files changed, 54 insertions(+), 27 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 7490ef62a..4edb6efd1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -205,21 +205,21 @@ function Set-TargetResource if($blockedFiles.Blocked -ne $null ){ $wa.BlockedFileExtensions.Clear(); $blockedFiles.Blocked| % { - $wa.BlockedFileExtensions.Add($_) ; + $wa.BlockedFileExtensions.Add($_); } } if($blockedFiles.EnsureBlocked -ne $null){ $blockedFiles.EnsureBlocked| % { if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; + $wa.BlockedFileExtensions.Add($_); } } } if($blockedFiles.EnsureAllowed -ne $null){ $blockedFiles.EnsureAllowed | % { if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) + $wa.BlockedFileExtensions.Remove($_); } } } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 0e294dabd..629c937ab 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,11 +1,12 @@ -[ClassVersion("1.0.0")] +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationHappyHour")] Class MSFT_xSPFilesTypes { [write]String Blocked[]; [write]String EnsureBlocked[]; [write]String EnsureAllowed[]; }; -[ClassVersion("1.0.0")] + +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationHappyHour")] Class MSFT_xSPWebApplicationHappyHour { [write] uint32 Hour; @@ -13,7 +14,8 @@ Class MSFT_xSPWebApplicationHappyHour [write] uint32 Duration; }; -[ClassVersion("1.0.0")] + +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationThrottling")] Class MSFT_xSPWebApplicationThrottling { [write]uint32 ListViewThreshold; @@ -30,7 +32,7 @@ Class MSFT_xSPWebApplicationThrottling }; -[ClassVersion("1.0.0")] +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationWorkflowSettings")] Class MSFT_xSPWebApplicationWorkflowSettings { [write]boolean ExternalWorkflowParticipantsEnabled; @@ -38,7 +40,7 @@ Class MSFT_xSPWebApplicationWorkflowSettings [write]boolean EmailToNoPermissionWorkflowParticipantsEnable; }; -[ClassVersion("1.0.0")] +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationSettings")] Class MSFT_xSPWebApplicationSettings { [write]uint32 TimeZone; @@ -49,7 +51,6 @@ Class MSFT_xSPWebApplicationSettings [write]boolean BlogAPI; [write]boolean BlogAPIAuthenticated; [write, ValueMap{"Strict","Permissive"}, Values{"Stric","Permissive"}] String BrowserFileHandling; - [write]boolean SecurityValidation; [write]boolean RecycleBinEnabled; [write]boolean SecondStageRecycleBinEnabled; diff --git a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 index cfe9684bf..c1f212a9e 100644 --- a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 @@ -2,7 +2,6 @@ param( [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) - $ErrorActionPreference = 'stop' Set-StrictMode -Version latest @@ -22,11 +21,13 @@ Describe 'xSharePoint whole of module tests' { $mofFiles | ForEach-Object { $fileHasInstallAccount = $false - $mofSchema = Get-MofSchemaObject $_.FullName - $installAccount = $mofSchema.Attributes | Where-Object { $_.Name -eq "InstallAccount" } - if (($null -ne $installAccount) -and ($installAccount.State -eq "Required")) { - $mofFilesWithNoInstallAccount += 1 - Write-Warning "File $($_.FullName) has InstallAccount listed as a required parameter. After v0.6 of xSharePoint this should be changed to 'write' instead of 'required'" + $mofSchemas = Get-MofSchemaObject $_.FullName + foreach($mofSchema in $mofSchemas) { + $installAccount = $mofSchema.Attributes | Where-Object { $_.Name -eq "InstallAccount" } + if (($null -ne $installAccount) -and ($installAccount.State -eq "Required")) { + $mofFilesWithNoInstallAccount += 1 + Write-Warning "File $($_.FullName) has InstallAccount listed as a required parameter. After v0.6 of xSharePoint this should be changed to 'write' instead of 'required'" + } } } $mofFilesWithNoInstallAccount | Should Be 0 @@ -92,4 +93,4 @@ Describe 'xSharePoint whole of module tests' { $errors.Count | Should Be 0 } } -} \ No newline at end of file +} diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 index 0d2001041..17b735acc 100644 --- a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 +++ b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 @@ -5,31 +5,55 @@ function Get-MofSchemaObject() { ) $contents = Get-Content $fileName - $results = @{ + $results = @() + + $currentResult = @{ ClassVersion = $null FriendlyName = $null ClassName = $null Attributes = @() + Documentation = $null } + $currentComment = "" + $currentlyInCommentBlock = $false foreach($textLine in $contents) { - if ($textLine.Contains("ClassVersion") -or $textLine.Contains("ClassVersion")) { + if ($textLine.StartsWith("/*")) { + $currentlyInCommentBlock = $true + } elseif($textLine.StartsWith("*/")) { + $currentlyInCommentBlock = $false + $currentResult.Documentation = $currentComment + } elseif($currentlyInCommentBlock -eq $true) { + $currentComment += $textLine + [Environment]::NewLine + } elseif ($textLine -match "ClassVersion" -or $textLine -match "FriendlyName") { if ($textLine -match "ClassVersion(`"*.`")") { $start = $textLine.IndexOf("ClassVersion(`"") + 14 $end = $textLine.IndexOf("`")", $start) - $results.ClassVersion = $textLine.Substring($start, $end - $start) + $currentResult.ClassVersion = $textLine.Substring($start, $end - $start) } if ($textLine -match "FriendlyName(`"*.`")") { $start = $textLine.IndexOf("FriendlyName(`"") + 14 $end = $textLine.IndexOf("`")", $start) - $results.FriendlyName = $textLine.Substring($start, $end - $start) + $currentResult.FriendlyName = $textLine.Substring($start, $end - $start) } - } elseif ($textLine.Contains("class ")) { - $start = $textLine.IndexOf("class ") + 6 + } elseif ($textLine -match "class ") { + $start = $textLine.ToLower().IndexOf("class ") + 6 $end = $textLine.IndexOf(" ", $start) - $results.ClassName = $textLine.Substring($start, $end - $start) - } elseif ($textLine.Trim() -eq "{" -or $textLine.Trim() -eq "};" -or [string]::IsNullOrEmpty($textLine)) { + if ($end -eq -1) { + $end = $textLine.Length + } + $currentResult.ClassName = $textLine.Substring($start, $end - $start) + } elseif ($textLine.Trim() -eq "{" -or [string]::IsNullOrEmpty($textLine.Trim())) { + } elseif ($textLine.Trim() -eq "};") { + $results += $currentResult + $currentResult = @{ + ClassVersion = $null + FriendlyName = $null + ClassName = $null + Attributes = @() + Documentation = $null + } } else { $attributeValue = @{ State = $null @@ -66,7 +90,7 @@ function Get-MofSchemaObject() { $attributeValue.DataType = $nonMetadataObjects[1] $attributeValue.Name = $nonMetadataObjects[2] - $results.Attributes += $attributeValue + $currentResult.Attributes += $attributeValue } } return $results @@ -78,7 +102,8 @@ function Assert-MofSchemaScriptParameters() { [string]$mofFileName ) $hasErrors = $false - $mofData = Get-MofSchemaObject -fileName $mofFileName + $mofSchemas = Get-MofSchemaObject -fileName $mofFileName + $mofData = $mofSchemas | Where-Object { $_.ClassName -eq $mofFileName.Replace(".schema.mof", "") } $psFile = $mofFileName.Replace(".schema.mof", ".psm1") $tokens = $null @@ -190,4 +215,4 @@ function Get-ParseErrors { return $errors } -Export-ModuleMember * \ No newline at end of file +Export-ModuleMember * From 8a1503e61074f75b79af8c81383be5f2ae3a0cc6 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 22 Nov 2015 20:38:09 +1100 Subject: [PATCH 052/147] Code review feedback tweaks --- .../MSFT_xSPSearchIndexPartition.psm1 | 25 +++++++++---------- .../MSFT_xSPSearchIndexPartition.schema.mof | 4 ++- .../MSFT_xSPSearchRoles.psm1 | 22 ++++++++++------ .../MSFT_xSPSearchRoles.schema.mof | 2 +- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 index 0009c614a..2d99a36b7 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 @@ -7,6 +7,7 @@ function Get-TargetResource [parameter(Mandatory = $true)] [System.UInt32] $Index, [parameter(Mandatory = $true)] [System.String] $Servers, [parameter(Mandatory = $true)] [System.String] $RootDirectory, + [parameter(Mandatory = $true)] [System.String] $ServiceAppName, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) @@ -15,7 +16,7 @@ function Get-TargetResource $params = $args[0] $ConfirmPreference = 'None' - $ssa = Get-SPEnterpriseSearchServiceApplication + $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName $indexComps = Get-SPEnterpriseSearchComponent -SearchTopology $ssa.ActiveTopology ` | Where-Object {($_.GetType().Name -eq "IndexComponent") ` -and ($_.IndexPartitionOrdinal -eq $params.Index)} @@ -52,6 +53,7 @@ function Set-TargetResource [parameter(Mandatory = $true)] [System.UInt32] $Index, [parameter(Mandatory = $true)] [System.String] $Servers, [parameter(Mandatory = $true)] [System.String] $RootDirectory, + [parameter(Mandatory = $true)] [System.String] $ServiceAppName, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) @@ -60,7 +62,7 @@ function Set-TargetResource $params = $args[0] $ConfirmPreference = 'None' - $ssa = Get-SPEnterpriseSearchServiceApplication + $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName $newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $ssa.ActiveTopology $servers = $params["Servers"].Replace(" ", "").Split(",", [StringSplitOptions]::RemoveEmptyEntries) @@ -74,24 +76,20 @@ function Set-TargetResource } #Wait for Search Service Instance to come online + $loopCount = 0 $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; do { $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; - Write-Verbose "Waiting for service on $server - current status is $($online.Status)" - Start-Sleep -Seconds 10 + Write-Verbose "Waiting for service: $($online.TypeName)" + $loopCount++ + Start-Sleep -Seconds 30 } - until ($online.Status -eq "Online") + until ($online.Status -eq "Online" -or $loopCount -eq 20) if ($params.Ensure -eq "Present") { Write-Verbose "Creating $($params.RootDirectory) on $server" - $InvokeCommandArgs = @{ - ArgumentList = @($params.RootDirectory) - } - $session = New-PSSession -ComputerName $server -Name "Microsoft.SharePoint.DSC.SearchIndexSetup" -SessionOption (New-PSSessionOption -OperationTimeout 0 -IdleTimeout 60000) - if ($null -ne $session) { $InvokeCommandArgs.Add("Session", $session) } - Invoke-Command @InvokeCommandArgs -ScriptBlock { - New-Item $args[0] -ItemType Directory -Force - } + $networkPath = "\\$server\" + $params.RootDirectory.Replace(":\", "$\") + New-Item $networkPath -ItemType Directory -Force New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $ssi -IndexPartition $params.Index -RootDirectory $params.RootDirectory } else { @@ -114,6 +112,7 @@ function Test-TargetResource [parameter(Mandatory = $true)] [System.UInt32] $Index, [parameter(Mandatory = $true)] [System.String] $Servers, [parameter(Mandatory = $true)] [System.String] $RootDirectory, + [parameter(Mandatory = $true)] [System.String] $ServiceAppName, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof index d1cb08771..d5f32a356 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof @@ -16,6 +16,7 @@ Additional search index partitions can be created through using this resource. Servers = "Server2,Server3" Index = 1 RootDirectory = "I:\SearchIndexes\1" + ServiceAppName = "Search Service Application" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[xSPSearchRoles]LocalSearchRoles" } @@ -26,6 +27,7 @@ class MSFT_xSPSearchIndexPartition : OMI_BaseResource [Key] Uint32 Index; [Required] String Servers; [Required] String RootDirectory; + [Required] String ServiceAppName; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; -}; \ No newline at end of file +}; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 index 2db6dfafd..71c432786 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 @@ -28,7 +28,7 @@ function Get-TargetResource $QueryProcessingExists = $false; $ssi = Get-SPEnterpriseSearchServiceInstance -Identity $env:COMPUTERNAME - $ssa = Get-SPEnterpriseSearchServiceApplication + $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName if($ssi.Status -eq "Offline") { Write-Verbose "Search is offline" return @{ @@ -122,7 +122,7 @@ function Set-TargetResource $ConfirmPreference = 'None' $ssi = Get-SPEnterpriseSearchServiceInstance -Local - $ssa = Get-SPEnterpriseSearchServiceApplication + $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName if($ssi.Status -eq "Offline") { Write-Verbose "Start Search Service Instance" @@ -130,12 +130,15 @@ function Set-TargetResource } #Wait for Search Service Instance to come online + $loopCount = 0 $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; do { $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; Write-Verbose "Waiting for service: $($online.TypeName)" + $loopCount++ + Start-Sleep -Seconds 30 } - until ($online.Status -eq "Online") + until ($online.Status -eq "Online" -or $loopCount -eq 20) $currentTopology = $ssa.ActiveTopology $newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $currentTopology @@ -169,7 +172,7 @@ function Set-TargetResource #Add the First search index if no other indexes already exist required if($null -eq $IndexComponent1) { - Write-Verbose "Adding First search indedx at partition $($params.FirstPartitionIndex)" + Write-Verbose "Adding First search index at partition $($params.FirstPartitionIndex)" $servers = $params.FirstPartitionServers.Replace(" ", "").Split(',', [StringSplitOptions]::RemoveEmptyEntries) foreach($server in $servers) { @@ -181,12 +184,17 @@ function Set-TargetResource Write-Verbose "Start Search Service Instance" Start-SPEnterpriseSearchServiceInstance -Identity $indexSsi } - $online = Get-SPEnterpriseSearchServiceInstance -Identity $indexSsi + + #Wait for Search Service Instance to come online + $loopCount = 0 + $online = Get-SPEnterpriseSearchServiceInstance -Identity $indexSsi; do { - $online = Get-SPEnterpriseSearchServiceInstance -Identity $indexSsi + $online = Get-SPEnterpriseSearchServiceInstance -Identity $indexSsi; Write-Verbose "Waiting for service: $($online.TypeName)" + $loopCount++ + Start-Sleep -Seconds 30 } - until ($online.Status -eq "Online") + until ($online.Status -eq "Online" -or $loopCount -eq 20) New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $indexSsi -IndexPartition $params.FirstPartitionIndex -RootDirectory $params.FirstPartitionDirectory } } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof index 1069183b6..84a0b581c 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof @@ -39,4 +39,4 @@ class MSFT_xSPSearchRoles : OMI_BaseResource [Write] Uint32 FirstPartitionIndex; [Write] String FirstPartitionDirectory; [Write] String FirstPartitionServers; -}; \ No newline at end of file +}; From 00d13b810f06aec112d8020f5a00fc7456fd2935 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 22 Nov 2015 20:43:50 +1100 Subject: [PATCH 053/147] Fixing test after new parameter --- Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 index e20c5c6be..63332c62c 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 @@ -19,6 +19,7 @@ Describe "xSPSearchIndexPartition" { Servers = $env:COMPUTERNAME RootDirectory = "C:\SearchIndex\0" Ensure = "Present" + ServiceAppName = "Search Service Application" } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue From 0baef2ac27be280ff9c5fcb0a33095c5b60372b6 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 22 Nov 2015 21:19:59 +1100 Subject: [PATCH 054/147] Fixed tabs --- .../MSFT_xSPSearchIndexPartition.schema.mof | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof index d5f32a356..194c22676 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof @@ -16,7 +16,7 @@ Additional search index partitions can be created through using this resource. Servers = "Server2,Server3" Index = 1 RootDirectory = "I:\SearchIndexes\1" - ServiceAppName = "Search Service Application" + ServiceAppName = "Search Service Application" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[xSPSearchRoles]LocalSearchRoles" } @@ -27,7 +27,7 @@ class MSFT_xSPSearchIndexPartition : OMI_BaseResource [Key] Uint32 Index; [Required] String Servers; [Required] String RootDirectory; - [Required] String ServiceAppName; + [Required] String ServiceAppName; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; }; From fa893f41bb82c4ad63eee4017820c2205b0157f2 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Wed, 25 Nov 2015 09:42:38 +1100 Subject: [PATCH 055/147] Removing search topology from this branch to revisit approach later --- .../MSFT_xSPSearchIndexPartition.psm1 | 123 --------- .../MSFT_xSPSearchIndexPartition.schema.mof | 33 --- .../MSFT_xSPSearchRoles.psm1 | 254 ------------------ .../MSFT_xSPSearchRoles.schema.mof | 42 --- Modules/xSharePoint/xSharePoint.pssproj | 6 - 5 files changed, 458 deletions(-) delete mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 delete mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof delete mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 delete mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 deleted file mode 100644 index 2d99a36b7..000000000 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.psm1 +++ /dev/null @@ -1,123 +0,0 @@ -function Get-TargetResource -{ - [CmdletBinding()] - [OutputType([System.Collections.Hashtable])] - param - ( - [parameter(Mandatory = $true)] [System.UInt32] $Index, - [parameter(Mandatory = $true)] [System.String] $Servers, - [parameter(Mandatory = $true)] [System.String] $RootDirectory, - [parameter(Mandatory = $true)] [System.String] $ServiceAppName, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure - ) - - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - $ConfirmPreference = 'None' - - $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName - $indexComps = Get-SPEnterpriseSearchComponent -SearchTopology $ssa.ActiveTopology ` - | Where-Object {($_.GetType().Name -eq "IndexComponent") ` - -and ($_.IndexPartitionOrdinal -eq $params.Index)} - - if (($indexComps -eq $null) -or ($indexComps.Count -eq 0)) { return @{ - Index = -1 - Servers = $params.Servers - RootDirectory = $null - InstallAccount = $params.InstallAccount - Ensure = "Absent" - } } - - $servers = "" - foreach ($indexComp in $indexComps) { - $servers += $indexComp.ServerName + "," - } - - return @{ - Index = $params.Index - Servers = $servers.TrimEnd(",") - RootDirectory = $params.RootDirectory - InstallAccount = $params.InstallAccount - Ensure = "Present" - } - } - return $result -} - -function Set-TargetResource -{ - [CmdletBinding()] - param - ( - [parameter(Mandatory = $true)] [System.UInt32] $Index, - [parameter(Mandatory = $true)] [System.String] $Servers, - [parameter(Mandatory = $true)] [System.String] $RootDirectory, - [parameter(Mandatory = $true)] [System.String] $ServiceAppName, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure - ) - - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - $ConfirmPreference = 'None' - - $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName - $newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $ssa.ActiveTopology - - $servers = $params["Servers"].Replace(" ", "").Split(",", [StringSplitOptions]::RemoveEmptyEntries) - - foreach($server in $servers) { - $ssi = Get-SPEnterpriseSearchServiceInstance -Identity $server - - if($ssi.Status -eq "Offline") { - Write-Verbose "Start Search Service Instance on $server" - Start-SPEnterpriseSearchServiceInstance -Identity $ssi - } - - #Wait for Search Service Instance to come online - $loopCount = 0 - $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; - do { - $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; - Write-Verbose "Waiting for service: $($online.TypeName)" - $loopCount++ - Start-Sleep -Seconds 30 - } - until ($online.Status -eq "Online" -or $loopCount -eq 20) - - if ($params.Ensure -eq "Present") { - Write-Verbose "Creating $($params.RootDirectory) on $server" - $networkPath = "\\$server\" + $params.RootDirectory.Replace(":\", "$\") - New-Item $networkPath -ItemType Directory -Force - New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $ssi -IndexPartition $params.Index -RootDirectory $params.RootDirectory - } - else { - $IndexComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | ? {($_.GetType().Name -eq "IndexComponent") -and ($_.ServerName -eq $($ssi.Server.Address)) -and ($_.IndexPartitionOrdinal -eq $params.Index)} - if($IndexComponent1) { - $IndexComponent1 | Remove-SPEnterpriseSearchComponent -SearchTopology $newTopology -confirm:$false - } - } - } - Set-SPEnterpriseSearchTopology -Identity $newTopology - } -} - -function Test-TargetResource -{ - [CmdletBinding()] - [OutputType([System.Boolean])] - param - ( - [parameter(Mandatory = $true)] [System.UInt32] $Index, - [parameter(Mandatory = $true)] [System.String] $Servers, - [parameter(Mandatory = $true)] [System.String] $RootDirectory, - [parameter(Mandatory = $true)] [System.String] $ServiceAppName, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure - ) - $CurrentValues = Get-TargetResource @PSBoundParameters - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Ensure", "Servers") -} - -Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof deleted file mode 100644 index 194c22676..000000000 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchIndexPartition/MSFT_xSPSearchIndexPartition.schema.mof +++ /dev/null @@ -1,33 +0,0 @@ -/* -**Description** - -This resource is responsible for creating search indexes. -It works by creating the index topology components and updating the topology from the server that runs this resource. -For this reason this resource only needs to run from one server and not from each server which will host the index component. -The search service application and existing search topology must be deployed before creating additional indexes. -The first index will be created through the use of the xSPSearchRoles resource. -Additional search index partitions can be created through using this resource. - -**Example** - - xSPSearchIndexPartition MainSearchPartition - { - Ensure = "Present" - Servers = "Server2,Server3" - Index = 1 - RootDirectory = "I:\SearchIndexes\1" - ServiceAppName = "Search Service Application" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPSearchRoles]LocalSearchRoles" - } -*/ -[ClassVersion("1.0.0.0"), FriendlyName("xSPSearchIndexPartition")] -class MSFT_xSPSearchIndexPartition : OMI_BaseResource -{ - [Key] Uint32 Index; - [Required] String Servers; - [Required] String RootDirectory; - [Required] String ServiceAppName; - [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; - [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; -}; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 deleted file mode 100644 index 71c432786..000000000 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.psm1 +++ /dev/null @@ -1,254 +0,0 @@ -function Get-TargetResource -{ - [CmdletBinding()] - [OutputType([System.Collections.Hashtable])] - param - ( - [parameter(Mandatory = $true)] [System.String] $ServiceAppName, - [parameter(Mandatory = $true)] [System.Boolean] $Admin, - [parameter(Mandatory = $true)] [System.Boolean] $Crawler, - [parameter(Mandatory = $true)] [System.Boolean] $ContentProcessing, - [parameter(Mandatory = $true)] [System.Boolean] $AnalyticsProcessing, - [parameter(Mandatory = $true)] [System.Boolean] $QueryProcessing, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, - [parameter(Mandatory = $false)] [System.UInt32] $FirstPartitionIndex, - [parameter(Mandatory = $true)] [System.String] $FirstPartitionDirectory, - [parameter(Mandatory = $true)] [System.String] $FirstPartitionServers - ) - - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - $ConfirmPreference = 'None' - - $AdminExists = $false; - $CrawlerExists = $false; - $ContentProcessingExists = $false; - $AnalyticsProcessingExists = $false; - $QueryProcessingExists = $false; - - $ssi = Get-SPEnterpriseSearchServiceInstance -Identity $env:COMPUTERNAME - $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName - if($ssi.Status -eq "Offline") { - Write-Verbose "Search is offline" - return @{ - ServiceAppName = $params.ServiceAppName - Admin = $false - Crawler = $false - ContentProcessing = $false - AnalyticsProcessing = $false - QueryProcessing = $false - InstallAccount = $params.InstallAccount - FirstPartitionIndex = $params.FirstPartitionIndex - FirstPartitionDirectory = $params.FirstPartitionDirectory - FirstPartitionServers = $params.FirstPartitionServers - Ensure = $params.Ensure - } - } - $currentTopology = $ssa.ActiveTopology - - #Make sure what we expect to be there is - $AdminComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "AdminComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if($AdminComponent1) { - $AdminExists = $true - } - $CrawlComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "CrawlComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if($CrawlComponent1) { - $CrawlerExists = $true - } - $ContentProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "ContentProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if($ContentProcessingComponent1) { - $ContentProcessingExists = $true - } - $AnalyticsProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "AnalyticsProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if($AnalyticsProcessingComponent1) { - $AnalyticsProcessingExists = $true - } - $QueryProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | Where-Object {($_.GetType().Name -eq "QueryProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if($QueryProcessingComponent1) { - $QueryProcessingExists = $true - } - - $indexComps = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology ` - | Where-Object {($_.GetType().Name -eq "IndexComponent") ` - -and ($_.IndexPartitionOrdinal -eq $params.Index)} - - $servers = "" - foreach ($indexComp in $indexComps) { - $servers += $indexComp.ServerName + "," - } - - return @{ - ServiceAppName = $params.ServiceAppName - Admin = $AdminExists - Crawler = $CrawlerExists - ContentProcessing = $ContentProcessingExists - AnalyticsProcessing = $AnalyticsProcessingExists - QueryProcessing = $QueryProcessingExists - InstallAccount = $params.InstallAccount - FirstPartitionIndex = $params.FirstPartitionIndex - FirstPartitionDirectory = $params.FirstPartitionDirectory - FirstPartitionServers = $servers.TrimEnd(",") - Ensure = $params.Ensure - } - } - return $result -} - - -function Set-TargetResource -{ - [CmdletBinding()] - param - ( - [parameter(Mandatory = $true)] [System.String] $ServiceAppName, - [parameter(Mandatory = $true)] [System.Boolean] $Admin, - [parameter(Mandatory = $true)] [System.Boolean] $Crawler, - [parameter(Mandatory = $true)] [System.Boolean] $ContentProcessing, - [parameter(Mandatory = $true)] [System.Boolean] $AnalyticsProcessing, - [parameter(Mandatory = $true)] [System.Boolean] $QueryProcessing, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, - [parameter(Mandatory = $false)] [System.UInt32] $FirstPartitionIndex, - [parameter(Mandatory = $true)] [System.String] $FirstPartitionDirectory, - [parameter(Mandatory = $true)] [System.String] $FirstPartitionServers - ) - - $CurrentValues = Get-TargetResource @PSBoundParameters - - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters, $CurrentValues) -ScriptBlock { - $params = $args[0] - $CurrentValues = $args[1] - $ConfirmPreference = 'None' - - $ssi = Get-SPEnterpriseSearchServiceInstance -Local - $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName - - if($ssi.Status -eq "Offline") { - Write-Verbose "Start Search Service Instance" - Start-SPEnterpriseSearchServiceInstance -Identity $ssi - } - - #Wait for Search Service Instance to come online - $loopCount = 0 - $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; - do { - $online = Get-SPEnterpriseSearchServiceInstance -Identity $ssi; - Write-Verbose "Waiting for service: $($online.TypeName)" - $loopCount++ - Start-Sleep -Seconds 30 - } - until ($online.Status -eq "Online" -or $loopCount -eq 20) - - $currentTopology = $ssa.ActiveTopology - $newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $currentTopology - - - if ($params.Ensure -eq "Present") { - if($CurrentValues.Admin -eq $false -and $params.Admin -eq $true) { - New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology ` - -SearchServiceInstance $ssi - } - if($CurrentValues.Crawler -eq $false -and $params.Crawler -eq $true) { - New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology ` - -SearchServiceInstance $ssi - } - if($CurrentValues.ContentProcessing -eq $false -and $params.ContentProcessing -eq $true) { - New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology ` - -SearchServiceInstance $ssi - } - if($CurrentValues.AnalyticsProcessing -eq $false -and $params.AnalyticsProcessing -eq $true) { - New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology ` - -SearchServiceInstance $ssi - } - if($CurrentValues.QueryProcessing -eq $false -and $params.QueryProcessing -eq $true) { - New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology ` - -SearchServiceInstance $ssi - } - - $IndexComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object { - ($_.GetType().Name -ccontains "IndexComponent") - } - - #Add the First search index if no other indexes already exist required - if($null -eq $IndexComponent1) { - Write-Verbose "Adding First search index at partition $($params.FirstPartitionIndex)" - - $servers = $params.FirstPartitionServers.Replace(" ", "").Split(',', [StringSplitOptions]::RemoveEmptyEntries) - foreach($server in $servers) { - $networkPath = "\\$server\" + $params.FirstPartitionDirectory.Replace(":\", "$\") - New-Item $networkPath -ItemType Directory -Force - - $indexSsi = Get-SPEnterpriseSearchServiceInstance -Identity $server - if($indexSsi.Status -eq "Offline") { - Write-Verbose "Start Search Service Instance" - Start-SPEnterpriseSearchServiceInstance -Identity $indexSsi - } - - #Wait for Search Service Instance to come online - $loopCount = 0 - $online = Get-SPEnterpriseSearchServiceInstance -Identity $indexSsi; - do { - $online = Get-SPEnterpriseSearchServiceInstance -Identity $indexSsi; - Write-Verbose "Waiting for service: $($online.TypeName)" - $loopCount++ - Start-Sleep -Seconds 30 - } - until ($online.Status -eq "Online" -or $loopCount -eq 20) - New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $indexSsi -IndexPartition $params.FirstPartitionIndex -RootDirectory $params.FirstPartitionDirectory - } - } - Set-SPEnterpriseSearchTopology -Identity $newTopology - } else { - $AdminComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "AdminComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if (($params.Admin -eq $false) -and ($null -ne $AdminComponent1)) { - Remove-SPEnterpriseSearchComponent -Identity $AdminComponent1.ComponentId -SearchTopology $newTopology -confirm:$false - } - $CrawlComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "CrawlComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if (($params.Crawler -eq $false) -and ($null -ne $CrawlComponent1)) { - Remove-SPEnterpriseSearchComponent -Identity $CrawlComponent1.ComponentId -SearchTopology $newTopology -confirm:$false - } - $ContentProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "ContentProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if (($params.ContentProcessing -eq $false) -and ($null -ne $ContentProcessingComponent1)) { - Remove-SPEnterpriseSearchComponent -Identity $ContentProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false - } - $AnalyticsProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "AnalyticsProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if (($params.AnalyticsProcessing -eq $false) -and ($null -ne $AnalyticsProcessingComponent1)) { - Remove-SPEnterpriseSearchComponent -Identity $AnalyticsProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false - } - $QueryProcessingComponent1 = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | Where-Object {($_.GetType().Name -eq "QueryProcessingComponent") -and ($_.ServerName -eq $($ssi.Server.Address))} - if (($params.QueryProcessing -eq $false) -and ($null -ne $QueryProcessingComponent1)) { - Remove-SPEnterpriseSearchComponent -Identity $QueryProcessingComponent1.ComponentId -SearchTopology $newTopology -confirm:$false - } - - Set-SPEnterpriseSearchTopology -Identity $newTopology - } - } -} - - -function Test-TargetResource -{ - [CmdletBinding()] - [OutputType([System.Boolean])] - param - ( - [parameter(Mandatory = $true)] [System.String] $ServiceAppName, - [parameter(Mandatory = $true)] [System.Boolean] $Admin, - [parameter(Mandatory = $true)] [System.Boolean] $Crawler, - [parameter(Mandatory = $true)] [System.Boolean] $ContentProcessing, - [parameter(Mandatory = $true)] [System.Boolean] $AnalyticsProcessing, - [parameter(Mandatory = $true)] [System.Boolean] $QueryProcessing, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, - [parameter(Mandatory = $false)] [System.UInt32] $FirstPartitionIndex, - [parameter(Mandatory = $true)] [System.String] $FirstPartitionDirectory, - [parameter(Mandatory = $true)] [System.String] $FirstPartitionServers - ) - - $CurrentValues = Get-TargetResource @PSBoundParameters - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Ensure", "Admin", "Crawler", "ContentProcessing", "AnalyticsProcessing", "QueryProcessing") -} - -Export-ModuleMember -Function *-TargetResource - diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof deleted file mode 100644 index 84a0b581c..000000000 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchRoles/MSFT_xSPSearchRoles.schema.mof +++ /dev/null @@ -1,42 +0,0 @@ -/* -**Description** - -This resource is responsible for provisioning a search topology in to the current farm. -It allows the configuration to dictate the search topology roles that the current server should be running. -Any combination of roles can be specified and the topology will be upaded to reflect the current servers new roles. -If this is the first server to apply topology to a farm, then at least one search index must be provided. -To this end, the FirstPartitionIndex, FirstPartitionDirectory and FirstPartitionServers allow configuring where the first index partition will belong. -This will behave the same as the xSPSearchIndexPartition resource. - -**Example** - - xSPSearchRoles LocalSearchRoles - { - Ensure = "Present" - Admin = $true - Crawler = $true - ContentProcessing = $true - AnalyticsProcessing = $true - QueryProcessing = $true - ServiceAppName = "Search Service Application" - PsDscRunAsCredential = $SPSetupAccount - FirstPartitionIndex = 0 - FirstPartitionDirectory = "I:\SearchIndexes\0" - FirstPartitionServers = "Server1,Server2" - } -*/ -[ClassVersion("1.0.0.0"), FriendlyName("xSPSearchRoles")] -class MSFT_xSPSearchRoles : OMI_BaseResource -{ - [Key] String ServiceAppName; - [Required] Boolean Admin; - [Required] Boolean Crawler; - [Required] Boolean ContentProcessing; - [Required] Boolean AnalyticsProcessing; - [Required] Boolean QueryProcessing; - [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; - [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; - [Write] Uint32 FirstPartitionIndex; - [Write] String FirstPartitionDirectory; - [Write] String FirstPartitionServers; -}; diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index dfcaede53..ed34fb6b5 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -62,7 +62,6 @@ - @@ -73,7 +72,6 @@ - @@ -105,8 +103,6 @@ - - @@ -132,8 +128,6 @@ - - From d0ac88201479cd93de6ef24987bc7ab4e3f4b345 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Wed, 25 Nov 2015 09:47:13 +1100 Subject: [PATCH 056/147] Removed search topology tests --- Tests/Tests.pssproj | 2 - ...arePoint.xSPSearchIndexPartition.Tests.ps1 | 126 --------- .../xSharePoint.xSPSearchRoles.Tests.ps1 | 247 ------------------ 3 files changed, 375 deletions(-) delete mode 100644 Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 delete mode 100644 Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 6606ac3b5..c41c07e08 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -67,8 +67,6 @@ - - diff --git a/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 deleted file mode 100644 index 63332c62c..000000000 --- a/Tests/xSharePoint/xSharePoint.xSPSearchIndexPartition.Tests.ps1 +++ /dev/null @@ -1,126 +0,0 @@ -[CmdletBinding()] -param( - [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) -) - -$ErrorActionPreference = 'stop' -Set-StrictMode -Version latest - -$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path -$Global:CurrentSharePointStubModule = $SharePointCmdletModule - -$ModuleName = "MSFT_xSPSearchIndexPartition" -Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") - -Describe "xSPSearchIndexPartition" { - InModuleScope $ModuleName { - $testParams = @{ - Index = "0" - Servers = $env:COMPUTERNAME - RootDirectory = "C:\SearchIndex\0" - Ensure = "Present" - ServiceAppName = "Search Service Application" - } - Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") - Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue - - Mock Invoke-xSharePointCommand { - return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope - } - Mock New-PSSession { - return $null - } - Mock New-Item { return @{} } - Mock Get-SPEnterpriseSearchServiceApplication { - return @{ - ActiveTopology = @{} - } - } - Mock New-SPEnterpriseSearchTopology { return @{} } - - $Global:xSharePointSearchRoleInstanceCallCount = 0 - Mock Get-SPEnterpriseSearchServiceInstance { - if ($Global:xSharePointSearchRoleInstanceCallCount -eq 2) { - $Global:xSharePointSearchRoleInstanceCallCount = 0 - return @{ - Server = @{ - Address = $env:COMPUTERNAME - } - Status = "Online" - } - } else { - $Global:xSharePointSearchRoleInstanceCallCount++ - return @{ - Server = @{ - Address = $env:COMPUTERNAME - } - Status = "Offline" - } - } - } - Mock Start-SPEnterpriseSearchServiceInstance { return $null } - Mock New-SPEnterpriseSearchIndexComponent { return $null } - Mock Remove-SPEnterpriseSearchComponent { return $null } - Mock Set-SPEnterpriseSearchTopology { return $null } - - Add-Type -TypeDefinition "public class IndexComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;} public System.Int32 IndexPartitionOrdinal {get; set;}}" - $indexComponent = New-Object IndexComponent - $indexComponent.ServerName = $env:COMPUTERNAME - $indexComponent.IndexPartitionOrdinal = 0 - - Context "Search index doesn't exist and it should" { - Mock Get-SPEnterpriseSearchComponent { return @() } - $Global:xSharePointSearchRoleInstanceCallCount = 0 - - It "returns absent from the get method" { - $result = Get-TargetResource @testParams - $result.Ensure | Should Be "Absent" - } - - It "returns false from the test method" { - Test-TargetResource @testParams | Should Be $false - } - - It "creates the search index in the set method" { - Set-TargetResource @testParams - Assert-MockCalled New-SPEnterpriseSearchIndexComponent - } - } - - Context "Search index does exist and it should" { - Mock Get-SPEnterpriseSearchComponent { return @($indexComponent) } - - It "returns present from the get method" { - $result = Get-TargetResource @testParams - $result.Ensure | Should Be "Present" - } - - It "returns true from the test method" { - Test-TargetResource @testParams | Should Be $true - } - } - - $testParams.Ensure = "Absent" - - Context "Search index exists and it shouldn't" { - Mock Get-SPEnterpriseSearchComponent { return @($indexComponent) } - - It "returns false from the test method" { - Test-TargetResource @testParams | Should Be $false - } - - It "removes the search index in the set method" { - Set-TargetResource @testParams - Assert-MockCalled Remove-SPEnterpriseSearchComponent - } - } - - Context "Search index doesn't exist and it shouldn't" { - Mock Get-SPEnterpriseSearchComponent { return @() } - - It "returns true from the test method" { - Test-TargetResource @testParams | Should Be $true - } - } - } -} \ No newline at end of file diff --git a/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 deleted file mode 100644 index b59ad1f0b..000000000 --- a/Tests/xSharePoint/xSharePoint.xSPSearchRoles.Tests.ps1 +++ /dev/null @@ -1,247 +0,0 @@ -[CmdletBinding()] -param( - [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) -) - -$ErrorActionPreference = 'stop' -Set-StrictMode -Version latest - -$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path -$Global:CurrentSharePointStubModule = $SharePointCmdletModule - -$ModuleName = "MSFT_xSPSearchRoles" -Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") - -Describe "xSPSearchRoles" { - InModuleScope $ModuleName { - $testParams = @{ - ServiceAppName = "Search Service Application" - Admin = $true - Crawler = $true - ContentProcessing = $true - AnalyticsProcessing = $true - QueryProcessing = $true - Ensure = "Present" - FirstPartitionIndex = "0" - FirstPartitionDirectory = "C:\ExamplePath" - FirstPartitionServers = $env:COMPUTERNAME - } - Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") - Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue - - Mock Invoke-xSharePointCommand { - return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope - } - Mock New-PSSession { - return $null - } - Mock New-Item { return @{} } - Mock Get-SPEnterpriseSearchServiceInstance { - return @{ - Server = @{ - Address = $env:COMPUTERNAME - } - Status = "Online" - } - } - Mock Get-SPEnterpriseSearchServiceApplication { - return @{ - ActiveTopology = @{} - } - } - - Add-Type -TypeDefinition "public class AdminComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - Add-Type -TypeDefinition "public class CrawlComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - Add-Type -TypeDefinition "public class ContentProcessingComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - Add-Type -TypeDefinition "public class AnalyticsProcessingComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - Add-Type -TypeDefinition "public class QueryProcessingComponent { public string ServerName { get; set; } public System.Guid ComponentId {get; set;}}" - - $adminComponent = New-Object AdminComponent - $adminComponent.ServerName = $env:COMPUTERNAME - $adminComponent.ComponentId = [Guid]::NewGuid() - - $crawlComponent = New-Object CrawlComponent - $crawlComponent.ServerName = $env:COMPUTERNAME - $crawlComponent.ComponentId = [Guid]::NewGuid() - - $contentProcessingComponent = New-Object ContentProcessingComponent - $contentProcessingComponent.ServerName = $env:COMPUTERNAME - $contentProcessingComponent.ComponentId = [Guid]::NewGuid() - - $analyticsProcessingComponent = New-Object AnalyticsProcessingComponent - $analyticsProcessingComponent.ServerName = $env:COMPUTERNAME - $analyticsProcessingComponent.ComponentId = [Guid]::NewGuid() - - $queryProcessingComponent = New-Object QueryProcessingComponent - $queryProcessingComponent.ServerName = $env:COMPUTERNAME - $queryProcessingComponent.ComponentId = [Guid]::NewGuid() - - Mock Start-SPEnterpriseSearchServiceInstance { return $null } - Mock New-SPEnterpriseSearchTopology { return @{} } - Mock New-SPEnterpriseSearchAdminComponent { return @{} } - Mock New-SPEnterpriseSearchCrawlComponent { return @{} } - Mock New-SPEnterpriseSearchContentProcessingComponent { return @{} } - Mock New-SPEnterpriseSearchAnalyticsProcessingComponent { return @{} } - Mock New-SPEnterpriseSearchQueryProcessingComponent { return @{} } - Mock New-SPEnterpriseSearchIndexComponent { return @{} } - Mock Set-SPEnterpriseSearchTopology { return @{} } - Mock Remove-SPEnterpriseSearchComponent { return $null } - - Context "No search topology has been applied" { - Mock Get-SPEnterpriseSearchComponent { - return @{} - } - - It "returns false values from the get method" { - $result = Get-TargetResource @testParams - $result.Admin | Should Be $false - $result.Crawler | Should Be $false - $result.ContentProcessing | Should Be $false - $result.AnalyticsProcessing | Should Be $false - $result.QueryProcessing | Should Be $false - } - - It "returns false from the test method" { - Test-TargetResource @testParams | Should Be $false - } - - It "sets the desired topology for the current server" { - Set-TargetResource @testParams - } - } - - Context "No search topology exist and the search service instance isnt running" { - Mock Get-SPEnterpriseSearchComponent { - return @{} - } - $Global:xSharePointSearchRoleInstanceCalLCount = 0 - Mock Get-SPEnterpriseSearchServiceInstance { - if ($Global:xSharePointSearchRoleInstanceCalLCount -eq 2) { - $Global:xSharePointSearchRoleInstanceCalLCount = 0 - return @{ - Status = "Online" - } - } else { - $Global:xSharePointSearchRoleInstanceCalLCount++ - return @{ - Status = "Offline" - } - } - } - - It "sets the desired topology for the current server and starts the search service instance" { - Set-TargetResource @testParams - Assert-MockCalled Start-SPEnterpriseSearchServiceInstance - } - - } - - Context "A search topology has been applied but it is not correct" { - - Mock Get-SPEnterpriseSearchServiceInstance { - return @{ - Server = @{ - Address = $env:COMPUTERNAME - } - Status = "Online" - } - } - - It "adds a missing admin component" { - Mock Get-SPEnterpriseSearchComponent { - return @($crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) - } - Set-TargetResource @testParams - Assert-MockCalled New-SPEnterpriseSearchAdminComponent - } - - It "adds a missing crawl component" { - Mock Get-SPEnterpriseSearchComponent { - return @($adminComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) - } - Set-TargetResource @testParams - Assert-MockCalled New-SPEnterpriseSearchCrawlComponent - } - - It "adds a missing content processing component" { - Mock Get-SPEnterpriseSearchComponent { - return @($adminComponent, $crawlComponent, $analyticsProcessingComponent, $queryProcessingComponent) - } - Set-TargetResource @testParams - Assert-MockCalled New-SPEnterpriseSearchContentProcessingComponent - } - - It "adds a missing analytics processing component" { - Mock Get-SPEnterpriseSearchComponent { - return @($adminComponent, $crawlComponent, $contentProcessingComponent, $queryProcessingComponent) - } - Set-TargetResource @testParams - Assert-MockCalled New-SPEnterpriseSearchAnalyticsProcessingComponent - } - - It "adds a missing query processing component" { - Mock Get-SPEnterpriseSearchComponent { - return @($adminComponent, $crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent) - } - Set-TargetResource @testParams - Assert-MockCalled New-SPEnterpriseSearchQueryProcessingComponent - } - - $testParams = @{ - ServiceAppName = "Search Service Application" - Admin = $false - Crawler = $false - ContentProcessing = $false - AnalyticsProcessing = $false - QueryProcessing = $false - Ensure = "Absent" - FirstPartitionIndex = "0" - FirstPartitionDirectory = "C:\ExamplePath" - FirstPartitionServers = $env:COMPUTERNAME - } - - Mock Get-SPEnterpriseSearchComponent { - return @($adminComponent, $crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) - } - - It "Removes components that shouldn't be on this server" { - Set-TargetResource @testParams - Assert-MockCalled Remove-SPEnterpriseSearchComponent -Times 5 - } - - - } - - Context "The correct topology on this server exists" { - Mock Get-SPEnterpriseSearchComponent { - return @($adminComponent, $crawlComponent, $contentProcessingComponent, $analyticsProcessingComponent, $queryProcessingComponent) - } - - Mock Get-SPEnterpriseSearchServiceInstance { - return @{ - Server = @{ - Address = $env:COMPUTERNAME - } - Status = "Online" - } - } - - $testParams = @{ - ServiceAppName = "Search Service Application" - Admin = $true - Crawler = $true - ContentProcessing = $true - AnalyticsProcessing = $true - QueryProcessing = $true - Ensure = "Present" - FirstPartitionIndex = "0" - FirstPartitionDirectory = "C:\ExamplePath" - FirstPartitionServers = $env:COMPUTERNAME - } - - It "returns true from the test method" { - Test-TargetResource @testParams -Verbose | Should Be $true - } - } - } -} \ No newline at end of file From df6c217d4ce865962f3bc296c8501fc8c7b3644a Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Wed, 25 Nov 2015 09:56:17 +1100 Subject: [PATCH 057/147] Removed search tolopolgy from single server example --- .../Examples/Single Server/SharePoint.ps1 | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 b/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 index 42829dede..28d4d58df 100644 --- a/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 +++ b/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 @@ -335,30 +335,6 @@ Configuration SharePointServer PsDscRunAsCredential = $SPSetupAccount DependsOn = "[xSPServiceAppPool]MainServiceAppPool" } - xSPSearchRoles LocalSearchRoles - { - Ensure = "Present" - Admin = $true - Crawler = $true - ContentProcessing = $true - AnalyticsProcessing = $true - QueryProcessing = $true - ServiceAppName = "Search Service Application" - PsDscRunAsCredential = $SPSetupAccount - FirstPartitionIndex = 0 - FirstPartitionDirectory = "$($ConfigurationData.NonNodeData.SharePoint.Search.IndexRootPath.TrimEnd("\"))\0" - FirstPartitionServers = $env:COMPUTERNAME - DependsOn = "[xSPSearchServiceApp]SearchServiceApp" - } - xSPSearchIndexPartition MainSearchPartition - { - Ensure = "Present" - Servers = $env:COMPUTERNAME - Index = 1 - RootDirectory = "$($ConfigurationData.NonNodeData.SharePoint.Search.IndexRootPath.TrimEnd("\"))\1" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPSearchRoles]LocalSearchRoles" - } #********************************************************** # Local configuration manager settings From 6c9ad9fbed089913aa6dd7b19955f2ea0de50e56 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Wed, 25 Nov 2015 20:21:17 +0200 Subject: [PATCH 058/147] Fix for 'Prerequisite Installer Does Not Validate File Paths' #100 --- .../MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 index 41f852290..558116680 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 @@ -125,6 +125,9 @@ function Set-TargetResource $requiredParams | ForEach-Object { if (($PSBoundParameters.ContainsKey($_) -and [string]::IsNullOrEmpty($PSBoundParameters.$_)) -or (-not $PSBoundParameters.ContainsKey($_))) { throw "In offline mode for version $majorVersion parameter $_ is required" + } + if ((Test-Path $PSBoundParameters.$_) -eq $false) { + throw "The $_ parameter has been passed but the file cannot be found at the path supplied: `"$($PSBoundParameters.$_)`"" } } $requiredParams | ForEach-Object { From 3852420ccf1206b1bc4ec60632e74cad800cc02f Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 12:57:44 +1100 Subject: [PATCH 059/147] Updated examples --- .../Examples/Single Server/SharePoint.ps1 | 15 +- .../Examples/Single Server/SharePoint.psd1 | 3 - .../Examples/Small Farm/AppServer.ps1 | 165 ------- .../Examples/Small Farm/FirstServer.ps1 | 373 -------------- .../Examples/Small Farm/SharePoint.ps1 | 466 ++++++++++++++++++ .../Examples/Small Farm/SharePoint.psd1 | 127 +++++ .../Examples/Small Farm/WFEServer.ps1 | 189 ------- 7 files changed, 599 insertions(+), 739 deletions(-) delete mode 100644 Modules/xSharePoint/Examples/Small Farm/AppServer.ps1 delete mode 100644 Modules/xSharePoint/Examples/Small Farm/FirstServer.ps1 create mode 100644 Modules/xSharePoint/Examples/Small Farm/SharePoint.ps1 create mode 100644 Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 delete mode 100644 Modules/xSharePoint/Examples/Small Farm/WFEServer.ps1 diff --git a/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 b/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 index 28d4d58df..80f620084 100644 --- a/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 +++ b/Modules/xSharePoint/Examples/Single Server/SharePoint.ps1 @@ -257,15 +257,12 @@ Configuration SharePointServer } } - # Search front or back end instances - if ($Node.ServiceRoles.SearchFrontEnd -eq $true -or $Node.ServiceRoles.SearchBackEnd -eq $true) { - xSPServiceInstance SearchServiceInstance - { - Name = "SharePoint Server Search" - Ensure = "Present" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } + xSPServiceInstance SearchServiceInstance + { + Name = "SharePoint Server Search" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPCreateFarm]CreateSPFarm" } #********************************************************** diff --git a/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 b/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 index 3815a2719..5595b3490 100644 --- a/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 +++ b/Modules/xSharePoint/Examples/Single Server/SharePoint.psd1 @@ -8,8 +8,6 @@ ServiceRoles = @{ WebFrontEnd = $true DistributedCache = $true - SearchFrontEnd = $true - SearchBackEnd = $true AppServer = $true } } @@ -98,7 +96,6 @@ } Search = @{ DatabaseName = "SP_Search" - IndexRootPath = "C:\SearchPartitions" } } } diff --git a/Modules/xSharePoint/Examples/Small Farm/AppServer.ps1 b/Modules/xSharePoint/Examples/Small Farm/AppServer.ps1 deleted file mode 100644 index 0578e3cb5..000000000 --- a/Modules/xSharePoint/Examples/Small Farm/AppServer.ps1 +++ /dev/null @@ -1,165 +0,0 @@ -Configuration SharePointAppServer -{ - param ( - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $CredSSPDelegates, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $SPBinaryPath, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $ULSViewerPath, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $SPBinaryPathCredential, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $FarmAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $InstallAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $ProductKey, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $DatabaseServer, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $FarmPassPhrase, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $WebPoolManagedAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $ServicePoolManagedAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $WebAppUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $MySiteHostUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $TeamSiteUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [int] $CacheSizeInMB - ) - Import-DscResource -ModuleName xSharePoint - Import-DscResource -ModuleName xWebAdministration - Import-DscResource -ModuleName xCredSSP - Import-DscResource -ModuleName xDisk - - node "localhost" - { - #********************************************************** - # Server configuration - # - # This section of the configuration includes details of the - # server level configuration, such as disks, registry - # settings etc. - #********************************************************** - - xDisk LogsDisk { DiskNumber = 2; DriveLetter = "l" } - xDisk IndexDisk { DiskNumber = 3; DriveLetter = "i" } - xCredSSP CredSSPServer { Ensure = "Present"; Role = "Server" } - xCredSSP CredSSPClient { Ensure = "Present"; Role = "Client"; DelegateComputers = $CredSSPDelegates } - - - #********************************************************** - # Software downloads - # - # This section details where any binary downloads should - # be downloaded from and put locally on the server before - # installation takes place - #********************************************************** - - File SPBinaryDownload - { - DestinationPath = "C:\SPInstall" - Credential = $SPBinaryPathCredential - Ensure = "Present" - SourcePath = $SPBinaryPath - Type = "Directory" - Recurse = $true - } - File UlsViewerDownload - { - DestinationPath = "L:\UlsViewer.exe" - Credential = $SPBinaryPathCredential - Ensure = "Present" - SourcePath = $ULSViewerPath - Type = "File" - DependsOn = "[xDisk]LogsDisk" - } - - #********************************************************** - # Binary installation - # - # This section triggers installation of both SharePoint - # as well as the prerequisites required - #********************************************************** - xSPInstallPrereqs InstallPrerequisites - { - InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" - OnlineMode = $true - SQLNCli = "C:\SPInstall\prerequisiteinstallerfiles\sqlncli.msi" - PowerShell = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB2506143-x64.msu" - NETFX = "C:\SPInstall\prerequisiteinstallerfiles\dotNetFx45_Full_setup.exe" - IDFX = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB974405-x64.msu" - Sync = "C:\SPInstall\prerequisiteinstallerfiles\Synchronization.msi" - AppFabric = "C:\SPInstall\prerequisiteinstallerfiles\WindowsServerAppFabricSetup_x64.exe" - IDFX11 = "C:\SPInstall\prerequisiteinstallerfiles\MicrosoftIdentityExtensions-64.msi" - MSIPCClient = "C:\SPInstall\prerequisiteinstallerfiles\setup_msipc_x64.msi" - WCFDataServices = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices.exe" - KB2671763 = "C:\SPInstall\prerequisiteinstallerfiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe" - WCFDataServices56 = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices56.exe" - DependsOn = "[xSPClearRemoteSessions]ClearRemotePowerShellSessions" - } - xSPInstall InstallBinaries - { - BinaryDir = "C:\SPInstall" - ProductKey = $ProductKey - Ensure = "Present" - DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" - } - - #********************************************************** - # IIS clean up - # - # This section removes all default sites and application - # pools from IIS as they are not required - #********************************************************** - - xWebAppPool RemoveDotNet2Pool { Name = ".NET v2.0"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDotNet2ClassicPool { Name = ".NET v2.0 Classic"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDotNet45Pool { Name = ".NET v4.5"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites"; } - xWebAppPool RemoveDotNet45ClassicPool { Name = ".NET v4.5 Classic"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites"; } - xWebAppPool RemoveClassicDotNetPool { Name = "Classic .NET AppPool"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDefaultAppPool { Name = "DefaultAppPool"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebSite RemoveDefaultWebSite { Name = "Default Web Site"; Ensure = "Absent"; PhysicalPath = "C:\inetpub\wwwroot"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - - - #********************************************************** - # Basic farm configuration - # - # This section creates the new SharePoint farm object, and - # provisions generic services and components used by the - # whole farm - #********************************************************** - - xSPJoinFarm JoinSPFarm - { - DatabaseServer = $DatabaseServer - FarmConfigDatabaseName = "SP_Config" - Passphrase = $FarmPassPhrase - InstallAccount = $InstallAccount - DependsOn = "[xSPInstall]InstallBinaries" - } - - #********************************************************** - # Service instances - # - # This section describes which services should be running - # and not running on the server - #********************************************************** - - xSPServiceInstance ClaimsToWindowsTokenServiceInstance - { - Name = "Claims to Windows Token Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPJoinFarm]JoinSPFarm" - } - xSPServiceInstance UserProfileServiceInstance - { - Name = "User Profile Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPJoinFarm]JoinSPFarm" - } - - #********************************************************** - # Local configuration manager settings - # - # This section contains settings for the LCM of the host - # that this configuration is applied to - #********************************************************** - LocalConfigurationManager - { - RebootNodeIfNeeded = $true - } - } -} diff --git a/Modules/xSharePoint/Examples/Small Farm/FirstServer.ps1 b/Modules/xSharePoint/Examples/Small Farm/FirstServer.ps1 deleted file mode 100644 index 776d54b37..000000000 --- a/Modules/xSharePoint/Examples/Small Farm/FirstServer.ps1 +++ /dev/null @@ -1,373 +0,0 @@ -Configuration SharePointFarmServer -{ - param ( - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $CredSSPDelegates, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $SPBinaryPath, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $ULSViewerPath, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $SPBinaryPathCredential, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $FarmAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $InstallAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $ProductKey, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $DatabaseServer, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $FarmPassPhrase, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $WebPoolManagedAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $ServicePoolManagedAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $WebAppUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $MySiteHostUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $TeamSiteUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [int] $CacheSizeInMB - ) - Import-DscResource -ModuleName xSharePoint - Import-DscResource -ModuleName xWebAdministration - Import-DscResource -ModuleName xCredSSP - Import-DscResource -ModuleName xDisk - - node "localhost" - { - #********************************************************** - # Server configuration - # - # This section of the configuration includes details of the - # server level configuration, such as disks, registry - # settings etc. - #********************************************************** - - xDisk LogsDisk { DiskNumber = 2; DriveLetter = "l" } - xDisk IndexDisk { DiskNumber = 3; DriveLetter = "i" } - xCredSSP CredSSPServer { Ensure = "Present"; Role = "Server" } - xCredSSP CredSSPClient { Ensure = "Present"; Role = "Client"; DelegateComputers = $CredSSPDelegates } - - - #********************************************************** - # Software downloads - # - # This section details where any binary downloads should - # be downloaded from and put locally on the server before - # installation takes place - #********************************************************** - - File SPBinaryDownload - { - DestinationPath = "C:\SPInstall" - Credential = $SPBinaryPathCredential - Ensure = "Present" - SourcePath = $SPBinaryPath - Type = "Directory" - Recurse = $true - } - File UlsViewerDownload - { - DestinationPath = "L:\UlsViewer.exe" - Credential = $SPBinaryPathCredential - Ensure = "Present" - SourcePath = $ULSViewerPath - Type = "File" - DependsOn = "[xDisk]LogsDisk" - } - - #********************************************************** - # Binary installation - # - # This section triggers installation of both SharePoint - # as well as the prerequisites required - #********************************************************** - xSPInstallPrereqs InstallPrerequisites - { - InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" - OnlineMode = $true - SQLNCli = "C:\SPInstall\prerequisiteinstallerfiles\sqlncli.msi" - PowerShell = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB2506143-x64.msu" - NETFX = "C:\SPInstall\prerequisiteinstallerfiles\dotNetFx45_Full_setup.exe" - IDFX = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB974405-x64.msu" - Sync = "C:\SPInstall\prerequisiteinstallerfiles\Synchronization.msi" - AppFabric = "C:\SPInstall\prerequisiteinstallerfiles\WindowsServerAppFabricSetup_x64.exe" - IDFX11 = "C:\SPInstall\prerequisiteinstallerfiles\MicrosoftIdentityExtensions-64.msi" - MSIPCClient = "C:\SPInstall\prerequisiteinstallerfiles\setup_msipc_x64.msi" - WCFDataServices = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices.exe" - KB2671763 = "C:\SPInstall\prerequisiteinstallerfiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe" - WCFDataServices56 = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices56.exe" - DependsOn = "[xSPClearRemoteSessions]ClearRemotePowerShellSessions" - } - xSPInstall InstallBinaries - { - BinaryDir = "C:\SPInstall" - ProductKey = $ProductKey - Ensure = "Present" - DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" - } - - #********************************************************** - # IIS clean up - # - # This section removes all default sites and application - # pools from IIS as they are not required - #********************************************************** - - xWebAppPool RemoveDotNet2Pool { Name = ".NET v2.0"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDotNet2ClassicPool { Name = ".NET v2.0 Classic"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDotNet45Pool { Name = ".NET v4.5"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites"; } - xWebAppPool RemoveDotNet45ClassicPool { Name = ".NET v4.5 Classic"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites"; } - xWebAppPool RemoveClassicDotNetPool { Name = "Classic .NET AppPool"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDefaultAppPool { Name = "DefaultAppPool"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebSite RemoveDefaultWebSite { Name = "Default Web Site"; Ensure = "Absent"; PhysicalPath = "C:\inetpub\wwwroot"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - - - #********************************************************** - # Basic farm configuration - # - # This section creates the new SharePoint farm object, and - # provisions generic services and components used by the - # whole farm - #********************************************************** - - xSPCreateFarm CreateSPFarm - { - DatabaseServer = $DatabaseServer - FarmConfigDatabaseName = "SP_Config" - Passphrase = $FarmPassPhrase - FarmAccount = $FarmAccount - InstallAccount = $InstallAccount - AdminContentDatabaseName = "SP_AdminContent" - DependsOn = "[xSPInstall]InstallBinaries" - } - xSPManagedAccount ServicePoolManagedAccount - { - AccountName = $ServicePoolManagedAccount.UserName - Account = $ServicePoolManagedAccount - Schedule = "" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPManagedAccount WebPoolManagedAccount - { - AccountName = $WebPoolManagedAccount.UserName - Account = $WebPoolManagedAccount - Schedule = "" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPDiagnosticLoggingSettings ApplyDiagnosticLogSettings - { - InstallAccount = $InstallAccount - LogPath = "L:\ULSLogs" - LogSpaceInGB = 10 - AppAnalyticsAutomaticUploadEnabled = $false - CustomerExperienceImprovementProgramEnabled = $true - DaysToKeepLogs = 7 - DownloadErrorReportingUpdatesEnabled = $false - ErrorReportingAutomaticUploadEnabled = $false - ErrorReportingEnabled = $false - EventLogFloodProtectionEnabled = $true - EventLogFloodProtectionNotifyInterval = 5 - EventLogFloodProtectionQuietPeriod = 2 - EventLogFloodProtectionThreshold = 5 - EventLogFloodProtectionTriggerPeriod = 2 - LogCutInterval = 15 - LogMaxDiskSpaceUsageEnabled = $true - ScriptErrorReportingDelay = 30 - ScriptErrorReportingEnabled = $true - ScriptErrorReportingRequireAuth = $true - DependsOn = @("[xSPCreateFarm]CreateSPFarm", "[xDisk]LogsDisk") - } - xSPUsageApplication UsageApplication - { - Name = "Usage Service Application" - DatabaseName = "SP_Usage" - UsageLogCutTime = 5 - UsageLogLocation = "L:\UsageLogs" - UsageLogMaxFileSizeKB = 1024 - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPStateServiceApp StateServiceApp - { - Name = "State Service Application" - DatabaseName = "SP_State" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - - #********************************************************** - # Web applications - # - # This section creates the web applications in the - # SharePoint farm, as well as managed paths and other web - # application settings - #********************************************************** - - xSPWebApplication HostNameSiteCollectionWebApp - { - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Sites" - ApplicationPoolAccount = $WebPoolManagedAccount.UserName - AllowAnonymous = $false - AuthenticationMethod = "NTLM" - DatabaseName = "SP_Content_01" - DatabaseServer = $DatabaseServer - Url = $WebAppUrl - Port = 80 - InstallAccount = $InstallAccount - DependsOn = "[xSPManagedAccount]WebPoolManagedAccount" - } - xSPManagedPath TeamsManagedPath - { - WebAppUrl = "http://$WebAppUrl" - InstallAccount = $InstallAccount - RelativeUrl = "teams" - Explicit = $false - HostHeader = $true - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" - } - xSPManagedPath PersonalManagedPath - { - WebAppUrl = "http://$WebAppUrl" - InstallAccount = $InstallAccount - RelativeUrl = "personal" - Explicit = $false - HostHeader = $true - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" - } - xSPCacheAccounts SetCacheAccounts - { - WebAppUrl = "http://$WebAppUrl" - SuperUserAlias = "DEMO\svxSPSuperUser" - SuperReaderAlias = "DEMO\svxSPReader" - InstallAccount = $InstallAccount - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" - } - - #********************************************************** - # Service instances - # - # This section describes which services should be running - # and not running on the server - #********************************************************** - - xSPServiceInstance ClaimsToWindowsTokenServiceInstance - { - Name = "Claims to Windows Token Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPServiceInstance UserProfileServiceInstance - { - Name = "User Profile Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPUserProfileSyncService UserProfileSyncService - { - UserProfileServiceAppName = "User Profile Service Application" - Ensure = "Present" - FarmAccount = $FarmAccount - InstallAccount = $InstallAccount - DependsOn = "[xSPUserProfileServiceApp]UserProfileServiceApp" - } - - #********************************************************** - # Service applications - # - # This section creates service applications and required - # dependencies - #********************************************************** - - xSPServiceAppPool MainServiceAppPool - { - Name = "SharePoint Service Applications" - ServiceAccount = $ServicePoolManagedAccount.UserName - InstallAccount = $InstallAccount - DependsOn = "[xSPCreateFarm]CreateSPFarm" - } - xSPUserProfileServiceApp UserProfileServiceApp - { - Name = "User Profile Service Application" - ApplicationPool = "SharePoint Service Applications" - MySiteHostLocation = "http://$MySiteHostUrl" - ProfileDBName = "SP_UserProfiles" - ProfileDBServer = $DatabaseServer - SocialDBName = "SP_Social" - SocialDBServer = $DatabaseServer - SyncDBName = "SP_ProfileSync" - SyncDBServer = $DatabaseServer - FarmAccount = $FarmAccount - InstallAccount = $InstallAccount - DependsOn = @('[xSPServiceAppPool]MainServiceAppPool', '[xSPManagedPath]PersonalManagedPath', '[xSPSite]MySiteHost', '[xSPManagedMetaDataServiceApp]ManagedMetadataServiceApp', '[xSPSearchServiceApp]SearchServiceApp') - } - xSPSecureStoreServiceApp SecureStoreServiceApp - { - Name = "Secure Store Service Application" - ApplicationPool = "SharePoint Service Applications" - AuditingEnabled = $true - AuditlogMaxSize = 30 - DatabaseName = "SP_SecureStore" - InstallAccount = $InstallAccount - DependsOn = "[xSPServiceAppPool]MainServiceAppPool" - } - xSPManagedMetaDataServiceApp ManagedMetadataServiceApp - { - Name = "Managed Metadata Service Application" - InstallAccount = $InstallAccount - ApplicationPool = "SharePoint Service Applications" - DatabaseServer = $DatabaseServer - DatabaseName = "SP_ManagedMetadata" - DependsOn = "[xSPServiceAppPool]MainServiceAppPool" - } - xSPSearchServiceApp SearchServiceApp - { - Name = "Search Service Application" - DatabaseName = "SP_Search" - ApplicationPool = "SharePoint Service Applications" - InstallAccount = $InstallAccount - DependsOn = "[xSPServiceAppPool]MainServiceAppPool" - } - xSPBCSServiceApp BCSServiceApp - { - Name = "BCS Service Application" - ApplicationPool = "SharePoint Service Applications" - DatabaseName = "SP_BCS" - DatabaseServer = $DatabaseServer - InstallAccount = $InstallAccount - DependsOn = @('[xSPServiceAppPool]MainServiceAppPool', '[xSPSecureStoreServiceApp]SecureStoreServiceApp') - } - - #********************************************************** - # Site Collections - # - # This section contains the site collections to provision - #********************************************************** - - xSPSite TeamSite - { - Url = "http://$TeamSiteUrl" - OwnerAlias = $InstallAccount.UserName - HostHeaderWebApplication = "http://$WebAppUrl" - Name = "Team Sites" - Template = "STS#0" - InstallAccount = $InstallAccount - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" - } - xSPSite MySiteHost - { - Url = "http://$MySiteHostUrl" - OwnerAlias = $InstallAccount.UserName - HostHeaderWebApplication = "http://$WebAppUrl" - Name = "My Site Host" - Template = "SPSMSITEHOST#0" - InstallAccount = $InstallAccount - DependsOn = "[xSPWebApplication]HostNameSiteCollectionWebApp" - } - - #********************************************************** - # Local configuration manager settings - # - # This section contains settings for the LCM of the host - # that this configuraiton is applied to - #********************************************************** - LocalConfigurationManager - { - RebootNodeIfNeeded = $true - } - } -} \ No newline at end of file diff --git a/Modules/xSharePoint/Examples/Small Farm/SharePoint.ps1 b/Modules/xSharePoint/Examples/Small Farm/SharePoint.ps1 new file mode 100644 index 000000000..82c20f0a1 --- /dev/null +++ b/Modules/xSharePoint/Examples/Small Farm/SharePoint.ps1 @@ -0,0 +1,466 @@ +Configuration SharePointServer +{ + param ( + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $FarmAccount, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $SPSetupAccount, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $WebPoolManagedAccount, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $ServicePoolManagedAccount, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $domainAdminCredential + ) + + Import-DscResource -ModuleName PSDesiredStateConfiguration + Import-DscResource -ModuleName xSharePoint + Import-DscResource -ModuleName xWebAdministration + Import-DscResource -ModuleName xCredSSP + + node $AllNodes.NodeName + { + #********************************************************** + # Server configuration + # + # This section of the configuration includes details of the + # server level configuration, such as disks, registry + # settings etc. + #********************************************************** + + xCredSSP CredSSPServer { Ensure = "Present"; Role = "Server"; DependsOn = "[xComputer]DomainJoin" } + xCredSSP CredSSPClient { Ensure = "Present"; Role = "Client"; DelegateComputers = "*.$($ConfigurationData.NonNodeData.DomainDetails.DomainName)"; DependsOn = "[xComputer]DomainJoin" } + + if ($Node.DisableIISLoopbackCheck -eq $true) { + Registry DisableLoopBackCheck { + Ensure = "Present" + Key = "HKLM:\System\CurrentControlSet\Control\Lsa" + ValueName = "DisableLoopbackCheck" + ValueData = "1" + ValueType = "Dword" + } + } + + + #********************************************************** + # IIS clean up + # + # This section removes all default sites and application + # pools from IIS as they are not required + #********************************************************** + + xWebAppPool RemoveDotNet2Pool { Name = ".NET v2.0"; Ensure = "Absent"; } + xWebAppPool RemoveDotNet2ClassicPool { Name = ".NET v2.0 Classic"; Ensure = "Absent"; } + xWebAppPool RemoveDotNet45Pool { Name = ".NET v4.5"; Ensure = "Absent"; } + xWebAppPool RemoveDotNet45ClassicPool { Name = ".NET v4.5 Classic"; Ensure = "Absent"; } + xWebAppPool RemoveClassicDotNetPool { Name = "Classic .NET AppPool"; Ensure = "Absent"; } + xWebAppPool RemoveDefaultAppPool { Name = "DefaultAppPool"; Ensure = "Absent"; } + xWebSite RemoveDefaultWebSite { Name = "Default Web Site"; Ensure = "Absent"; PhysicalPath = "C:\inetpub\wwwroot"; } + + + #********************************************************** + # Basic farm configuration + # + # This section creates the new SharePoint farm object, and + # provisions generic services and components used by the + # whole farm + #********************************************************** + + # Determine the first app server and let it create the farm, all other servers will join that afterwards + $FirstAppServer = ($AllNodes | Where-Object { $_.ServiceRoles.AppServer -eq $true } | Select-Object -First 1).NodeName + + if ($Node.NodeName -eq $FirstAppServer) { + xSPCreateFarm CreateSPFarm + { + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.FarmDatabaseServer + FarmConfigDatabaseName = $ConfigurationData.NonNodeData.SharePoint.Farm.ConfigurationDatabase + Passphrase = $ConfigurationData.NonNodeData.SharePoint.Farm.Passphrase + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SPSetupAccount + AdminContentDatabaseName = $ConfigurationData.NonNodeData.SharePoint.Farm.AdminContentDatabase + DependsOn = "[xComputer]DomainJoin" + } + + $FarmWaitTask = "[xSPCreateFarm]CreateSPFarm" + } else { + WaitForAll WaitForFarmToExist + { + ResourceName = "[xSPCreateFarm]CreateSPFarm" + NodeName = $FirstAppServer + RetryIntervalSec = 60 + RetryCount = 60 + PsDscRunAsCredential = $SPSetupAccount + } + xSPJoinFarm JoinSPFarm + { + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.FarmDatabaseServer + FarmConfigDatabaseName = $ConfigurationData.NonNodeData.SharePoint.Farm.ConfigurationDatabase + Passphrase = $ConfigurationData.NonNodeData.SharePoint.Farm.Passphrase + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[WaitForAll]WaitForFarmToExist" + } + + $FarmWaitTask = "[xSPJoinFarm]JoinSPFarm" + } + + + # Apply farm wide configuration and logical components only on the first server + if ($Node.NodeName -eq $FirstAppServer) { + xSPManagedAccount ServicePoolManagedAccount + { + AccountName = $ServicePoolManagedAccount.UserName + Account = $ServicePoolManagedAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + xSPManagedAccount WebPoolManagedAccount + { + AccountName = $WebPoolManagedAccount.UserName + Account = $WebPoolManagedAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + xSPDiagnosticLoggingSettings ApplyDiagnosticLogSettings + { + PsDscRunAsCredential = $SPSetupAccount + LogPath = $ConfigurationData.NonNodeData.SharePoint.DiagnosticLogs.Path + LogSpaceInGB = $ConfigurationData.NonNodeData.SharePoint.DiagnosticLogs.MaxSize + AppAnalyticsAutomaticUploadEnabled = $false + CustomerExperienceImprovementProgramEnabled = $true + DaysToKeepLogs = $ConfigurationData.NonNodeData.SharePoint.DiagnosticLogs.DaysToKeep + DownloadErrorReportingUpdatesEnabled = $false + ErrorReportingAutomaticUploadEnabled = $false + ErrorReportingEnabled = $false + EventLogFloodProtectionEnabled = $true + EventLogFloodProtectionNotifyInterval = 5 + EventLogFloodProtectionQuietPeriod = 2 + EventLogFloodProtectionThreshold = 5 + EventLogFloodProtectionTriggerPeriod = 2 + LogCutInterval = 15 + LogMaxDiskSpaceUsageEnabled = $true + ScriptErrorReportingDelay = 30 + ScriptErrorReportingEnabled = $true + ScriptErrorReportingRequireAuth = $true + DependsOn = @($FarmWaitTask, "[xDisk]LogsDisk") + } + xSPUsageApplication UsageApplication + { + Name = "Usage Service Application" + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.UsageLogs.DatabaseName + UsageLogCutTime = 5 + UsageLogLocation = $ConfigurationData.NonNodeData.SharePoint.UsageLogs.Path + UsageLogMaxFileSizeKB = 1024 + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + xSPStateServiceApp StateServiceApp + { + Name = "State Service Application" + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.StateService.DatabaseName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + } + + + #********************************************************** + # Distributed cache + # + # This section calculates which servers should be running + # DCache and which servers they depend on + #********************************************************** + + if ($Node.ServiceRoles.DistributedCache -eq $true) { + $AllDCacheNodes = $AllNodes | Where-Object { $_.ServiceRoles.DistributedCache -eq $true } + $CurrentDcacheNode = [Array]::IndexOf($AllDCacheNodes, $Node) + + if ($Node.NodeName -ne $FirstAppServer) { + # Node is not the first app server so won't have the dependency for the service account + WaitForAll WaitForServiceAccount + { + ResourceName = "[xSPManagedAccount]ServicePoolManagedAccount" + NodeName = $FirstAppServer + RetryIntervalSec = 60 + RetryCount = 20 + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + $DCacheWaitFor = "[WaitForAll]WaitForServiceAccount" + } else { + $DCacheWaitFor = "[xSPManagedAccount]ServicePoolManagedAccount" + } + + if ($CurrentDcacheNode -eq 0) { + # The first distributed cache node doesn't wait on anything + xSPDistributedCacheService EnableDistributedCache + { + Name = "AppFabricCachingService" + Ensure = "Present" + CacheSizeInMB = 1024 + ServiceAccount = $ServicePoolManagedAccount.UserName + PsDscRunAsCredential = $SPSetupAccount + CreateFirewallRules = $true + DependsOn = @($FarmWaitTask,$DCacheWaitFor) + } + } else { + # All other distributed cache nodes depend on the node previous to it + $previousDCacheNode = $AllDCacheNodes[$CurrentDcacheNode - 1] + WaitForAll WaitForDCache + { + ResourceName = "[xSPDistributedCacheService]EnableDistributedCache" + NodeName = $previousDCacheNode.NodeName + RetryIntervalSec = 60 + RetryCount = 60 + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + xSPDistributedCacheService EnableDistributedCache + { + Name = "AppFabricCachingService" + Ensure = "Present" + CacheSizeInMB = 1024 + ServiceAccount = $ServicePoolManagedAccount.UserName + PsDscRunAsCredential = $SPSetupAccount + CreateFirewallRules = $true + DependsOn = "[WaitForAll]WaitForDCache" + } + } + } + + + #********************************************************** + # Web applications + # + # This section creates the web applications in the + # SharePoint farm, as well as managed paths and other web + # application settings + #********************************************************** + + if ($Node.NodeName -eq $FirstAppServer) { + foreach($webApp in $ConfigurationData.NonNodeData.SharePoint.WebApplications) { + $webAppInternalName = $webApp.Name.Replace(" ", "") + xSPWebApplication $webAppInternalName + { + Name = $webApp.Name + ApplicationPool = $webApp.AppPool + ApplicationPoolAccount = $webApp.APpPoolAccount + AllowAnonymous = $webApp.Anonymous + AuthenticationMethod = $webApp.Authentication + DatabaseName = $webApp.DatabaseName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ContentDatabaseServer + Url = $webApp.Url + Port = [Uri]::new($webApp.Url).Port + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPManagedAccount]WebPoolManagedAccount" + } + + # If using host named site collections, create the empty path based site here + if ($webApp.UseHostNamedSiteCollections -eq $true) { + xSPSite HNSCRootSite + { + Url = $webApp.Url + OwnerAlias = $SPSetupAccount.Username + Name = "Root site" + Template = "STS#0" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } + + foreach($managedPath in $webApp.ManagedPaths) { + xSPManagedPath "$($webAppInternalName)Path$($managedPath.Path)" + { + WebAppUrl = $webApp.Url + PsDscRunAsCredential = $SPSetupAccount + RelativeUrl = $managedPath.Path + Explicit = $managedPath.Explicit + HostHeader = $webApp.UseHostNamedSiteCollections + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } + + xSPCacheAccounts "$($webAppInternalName)CacheAccounts" + { + WebAppUrl = $webApp.Url + SuperUserAlias = $webApp.SuperUser + SuperReaderAlias = $webApp.SuperReader + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + + foreach($siteCollection in $webApp.SiteCollections) { + $internalSiteName = "$($webAppInternalName)Site$($siteCollection.Name.Replace(' ', ''))" + if ($webApp.UseHostNamedSiteCollections -eq $true) { + xSPSite $internalSiteName + { + Url = $siteCollection.Url + OwnerAlias = $siteCollection.Owner + HostHeaderWebApplication = $webApp.Url + Name = $siteCollection.Name + Template = $siteCollection.Template + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } else { + xSPSite $internalSiteName + { + Url = $siteCollection.Url + OwnerAlias = $siteCollection.Owner + Name = $siteCollection.Name + Template = $siteCollection.Template + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPWebApplication]$webAppInternalName" + } + } + } + } + } + + #********************************************************** + # Service instances + # + # This section describes which services should be running + # and not running on the server + #********************************************************** + + xSPServiceInstance ClaimsToWindowsTokenServiceInstance + { + Name = "Claims to Windows Token Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + + # App server service instances + if ($Node.ServiceRoles.AppServer -eq $true) { + xSPServiceInstance UserProfileServiceInstance + { + Name = "User Profile Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + xSPServiceInstance SecureStoreServiceInstance + { + Name = "Secure Store Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + + if ($Node.NodeName -eq $FirstAppServer) { + xSPUserProfileSyncService UserProfileSyncService + { + UserProfileServiceAppName = "User Profile Service Application" + Ensure = "Present" + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPUserProfileServiceApp]UserProfileServiceApp" + } + } + } + + # Front end service instances + if ($Node.ServiceRoles.WebFrontEnd -eq $true) { + xSPServiceInstance ManagedMetadataServiceInstance + { + Name = "Managed Metadata Web Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + xSPServiceInstance BCSServiceInstance + { + Name = "Business Data Connectivity Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + } + + xSPServiceInstance SearchServiceInstance + { + Name = "SharePoint Server Search" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + + + #********************************************************** + # Service applications + # + # This section creates service applications and required + # dependencies + #********************************************************** + + if ($Node.NodeName -eq $FirstAppServer) { + $serviceAppPoolName = "SharePoint Service Applications" + xSPServiceAppPool MainServiceAppPool + { + Name = $serviceAppPoolName + ServiceAccount = $ServicePoolManagedAccount.UserName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = $FarmWaitTask + } + xSPUserProfileServiceApp UserProfileServiceApp + { + Name = "User Profile Service Application" + ApplicationPool = $serviceAppPoolName + MySiteHostLocation = $ConfigurationData.NonNodeData.SharePoint.UserProfileService.MySiteUrl + ProfileDBName = $ConfigurationData.NonNodeData.SharePoint.UserProfileService.ProfileDB + ProfileDBServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + SocialDBName = $ConfigurationData.NonNodeData.SharePoint.UserProfileService.SocialDB + SocialDBServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + SyncDBName = $ConfigurationData.NonNodeData.SharePoint.UserProfileService.SyncDB + SyncDBServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = @('[xSPServiceAppPool]MainServiceAppPool', '[xSPManagedMetaDataServiceApp]ManagedMetadataServiceApp', '[xSPSearchServiceApp]SearchServiceApp') + } + xSPSecureStoreServiceApp SecureStoreServiceApp + { + Name = "Secure Store Service Application" + ApplicationPool = $serviceAppPoolName + AuditingEnabled = $true + AuditlogMaxSize = 30 + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.SecureStoreService.DatabaseName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPServiceAppPool]MainServiceAppPool" + } + xSPManagedMetaDataServiceApp ManagedMetadataServiceApp + { + Name = "Managed Metadata Service Application" + PsDscRunAsCredential = $SPSetupAccount + ApplicationPool = $serviceAppPoolName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.ManagedMetadataService.DatabaseName + DependsOn = "[xSPServiceAppPool]MainServiceAppPool" + } + xSPBCSServiceApp BCSServiceApp + { + Name = "BCS Service Application" + ApplicationPool = $serviceAppPoolName + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.BCSService.DatabaseName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + PsDscRunAsCredential = $SPSetupAccount + DependsOn = @('[xSPServiceAppPool]MainServiceAppPool', '[xSPSecureStoreServiceApp]SecureStoreServiceApp') + } + xSPSearchServiceApp SearchServiceApp + { + Name = "Search Service Application" + DatabaseName = $ConfigurationData.NonNodeData.SharePoint.Search.DatabaseName + DatabaseServer = $ConfigurationData.NonNodeData.SQLServer.ServiceAppDatabaseServer + ApplicationPool = $serviceAppPoolName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPServiceAppPool]MainServiceAppPool" + } + } + + #********************************************************** + # Local configuration manager settings + # + # This section contains settings for the LCM of the host + # that this configuraiton is applied to + #********************************************************** + LocalConfigurationManager + { + RebootNodeIfNeeded = $true + } + } +} \ No newline at end of file diff --git a/Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 b/Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 new file mode 100644 index 000000000..066e2959b --- /dev/null +++ b/Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 @@ -0,0 +1,127 @@ +@{ + AllNodes = @( + @{ + NodeName = "*" + DisableIISLoopbackCheck = $true + }, + @{ + NodeName = "sharepoint1" + ServiceRoles = @{ + WebFrontEnd = $false + DistributedCache = $false + AppServer = $true + } + }, + @{ + NodeName = "sharepoint2" + ServiceRoles = @{ + WebFrontEnd = $false + DistributedCache = $false + AppServer = $true + } + }, + @{ + NodeName = "sharepoint3" + ServiceRoles = @{ + WebFrontEnd = $true + DistributedCache = $true + AppServer = $false + } + }, + @{ + NodeName = "sharepoint4" + ServiceRoles = @{ + WebFrontEnd = $true + DistributedCache = $true + AppServer = $false + } + } + ) + NonNodeData = @{ + DomainDetails = @{ + DomainName = "contoso.local" + NetbiosName = "CONTOSO" + } + SQLServer = @{ + ContentDatabaseServer = "sql1.contoso.local" + SearchDatabaseServer = "sql1.contoso.local" + ServiceAppDatabaseServer = "sql1.contoso.local" + FarmDatabaseServer = "sql1.contoso.local" + } + SharePoint = @{ + Farm = @{ + ConfigurationDatabase = "SP_Config" + Passphrase = "SharePoint156!" + AdminContentDatabase = "SP_AdminContent" + } + DiagnosticLogs = @{ + Path = "L:\ULSLogs" + MaxSize = 10 + DaysToKeep = 7 + } + UsageLogs = @{ + DatabaseName = "SP_Usage" + Path = "L:\UsageLogs" + } + StateService = @{ + DatabaseName = "SP_State" + } + WebApplications = @( + @{ + Name = "SharePoint Sites" + DatabaeName = "SP_Content_01" + Url = "http://sites.sharepoint.contoso.local" + Authentication = "NTLM" + Anonymous = $false + AppPool = "SharePoint Sites" + AppPoolAccount = "CONTOSO\svcSPWebApp" + SuperUser = "CONTOSO\svcSPSuperUser" + SuperReader = "CONTOSO\svcSPReader" + UseHostNamedSiteCollections = $true + ManagedPaths = @( + @{ + Path = "teams" + Explicit = $false + }, + @{ + Path = "personal" + Explicit = $false + } + ) + SiteCollections = @( + @{ + Url = "http://teams.sharepoint.contoso.local" + Owner = "CONTOSO\svcSPFarm" + Name = "Team Sites" + Template = "STS#0" + }, + @{ + Url = "http://my.sharepoint.contoso.local" + Owner = "CONTOSO\svcSPFarm" + Name = "My Sites" + Template = "SPSMSITEHOST#0" + } + ) + } + ) + UserProfileService = @{ + MySiteUrl = "http://my.sharepoint.contoso.local" + ProfileDB = "SP_UserProfiles" + SocialDB = "SP_Social" + SyncDB = "SP_ProfileSync" + } + SecureStoreService = @{ + DatabaseName = "SP_SecureStore" + } + ManagedMetadataService = @{ + DatabaseName = "SP_ManagedMetadata" + } + BCSService = @{ + DatabaseName = "SP_BCS" + } + Search = @{ + DatabaseName = "SP_Search" + } + } + } +} \ No newline at end of file diff --git a/Modules/xSharePoint/Examples/Small Farm/WFEServer.ps1 b/Modules/xSharePoint/Examples/Small Farm/WFEServer.ps1 deleted file mode 100644 index 7461de9ea..000000000 --- a/Modules/xSharePoint/Examples/Small Farm/WFEServer.ps1 +++ /dev/null @@ -1,189 +0,0 @@ -Configuration SharePointWFEServer -{ - param ( - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $CredSSPDelegates, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $SPBinaryPath, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $ULSViewerPath, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $SPBinaryPathCredential, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $FarmAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $InstallAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $ProductKey, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $DatabaseServer, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $FarmPassPhrase, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $WebPoolManagedAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $ServicePoolManagedAccount, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $WebAppUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $MySiteHostUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [string] $TeamSiteUrl, - [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [int] $CacheSizeInMB - ) - Import-DscResource -ModuleName xSharePoint - Import-DscResource -ModuleName xWebAdministration - Import-DscResource -ModuleName xCredSSP - Import-DscResource -ModuleName xDisk - - node "localhost" - { - #********************************************************** - # Server configuration - # - # This section of the configuration includes details of the - # server level configuration, such as disks, registry - # settings etc. - #********************************************************** - - xDisk LogsDisk { DiskNumber = 2; DriveLetter = "l" } - xDisk IndexDisk { DiskNumber = 3; DriveLetter = "i" } - xCredSSP CredSSPServer { Ensure = "Present"; Role = "Server" } - xCredSSP CredSSPClient { Ensure = "Present"; Role = "Client"; DelegateComputers = $CredSSPDelegates } - - - #********************************************************** - # Software downloads - # - # This section details where any binary downloads should - # be downloaded from and put locally on the server before - # installation takes place - #********************************************************** - - File SPBinaryDownload - { - DestinationPath = "C:\SPInstall" - Credential = $SPBinaryPathCredential - Ensure = "Present" - SourcePath = $SPBinaryPath - Type = "Directory" - Recurse = $true - } - File UlsViewerDownload - { - DestinationPath = "L:\UlsViewer.exe" - Credential = $SPBinaryPathCredential - Ensure = "Present" - SourcePath = $ULSViewerPath - Type = "File" - DependsOn = "[xDisk]LogsDisk" - } - - #********************************************************** - # Binary installation - # - # This section triggers installation of both SharePoint - # as well as the prerequisites required - #********************************************************** - xSPInstallPrereqs InstallPrerequisites - { - InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" - OnlineMode = $true - SQLNCli = "C:\SPInstall\prerequisiteinstallerfiles\sqlncli.msi" - PowerShell = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB2506143-x64.msu" - NETFX = "C:\SPInstall\prerequisiteinstallerfiles\dotNetFx45_Full_setup.exe" - IDFX = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB974405-x64.msu" - Sync = "C:\SPInstall\prerequisiteinstallerfiles\Synchronization.msi" - AppFabric = "C:\SPInstall\prerequisiteinstallerfiles\WindowsServerAppFabricSetup_x64.exe" - IDFX11 = "C:\SPInstall\prerequisiteinstallerfiles\MicrosoftIdentityExtensions-64.msi" - MSIPCClient = "C:\SPInstall\prerequisiteinstallerfiles\setup_msipc_x64.msi" - WCFDataServices = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices.exe" - KB2671763 = "C:\SPInstall\prerequisiteinstallerfiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe" - WCFDataServices56 = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices56.exe" - DependsOn = "[xSPClearRemoteSessions]ClearRemotePowerShellSessions" - } - xSPInstall InstallBinaries - { - BinaryDir = "C:\SPInstall" - ProductKey = $ProductKey - Ensure = "Present" - DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" - } - - #********************************************************** - # IIS clean up - # - # This section removes all default sites and application - # pools from IIS as they are not required - #********************************************************** - - xWebAppPool RemoveDotNet2Pool { Name = ".NET v2.0"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDotNet2ClassicPool { Name = ".NET v2.0 Classic"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDotNet45Pool { Name = ".NET v4.5"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites"; } - xWebAppPool RemoveDotNet45ClassicPool { Name = ".NET v4.5 Classic"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites"; } - xWebAppPool RemoveClassicDotNetPool { Name = "Classic .NET AppPool"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebAppPool RemoveDefaultAppPool { Name = "DefaultAppPool"; Ensure = "Absent"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - xWebSite RemoveDefaultWebSite { Name = "Default Web Site"; Ensure = "Absent"; PhysicalPath = "C:\inetpub\wwwroot"; DependsOn = "[xSPInstallPrereqs]InstallPrerequisites" } - - - #********************************************************** - # Basic farm configuration - # - # This section creates the new SharePoint farm object, and - # provisions generic services and components used by the - # whole farm - #********************************************************** - - xSPJoinFarm JoinSPFarm - { - DatabaseServer = $DatabaseServer - FarmConfigDatabaseName = "SP_Config" - Passphrase = $FarmPassPhrase - InstallAccount = $InstallAccount - DependsOn = "[xSPInstall]InstallBinaries" - } - xSPDistributedCacheService EnableDistributedCache - { - Name = "AppFabricCachingService" - Ensure = "Present" - CacheSizeInMB = $CacheSizeInMB - ServiceAccount = $ServicePoolManagedAccount.UserName - InstallAccount = $InstallAccount - CreateFirewallRules = $true - DependsOn = "[xSPJoinFarm]JoinSPFarm" - } - - #********************************************************** - # Service instances - # - # This section describes which services should be running - # and not running on the server - #********************************************************** - - xSPServiceInstance ClaimsToWindowsTokenServiceInstance - { - Name = "Claims to Windows Token Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPJoinFarm]JoinSPFarm" - } - xSPServiceInstance SecureStoreServiceInstance - { - Name = "Secure Store Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPJoinFarm]JoinSPFarm" - } - xSPServiceInstance ManagedMetadataServiceInstance - { - Name = "Managed Metadata Web Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPJoinFarm]JoinSPFarm" - } - xSPServiceInstance BCSServiceInstance - { - Name = "Business Data Connectivity Service" - Ensure = "Present" - InstallAccount = $InstallAccount - DependsOn = "[xSPJoinFarm]JoinSPFarm" - } - - #********************************************************** - # Local configuration manager settings - # - # This section contains settings for the LCM of the host - # that this configuraiton is applied to - #********************************************************** - LocalConfigurationManager - { - RebootNodeIfNeeded = $true - } - } -} \ No newline at end of file From 7493e45c664f52b716069a9ca5fd13f3f5ca060b Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 13:06:48 +1100 Subject: [PATCH 060/147] Fixed documentation generation --- Modules/xSharePoint/xSharePoint.pssproj | 5 ++-- Tests/Generate-xSharePointHelpFiles.ps1 | 39 +++++++++++++------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index ed34fb6b5..c823340a9 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -124,14 +124,13 @@ + + - - - diff --git a/Tests/Generate-xSharePointHelpFiles.ps1 b/Tests/Generate-xSharePointHelpFiles.ps1 index 6f30679e6..4ee5a6b31 100644 --- a/Tests/Generate-xSharePointHelpFiles.ps1 +++ b/Tests/Generate-xSharePointHelpFiles.ps1 @@ -8,28 +8,31 @@ Import-Module (Join-Path $PSScriptRoot "xSharePoint\xSharePoint.TestHelpers.psm1 $repoDir = Join-Path $PSScriptRoot "..\" -Resolve Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` - ForEach-Object { - $result = (Get-MofSchemaObject $_.FullName) | Where-Object { $_.ClassName -eq $_.Name.Replace(".schema.mof", "") } - Write-Output "Generating help document for $($result.FriendlyName)" + ForEach-Object { + $mofFileObject = $_ + $result = (Get-MofSchemaObject $_.FullName) | Where-Object { $_.ClassName -eq $mofFileObject.Name.Replace(".schema.mof", "") -and $result.FriendlyName -ne $null } + if ($result -ne $null) { + Write-Output "Generating help document for $($result.FriendlyName)" - $output = "NAME" + [Environment]::NewLine - $output += " $($result.FriendlyName)" + [Environment]::NewLine + [Environment]::NewLine - $output += "PARAMETERS" + [Environment]::NewLine + $output = "NAME" + [Environment]::NewLine + $output += " $($result.FriendlyName)" + [Environment]::NewLine + [Environment]::NewLine + $output += "PARAMETERS" + [Environment]::NewLine - foreach($property in $result.Attributes) { - $output += " $($property.Name) ($($property.State), $($property.DataType)" - if ([string]::IsNullOrEmpty($property.ValueMap) -ne $true) { - $output += ", Allowed values: " - $property.ValueMap | ForEach-Object { - $output += $_ + ", " + foreach($property in $result.Attributes) { + $output += " $($property.Name) ($($property.State), $($property.DataType)" + if ([string]::IsNullOrEmpty($property.ValueMap) -ne $true) { + $output += ", Allowed values: " + $property.ValueMap | ForEach-Object { + $output += $_ + ", " + } + $output = $output.TrimEnd(" ") + $output = $output.TrimEnd(",") } - $output = $output.TrimEnd(" ") - $output = $output.TrimEnd(",") + $output += ")" + [Environment]::NewLine } - $output += ")" + [Environment]::NewLine - } - $output += [Environment]::NewLine + $result.Documentation.Replace("**Description**", "DESCRIPTION").Replace("**Example**","EXAMPLE") + $output += [Environment]::NewLine + $result.Documentation.Replace("**Description**", "DESCRIPTION").Replace("**Example**","EXAMPLE") - $output | Out-File -FilePath (Join-Path $OutPutPath "about_$($result.FriendlyName).help.txt") -Encoding utf8 -Force + $output | Out-File -FilePath (Join-Path $OutPutPath "about_$($result.FriendlyName).help.txt") -Encoding utf8 -Force + } } \ No newline at end of file From 6efeab6fde097d58dc55b8c5ab265e73899a0357 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 13:10:00 +1100 Subject: [PATCH 061/147] Fixed incorrect variable name --- Tests/Generate-xSharePointHelpFiles.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Generate-xSharePointHelpFiles.ps1 b/Tests/Generate-xSharePointHelpFiles.ps1 index 4ee5a6b31..a767f237f 100644 --- a/Tests/Generate-xSharePointHelpFiles.ps1 +++ b/Tests/Generate-xSharePointHelpFiles.ps1 @@ -10,7 +10,7 @@ $repoDir = Join-Path $PSScriptRoot "..\" -Resolve Get-ChildItem "$repoDir\modules\xSharePoint\**\*.schema.mof" -Recurse | ` ForEach-Object { $mofFileObject = $_ - $result = (Get-MofSchemaObject $_.FullName) | Where-Object { $_.ClassName -eq $mofFileObject.Name.Replace(".schema.mof", "") -and $result.FriendlyName -ne $null } + $result = (Get-MofSchemaObject $_.FullName) | Where-Object { $_.ClassName -eq $mofFileObject.Name.Replace(".schema.mof", "") -and $_.FriendlyName -ne $null } if ($result -ne $null) { Write-Output "Generating help document for $($result.FriendlyName)" From b6253497c6f86ce7400703d6094810e159ed6b9a Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 13:51:23 +1100 Subject: [PATCH 062/147] merging changes for testing against dev branch updates --- .../MSFT_xSPAntivirusSettings.psm1 | 113 +++++++++ .../MSFT_xSPAntivirusSettings.schema.mof | 13 + .../MSFT_xSPFarmAdministrators.psm1 | 224 ++++++++++++++++++ .../MSFT_xSPFarmAdministrators.schema.mof | 11 + .../xSharePoint.Util/xSharePoint.Util.psm1 | 5 + 5 files changed, 366 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 new file mode 100644 index 000000000..2941a1de6 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 @@ -0,0 +1,113 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting antivirus configuration settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + + # Get a reference to the Administration WebService + $admService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService + + if ($null -eq $admService) { return $null } + + return @{ + # Set the antivirus settings + AllowDownloadInfected = $admService.AntivirusSettings.AllowDownload + ScanOnDownload = $admService.AntivirusSettings.DownloadScanEnabled + ScanOnUpload = $admService.AntivirusSettings.UploadScanEnabled + AttemptToClean = $admService.AntivirusSettings.CleaningEnabled + NumberOfThreads = $admService.AntivirusSettings.NumberOfThreads + TimeoutDuration = $admService.AntivirusSettings.Timeout.TotalSeconds + InstallAccount = $params.InstallAccount + } + } + + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting antivirus configuration settings" + + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + Write-Verbose -Message "Start update" + # Load the SharePoint Assembly, using old style for backward compatibility with V1 + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + + # Get a reference to the Administration WebService + $admService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService + + # Set the antivirus settings + if ($params.ContainsKey("AllowDownloadInfected")) { + Write-Verbose -Message "Setting Allow Download" + $admService.AntivirusSettings.AllowDownload = $params.AllowDownloadInfected + } + if ($params.ContainsKey("ScanOnDownload")) { $admService.AntivirusSettings.DownloadScanEnabled = $params.ScanOnDownload } + if ($params.ContainsKey("ScanOnUpload")) { $admService.AntivirusSettings.UploadScanEnabled = $params.ScanOnUpload } + if ($params.ContainsKey("AttemptToClean")) { $admService.AntivirusSettings.CleaningEnabled = $params.AttemptToClean } + if ($params.ContainsKey("NumberOfThreads")) { $admService.AntivirusSettings.NumberOfThreads = $params.NumberOfThreads } + if ($params.ContainsKey("TimeoutDuration")) { + $timespan = New-TimeSpan -Seconds $params.TimeoutDuration + $admService.AntivirusSettings.Timeout = $timespan + } + + $admService.Update() + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Testing antivirus configuration settings" + $CurrentValues = Get-TargetResource @PSBoundParameters + + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof new file mode 100644 index 000000000..03bfc3fb8 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof @@ -0,0 +1,13 @@ + +[ClassVersion("1.0.0.0"), FriendlyName("xSPAntivirusSettings")] +class MSFT_xSPAntivirusSettings : OMI_BaseResource +{ + [Key] Boolean ScanOnDownload; + [Write] Boolean ScanOnUpload; + [Write] Boolean AllowDownloadInfected; + [Write] Boolean AttemptToClean; + [Write] Uint16 TimeoutDuration; + [Write] Uint16 NumberOfThreads; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 new file mode 100644 index 000000000..77d0480a5 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 @@ -0,0 +1,224 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $false)] [System.String[]] $Members, + [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, + [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting all Farm Administrators" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} + $caWeb = Get-SPweb($caWebapp.Url) + $farmAdminGroup = $caWeb.AssociatedOwnerGroup + $farmAdministratorsGroup = $caWeb.SiteGroups[$farmAdminGroup] + return $farmAdministratorsGroup.users.UserLogin + } + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $false)] [System.String[]] $Members, + [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, + [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting Farm Administrator config" + + if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { + Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + + $CurrentValues = Get-TargetResource @PSBoundParameters + $changeUsers = @{} + $runChange = $false + + if ($Members) { + Write-Verbose "Processing Members parameter" + $differences = Compare-Object -ReferenceObject $CurrentValues -DifferenceObject $Members + if ($differences -eq $null) { + Write-Verbose "Farm Administrators group matches. No further processing required" + } else { + Write-Verbose "Farm Administrators group does not match. Perform corrective action" + $addUsers = @() + $removeUsers = @() + ForEach ($difference in $differences) { + if ($difference.SideIndicator -eq "=>") { + # Add account + $user = $difference.InputObject + Write-Verbose "Add $user to Add list" + $addUsers += $user + } elseif ($difference.SideIndicator -eq "<=") { + # Remove account + $user = $difference.InputObject + Write-Verbose "Add $user to Remove list" + $removeUsers += $user + } + } + + if($addUsers.count -gt 0) { + Write-Verbose "Adding $($addUsers.Count) users to the Farm Administrators group" + $changeUsers.Add = $addUsers + $runChange = $true + } + + if($removeUsers.count -gt 0) { + Write-Verbose "Removing $($removeUsers.Count) users from the Farm Administrators group" + $changeUsers.Remove = $removeUsers + $runChange = $true + } + } + } + + if ($MembersToInclude) { + Write-Verbose "Processing MembersToInclude parameter" + + $addUsers = @() + ForEach ($member in $MembersToInclude) { + if (-not($CurrentValues.Contains($member))) { + Write-Verbose "$member is not a Farm Administrator. Add user to Add list" + $addUsers += $member + } else { + Write-Verbose "$member is already a Farm Administrator. Skipping" + } + } + + if($addUsers.count -gt 0) { + Write-Verbose "Adding $($addUsers.Count) users to the Farm Administrators group" + $changeUsers.Add = $addUsers + $runChange = $true + } + } + + if ($MembersToExclude) { + Write-Verbose "Processing MembersToExclude parameter" + + $removeUsers = @() + ForEach ($member in $MembersToExclude) { + if ($CurrentValues.Contains($member)) { + Write-Verbose "$member is a Farm Administrator. Add user to Remove list" + $removeUsers += $member + } else { + Write-Verbose "$member is not a Farm Administrator. Skipping" + } + } + + if($removeUsers.count -gt 0) { + Write-Verbose "Removing $($removeUsers.Count) users from the Farm Administrators group" + $changeUsers.Remove = $removeUsers + $runChange = $true + } + } + + if ($runChange) { + Write-Verbose "Apply changes" + Change-SPFarmAdministrators $changeUsers + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $false)] [System.String[]] $Members, + [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, + [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Testing Farm Administrator settings" + + if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { + Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + + $CurrentValues = Get-TargetResource @PSBoundParameters + + if ($Members) { + Write-Verbose "Processing Members parameter" + $differences = Compare-Object -ReferenceObject $CurrentValues -DifferenceObject $Members + if ($differences -eq $null) { + Write-Verbose "Farm Administrators group matches" + return $true + } else { + Write-Verbose "Farm Administrators group does not match" + return $false + } + } + + $result = $true + if ($MembersToInclude) { + Write-Verbose "Processing MembersToInclude parameter" + ForEach ($member in $MembersToInclude) { + if (-not($CurrentValues.Contains($member))) { + Write-Verbose "$member is not a Farm Administrator. Set result to false" + $result = $false + } else { + Write-Verbose "$member is already a Farm Administrator. Skipping" + } + } + } + + if ($MembersToExclude) { + Write-Verbose "Processing MembersToExclude parameter" + ForEach ($member in $MembersToExclude) { + if ($CurrentValues.Contains($member)) { + Write-Verbose "$member is a Farm Administrator. Set result to false" + $result = $false + } else { + Write-Verbose "$member is not a Farm Administrator. Skipping" + } + } + } + + return $result +} + +function Change-SPFarmAdministrators { +Param ([Hashtable] $changeUsers) + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $changeUsers -ScriptBlock { + $changeUsers = $args[0] + + if ($changeUsers.ContainsKey("Add")) { + $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} + $caWeb = Get-SPweb($caWebapp.Url) + $farmAdminGroup = $caWeb.AssociatedOwnerGroup + + ForEach ($loginName in $changeUsers.Add) { + $caWeb.SiteGroups[$farmAdminGroup].AddUser($loginName,"","","") + } + } + + if ($changeUsers.ContainsKey("Remove")) { + $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} + $caWeb = Get-SPweb($caWebapp.Url) + $farmAdminGroup = $caWeb.AssociatedOwnerGroup + + ForEach ($loginName in $changeUsers.Remove) { + $removeUser = get-spuser $loginName -web $caWebapp.Url + $caWeb.SiteGroups[$farmAdminGroup].RemoveUser($removeUser) + } + } + } +} + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof new file mode 100644 index 000000000..8145a76d9 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof @@ -0,0 +1,11 @@ + +[ClassVersion("1.0.0.0"), FriendlyName("xSPFarmAdministrators")] +class MSFT_xSPFarmAdministrators : OMI_BaseResource +{ + [Key] String Name; + [Write] String Members[]; + [Write] String MembersToInclude[]; + [Write] String MembersToExclude[]; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; + diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 825be2900..ca1790e55 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -170,6 +170,11 @@ function Test-xSharePointSpecificParameters() { $returnValue = $false } } + "Int16" { + if (($DesiredValues.$fieldName -eq 0) -and ($CurrentValues.$fieldName -eq $null)) {} else { + $returnValue = $false + } + } default { $returnValue = $false } From 19ac838a3320f59b44a72cf746861828681f6fd9 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 14:02:50 +1100 Subject: [PATCH 063/147] Added update project file with new resources included --- Modules/xSharePoint/xSharePoint.pssproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index c823340a9..47c5802f9 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -50,11 +50,13 @@ + + @@ -79,6 +81,8 @@ + + @@ -89,6 +93,8 @@ + + From 0eafa5c6116ae2fd661d37cf26d6880b0a40792a Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 15:15:51 +1100 Subject: [PATCH 064/147] Unit test for antivirus settings --- .../MSFT_xSPAntivirusSettings.psm1 | 30 +++-- ...xSharePoint.xSPAntivirusSettings.Tests.ps1 | 112 ++++++++++++++++++ 2 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 Tests/xSharePoint/xSharePoint.xSPAntivirusSettings.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 index 2941a1de6..ba0d58cbb 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 @@ -1,3 +1,9 @@ +function Get-ContentService +{ + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + return [Microsoft.SharePoint.Administration.SPWebService]::ContentService +} + function Get-TargetResource { [CmdletBinding()] @@ -18,12 +24,15 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + try { + $spFarm = Get-SPFarm + } catch { + Write-Verbose -Verbose "No local SharePoint farm was detected. Antivirus settings will not be applied" + return $null + } # Get a reference to the Administration WebService - $admService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService - - if ($null -eq $admService) { return $null } + $admService = Get-ContentService return @{ # Set the antivirus settings @@ -59,13 +68,16 @@ function Set-TargetResource Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] + + try { + $spFarm = Get-SPFarm + } catch { + throw "No local SharePoint farm was detected. Antivirus settings will not be applied" + return + } Write-Verbose -Message "Start update" - # Load the SharePoint Assembly, using old style for backward compatibility with V1 - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - - # Get a reference to the Administration WebService - $admService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService + $admService = Get-ContentService # Set the antivirus settings if ($params.ContainsKey("AllowDownloadInfected")) { diff --git a/Tests/xSharePoint/xSharePoint.xSPAntivirusSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPAntivirusSettings.Tests.ps1 new file mode 100644 index 000000000..54c7598da --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPAntivirusSettings.Tests.ps1 @@ -0,0 +1,112 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPAntivirusSettings" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPAntivirusSettings" { + InModuleScope $ModuleName { + $testParams = @{ + ScanOnDownload = $true + ScanOnUpload = $true + AllowDownloadInfected = $true + AttemptToClean = $true + TimeoutDuration = 60 + NumberOfThreads = 5 + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Context "The server is not part of SharePoint farm" { + Mock Get-SPFarm { throw "Unable to detect local farm" } + + It "return null from the get method" { + Get-TargetResource @testParams | Should Be $null + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "throws an exception in the set method to say there is no local farm" { + { Set-TargetResource @testParams } | Should throw "No local SharePoint farm was detected" + } + } + + Context "The server is in a farm and the incorrect settings have been applied" { + Mock Get-ContentService { + $returnVal = @{ + AntivirusSettings = @{ + AllowDownload = $false + DownloadScanEnabled = $false + UploadScanEnabled = $false + CleaningEnabled = $false + NumberOfThreads = 0 + Timeout = @{ + TotalSeconds = 0; + } + } + } + $returnVal = $returnVal | Add-Member ScriptMethod Update { $Global:xSharePointAntivirusUpdated = $true } -PassThru + return $returnVal + } + Mock Get-SPFarm { return @{} } + + It "return values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + $Global:xSharePointAntivirusUpdated = $false + It "updates the antivirus settings" { + Set-TargetResource @testParams + $Global:xSharePointAntivirusUpdated | Should Be $true + } + } + + Context "The server is in a farm and the correct settings have been applied" { + Mock Get-ContentService { + $returnVal = @{ + AntivirusSettings = @{ + AllowDownload = $true + DownloadScanEnabled = $true + UploadScanEnabled = $true + CleaningEnabled = $true + NumberOfThreads = 5 + Timeout = @{ + TotalSeconds = 60; + } + } + } + $returnVal = $returnVal | Add-Member ScriptMethod Update { $Global:xSharePointAntivirusUpdated = $true } -PassThru + return $returnVal + } + Mock Get-SPFarm { return @{} } + + It "return values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + } +} From a89ab2dd60298e960b633fb057fae5ffc3e21588 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 15:16:15 +1100 Subject: [PATCH 065/147] removed PSSCriptRoot reference that shouldn't be there --- Tests/xSharePoint/xSharePoint.xSPBCSServiceApp.Tests.ps1 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPBCSServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPBCSServiceApp.Tests.ps1 index 4f8a2023e..3237bc766 100644 --- a/Tests/xSharePoint/xSharePoint.xSPBCSServiceApp.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPBCSServiceApp.Tests.ps1 @@ -3,11 +3,6 @@ param( [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) -if (!$PSScriptRoot) # $PSScriptRoot is not defined in 2.0 -{ - $PSScriptRoot = [System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path) -} - $ErrorActionPreference = 'stop' Set-StrictMode -Version latest From c0cdccfd283a9d609415a2c9a605b078cb748e83 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 18:57:16 +1100 Subject: [PATCH 066/147] Added tests for xSPFarmAdministrators resource --- .../MSFT_xSPFarmAdministrators.psm1 | 66 +++- Tests/Tests.pssproj | 2 + ...SharePoint.xSPFarmAdministrators.Tests.ps1 | 298 ++++++++++++++++++ 3 files changed, 351 insertions(+), 15 deletions(-) create mode 100644 Tests/xSharePoint/xSharePoint.xSPFarmAdministrators.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 index 77d0480a5..899dbe750 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 @@ -11,14 +11,34 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) + if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { + Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + + if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { + throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + Write-Verbose -Message "Getting all Farm Administrators" $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} + if ($null -eq $caWebapp) { + Write-Verbose "Unable to locate central administration website" + return $null + } $caWeb = Get-SPweb($caWebapp.Url) $farmAdminGroup = $caWeb.AssociatedOwnerGroup $farmAdministratorsGroup = $caWeb.SiteGroups[$farmAdminGroup] - return $farmAdministratorsGroup.users.UserLogin + return @{ + Name = $params.Name + Members = $farmAdministratorsGroup.users.UserLogin + MembersToInclude = $params.MembersToInclude + MembersToExclude = $params.MembersToExclude + InstallAccount = $params.InstallAccount + } } return $result } @@ -42,13 +62,20 @@ function Set-TargetResource Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" } + if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { + throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + $CurrentValues = Get-TargetResource @PSBoundParameters + if ($null -eq $CurrentValues) { + throw "Unable to locate central administration website" + } $changeUsers = @{} $runChange = $false if ($Members) { Write-Verbose "Processing Members parameter" - $differences = Compare-Object -ReferenceObject $CurrentValues -DifferenceObject $Members + $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members if ($differences -eq $null) { Write-Verbose "Farm Administrators group matches. No further processing required" } else { @@ -88,7 +115,7 @@ function Set-TargetResource $addUsers = @() ForEach ($member in $MembersToInclude) { - if (-not($CurrentValues.Contains($member))) { + if (-not($CurrentValues.Members.Contains($member))) { Write-Verbose "$member is not a Farm Administrator. Add user to Add list" $addUsers += $member } else { @@ -108,7 +135,7 @@ function Set-TargetResource $removeUsers = @() ForEach ($member in $MembersToExclude) { - if ($CurrentValues.Contains($member)) { + if ($CurrentValues.Members.Contains($member)) { Write-Verbose "$member is a Farm Administrator. Add user to Remove list" $removeUsers += $member } else { @@ -143,6 +170,14 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) + if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { + Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + + if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { + throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + Write-Verbose -Message "Testing Farm Administrator settings" if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { @@ -150,10 +185,12 @@ function Test-TargetResource } $CurrentValues = Get-TargetResource @PSBoundParameters + + if ($null -eq $CurrentValues) { return $false } if ($Members) { Write-Verbose "Processing Members parameter" - $differences = Compare-Object -ReferenceObject $CurrentValues -DifferenceObject $Members + $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members if ($differences -eq $null) { Write-Verbose "Farm Administrators group matches" return $true @@ -167,7 +204,7 @@ function Test-TargetResource if ($MembersToInclude) { Write-Verbose "Processing MembersToInclude parameter" ForEach ($member in $MembersToInclude) { - if (-not($CurrentValues.Contains($member))) { + if (-not($CurrentValues.Members.Contains($member))) { Write-Verbose "$member is not a Farm Administrator. Set result to false" $result = $false } else { @@ -179,7 +216,7 @@ function Test-TargetResource if ($MembersToExclude) { Write-Verbose "Processing MembersToExclude parameter" ForEach ($member in $MembersToExclude) { - if ($CurrentValues.Contains($member)) { + if ($CurrentValues.Members.Contains($member)) { Write-Verbose "$member is a Farm Administrator. Set result to false" $result = $false } else { @@ -197,21 +234,20 @@ Param ([Hashtable] $changeUsers) $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $changeUsers -ScriptBlock { $changeUsers = $args[0] - if ($changeUsers.ContainsKey("Add")) { - $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} - $caWeb = Get-SPweb($caWebapp.Url) - $farmAdminGroup = $caWeb.AssociatedOwnerGroup + $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} + if ($null -eq $caWebapp) { + throw "Unable to locate central administration website" + } + $caWeb = Get-SPweb($caWebapp.Url) + $farmAdminGroup = $caWeb.AssociatedOwnerGroup + if ($changeUsers.ContainsKey("Add")) { ForEach ($loginName in $changeUsers.Add) { $caWeb.SiteGroups[$farmAdminGroup].AddUser($loginName,"","","") } } if ($changeUsers.ContainsKey("Remove")) { - $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} - $caWeb = Get-SPweb($caWebapp.Url) - $farmAdminGroup = $caWeb.AssociatedOwnerGroup - ForEach ($loginName in $changeUsers.Remove) { $removeUser = get-spuser $loginName -web $caWebapp.Url $caWeb.SiteGroups[$farmAdminGroup].RemoveUser($removeUser) diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index c41c07e08..f74ac4f7c 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -67,6 +67,8 @@ + + diff --git a/Tests/xSharePoint/xSharePoint.xSPFarmAdministrators.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPFarmAdministrators.Tests.ps1 new file mode 100644 index 000000000..a247cd1fb --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPFarmAdministrators.Tests.ps1 @@ -0,0 +1,298 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPFarmAdministrators" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPFarmAdministrators" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "Farm Administrators" + Members = @("Demo\User1", "Demo\User2") + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + + Context "No central admin site exists" { + Mock Get-SPwebapplication { return $null } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "Unable to locate central administration website" + } + } + + Context "Central admin exists and a fixed members list is used which matches" { + Mock Get-SPwebapplication { return @{ + IsAdministrationWebApplication = $true + }} + Mock Get-SPWeb { + $web = @{ + AssociatedOwnerGroup = "Farm Administrators" + SiteGroups = @{ + "Farm Administrators" = @{ + Users = @( + @{ UserLogin = "Demo\User1" }, + @{ UserLogin = "Demo\User2" } + ) + } + } + } + return $web + } + + It "should return values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "Central admin exists and a fixed members list is used which does not match" { + Mock Get-SPwebapplication { return @{ + IsAdministrationWebApplication = $true + }} + Mock Get-SPWeb { + $web = @{ + AssociatedOwnerGroup = "Farm Administrators" + SiteGroups = @{ + "Farm Administrators" = @{ + Users = @( + @{ UserLogin = "Demo\User1" } + ) + } + } + } + return $web + } + + It "should return values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + } + + Context "Central admin exists and a members to include is set where the members are in the group" { + $testParams = @{ + Name = "Farm Administrators" + MembersToInclude = @("Demo\User2") + } + Mock Get-SPwebapplication { return @{ + IsAdministrationWebApplication = $true + }} + Mock Get-SPWeb { + $web = @{ + AssociatedOwnerGroup = "Farm Administrators" + SiteGroups = @{ + "Farm Administrators" = @{ + Users = @( + @{ UserLogin = "Demo\User1" }, + @{ UserLogin = "Demo\User2" } + ) + } + } + } + return $web + } + + It "should return values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "Central admin exists and a members to include is set where the members are not in the group" { + $testParams = @{ + Name = "Farm Administrators" + MembersToInclude = @("Demo\User2") + } + Mock Get-SPwebapplication { return @{ + IsAdministrationWebApplication = $true + }} + Mock Get-SPWeb { + $web = @{ + AssociatedOwnerGroup = "Farm Administrators" + SiteGroups = @{ + "Farm Administrators" = @{ + Users = @( + @{ UserLogin = "Demo\User1" } + ) + } + } + } + return $web + } + + It "should return values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return true from the test method" { + Test-TargetResource @testParams | Should Be $false + } + } + + Context "Central admin exists and a members to exclude is set where the members are in the group" { + $testParams = @{ + Name = "Farm Administrators" + MembersToExclude = @("Demo\User1") + } + Mock Get-SPwebapplication { return @{ + IsAdministrationWebApplication = $true + }} + Mock Get-SPWeb { + $web = @{ + AssociatedOwnerGroup = "Farm Administrators" + SiteGroups = @{ + "Farm Administrators" = @{ + Users = @( + @{ UserLogin = "Demo\User1" }, + @{ UserLogin = "Demo\User2" } + ) + } + } + } + return $web + } + + It "should return values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + } + + Context "Central admin exists and a members to exclude is set where the members are not in the group" { + $testParams = @{ + Name = "Farm Administrators" + MembersToExclude = @("Demo\User1") + } + Mock Get-SPwebapplication { return @{ + IsAdministrationWebApplication = $true + }} + Mock Get-SPWeb { + $web = @{ + AssociatedOwnerGroup = "Farm Administrators" + SiteGroups = @{ + "Farm Administrators" = @{ + Users = @( + @{ UserLogin = "Demo\User2" } + ) + } + } + } + return $web + } + + It "should return values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "The resource is called with both an explicit members list as well as members to include/exclude" { + $testParams = @{ + Name = "Farm Administrators" + Members = @("Demo\User1") + MembersToExclude = @("Demo\User1") + } + Mock Get-SPwebapplication { return @{ + IsAdministrationWebApplication = $true + }} + Mock Get-SPWeb { + $web = @{ + AssociatedOwnerGroup = "Farm Administrators" + SiteGroups = @{ + "Farm Administrators" = @{ + Users = @( + @{ UserLogin = "Demo\User2" } + ) + } + } + } + return $web + } + + It "should throw in the get method" { + { Get-TargetResource @testParams } | Should throw + } + + It "should throw in the test method" { + { Test-TargetResource @testParams } | Should throw + } + + It "should throw in the set method" { + { Set-TargetResource @testParams } | Should throw + } + } + + Context "The resource is called without either the specific members list or the include/exclude lists" { + $testParams = @{ + Name = "Farm Administrators" + } + Mock Get-SPwebapplication { return @{ + IsAdministrationWebApplication = $true + }} + Mock Get-SPWeb { + $web = @{ + AssociatedOwnerGroup = "Farm Administrators" + SiteGroups = @{ + "Farm Administrators" = @{ + Users = @( + @{ UserLogin = "Demo\User2" } + ) + } + } + } + return $web + } + + It "should throw in the get method" { + { Get-TargetResource @testParams } | Should throw + } + + It "should throw in the test method" { + { Test-TargetResource @testParams } | Should throw + } + + It "should throw in the set method" { + { Set-TargetResource @testParams } | Should throw + } + } + } +} From f8e2c2e3c9427705d85cee7d1ad900ca1c80730c Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 20:42:50 +1100 Subject: [PATCH 067/147] Added tests for xSPFarmAdministrators --- .../MSFT_xSPFarmAdministrators.psm1 | 6 +- ...SharePoint.xSPFarmAdministrators.Tests.ps1 | 125 ++++++++++-------- 2 files changed, 76 insertions(+), 55 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 index 899dbe750..9a7bc71d9 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 @@ -31,7 +31,7 @@ function Get-TargetResource } $caWeb = Get-SPweb($caWebapp.Url) $farmAdminGroup = $caWeb.AssociatedOwnerGroup - $farmAdministratorsGroup = $caWeb.SiteGroups[$farmAdminGroup] + $farmAdministratorsGroup = $caWeb.SiteGroups.GetByName($farmAdminGroup) return @{ Name = $params.Name Members = $farmAdministratorsGroup.users.UserLogin @@ -243,14 +243,14 @@ Param ([Hashtable] $changeUsers) if ($changeUsers.ContainsKey("Add")) { ForEach ($loginName in $changeUsers.Add) { - $caWeb.SiteGroups[$farmAdminGroup].AddUser($loginName,"","","") + $caWeb.SiteGroups.GetByName($farmAdminGroup).AddUser($loginName,"","","") } } if ($changeUsers.ContainsKey("Remove")) { ForEach ($loginName in $changeUsers.Remove) { $removeUser = get-spuser $loginName -web $caWebapp.Url - $caWeb.SiteGroups[$farmAdminGroup].RemoveUser($removeUser) + $caWeb.SiteGroups.GetByName($farmAdminGroup).RemoveUser($removeUser) } } } diff --git a/Tests/xSharePoint/xSharePoint.xSPFarmAdministrators.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPFarmAdministrators.Tests.ps1 index a247cd1fb..b69e3d64c 100644 --- a/Tests/xSharePoint/xSharePoint.xSPFarmAdministrators.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPFarmAdministrators.Tests.ps1 @@ -47,18 +47,19 @@ Describe "xSPFarmAdministrators" { Context "Central admin exists and a fixed members list is used which matches" { Mock Get-SPwebapplication { return @{ IsAdministrationWebApplication = $true + Url = "http://admin.shareopoint.contoso.local" }} Mock Get-SPWeb { $web = @{ AssociatedOwnerGroup = "Farm Administrators" - SiteGroups = @{ - "Farm Administrators" = @{ + SiteGroups = New-Object Object | Add-Member ScriptMethod GetByName { + return @{ Users = @( @{ UserLogin = "Demo\User1" }, @{ UserLogin = "Demo\User2" } ) } - } + } -PassThru } return $web } @@ -75,20 +76,22 @@ Describe "xSPFarmAdministrators" { Context "Central admin exists and a fixed members list is used which does not match" { Mock Get-SPwebapplication { return @{ IsAdministrationWebApplication = $true + Url = "http://admin.shareopoint.contoso.local" }} Mock Get-SPWeb { - $web = @{ + return @{ AssociatedOwnerGroup = "Farm Administrators" - SiteGroups = @{ - "Farm Administrators" = @{ - Users = @( + SiteGroups = New-Object Object | Add-Member ScriptMethod GetByName { + return New-Object Object | Add-Member ScriptProperty Users { + return @( @{ UserLogin = "Demo\User1" } ) - } - } + } -PassThru | Add-Member ScriptMethod AddUser { } -PassThru ` + | Add-Member ScriptMethod RemoveUser { } -PassThru + } -PassThru } - return $web } + Mock Get-SPUser { return @{} } It "should return values from the get method" { Get-TargetResource @testParams | Should Not BeNullOrEmpty @@ -97,6 +100,10 @@ Describe "xSPFarmAdministrators" { It "should return false from the test method" { Test-TargetResource @testParams | Should Be $false } + + It "should update the members list" { + Set-TargetResource @testParams + } } Context "Central admin exists and a members to include is set where the members are in the group" { @@ -106,20 +113,21 @@ Describe "xSPFarmAdministrators" { } Mock Get-SPwebapplication { return @{ IsAdministrationWebApplication = $true + Url = "http://admin.shareopoint.contoso.local" }} Mock Get-SPWeb { - $web = @{ + return @{ AssociatedOwnerGroup = "Farm Administrators" - SiteGroups = @{ - "Farm Administrators" = @{ - Users = @( + SiteGroups = New-Object Object | Add-Member ScriptMethod GetByName { + return New-Object Object | Add-Member ScriptProperty Users { + return @( @{ UserLogin = "Demo\User1" }, @{ UserLogin = "Demo\User2" } ) - } - } + } -PassThru | Add-Member ScriptMethod AddUser { } -PassThru ` + | Add-Member ScriptMethod RemoveUser { } -PassThru + } -PassThru } - return $web } It "should return values from the get method" { @@ -138,19 +146,20 @@ Describe "xSPFarmAdministrators" { } Mock Get-SPwebapplication { return @{ IsAdministrationWebApplication = $true + Url = "http://admin.shareopoint.contoso.local" }} Mock Get-SPWeb { - $web = @{ + return @{ AssociatedOwnerGroup = "Farm Administrators" - SiteGroups = @{ - "Farm Administrators" = @{ - Users = @( + SiteGroups = New-Object Object | Add-Member ScriptMethod GetByName { + return New-Object Object | Add-Member ScriptProperty Users { + return @( @{ UserLogin = "Demo\User1" } ) - } - } + } -PassThru | Add-Member ScriptMethod AddUser { } -PassThru ` + | Add-Member ScriptMethod RemoveUser { } -PassThru + } -PassThru } - return $web } It "should return values from the get method" { @@ -160,6 +169,10 @@ Describe "xSPFarmAdministrators" { It "should return true from the test method" { Test-TargetResource @testParams | Should Be $false } + + It "should update the members list" { + Set-TargetResource @testParams + } } Context "Central admin exists and a members to exclude is set where the members are in the group" { @@ -169,20 +182,21 @@ Describe "xSPFarmAdministrators" { } Mock Get-SPwebapplication { return @{ IsAdministrationWebApplication = $true + Url = "http://admin.shareopoint.contoso.local" }} Mock Get-SPWeb { - $web = @{ + return @{ AssociatedOwnerGroup = "Farm Administrators" - SiteGroups = @{ - "Farm Administrators" = @{ - Users = @( + SiteGroups = New-Object Object | Add-Member ScriptMethod GetByName { + return New-Object Object | Add-Member ScriptProperty Users { + return @( @{ UserLogin = "Demo\User1" }, @{ UserLogin = "Demo\User2" } ) - } - } + } -PassThru | Add-Member ScriptMethod AddUser { } -PassThru ` + | Add-Member ScriptMethod RemoveUser { } -PassThru + } -PassThru } - return $web } It "should return values from the get method" { @@ -192,6 +206,10 @@ Describe "xSPFarmAdministrators" { It "should return false from the test method" { Test-TargetResource @testParams | Should Be $false } + + It "should update the members list" { + Set-TargetResource @testParams + } } Context "Central admin exists and a members to exclude is set where the members are not in the group" { @@ -201,19 +219,20 @@ Describe "xSPFarmAdministrators" { } Mock Get-SPwebapplication { return @{ IsAdministrationWebApplication = $true + Url = "http://admin.shareopoint.contoso.local" }} Mock Get-SPWeb { - $web = @{ + return @{ AssociatedOwnerGroup = "Farm Administrators" - SiteGroups = @{ - "Farm Administrators" = @{ - Users = @( + SiteGroups = New-Object Object | Add-Member ScriptMethod GetByName { + return New-Object Object | Add-Member ScriptProperty Users { + return @( @{ UserLogin = "Demo\User2" } ) - } - } + } -PassThru | Add-Member ScriptMethod AddUser { } -PassThru ` + | Add-Member ScriptMethod RemoveUser { } -PassThru + } -PassThru } - return $web } It "should return values from the get method" { @@ -233,19 +252,20 @@ Describe "xSPFarmAdministrators" { } Mock Get-SPwebapplication { return @{ IsAdministrationWebApplication = $true + Url = "http://admin.shareopoint.contoso.local" }} Mock Get-SPWeb { - $web = @{ + return @{ AssociatedOwnerGroup = "Farm Administrators" - SiteGroups = @{ - "Farm Administrators" = @{ - Users = @( + SiteGroups = New-Object Object | Add-Member ScriptMethod GetByName { + return New-Object Object | Add-Member ScriptProperty Users { + return @( @{ UserLogin = "Demo\User2" } ) - } - } + } -PassThru | Add-Member ScriptMethod AddUser { } -PassThru ` + | Add-Member ScriptMethod RemoveUser { } -PassThru + } -PassThru } - return $web } It "should throw in the get method" { @@ -267,19 +287,20 @@ Describe "xSPFarmAdministrators" { } Mock Get-SPwebapplication { return @{ IsAdministrationWebApplication = $true + Url = "http://admin.shareopoint.contoso.local" }} Mock Get-SPWeb { - $web = @{ + return @{ AssociatedOwnerGroup = "Farm Administrators" - SiteGroups = @{ - "Farm Administrators" = @{ - Users = @( + SiteGroups = New-Object Object | Add-Member ScriptMethod GetByName { + return New-Object Object | Add-Member ScriptProperty Users { + return @( @{ UserLogin = "Demo\User2" } ) - } - } + } -PassThru | Add-Member ScriptMethod AddUser { } -PassThru ` + | Add-Member ScriptMethod RemoveUser { } -PassThru + } -PassThru } - return $web } It "should throw in the get method" { From 3dabd3a364ce9f9543784fc9144a0300665e8ebd Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 21:03:58 +1100 Subject: [PATCH 068/147] Added MOF documentation for antivirus and farm admins --- .../MSFT_xSPAntivirusSettings.schema.mof | 16 ++++++++++++++++ .../MSFT_xSPFarmAdministrators.schema.mof | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof index 03bfc3fb8..9014fe291 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof @@ -1,4 +1,20 @@ +/* +**Description** +This resource is used to set the global antivirus settings for the local form. +These settings will be used to control the behavior of an external anti-virus scanning tool that is able to integrate with SharePoint. +Note that this will not scan documents for viruses on it's own, an external tool still needs to be installed on the servers that integrates with SharePoint. + +**Example** + + xSPAntivirusSettings AVSettings + { + ScanOnDownload = $true + ScanOnUpload = $true + AllowDownloadInfected = $false + AttemptToClean = $false + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPAntivirusSettings")] class MSFT_xSPAntivirusSettings : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof index 8145a76d9..a3209947b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof @@ -1,4 +1,19 @@ +/* +**Description** +This resource is used to manage the membership of the farm administrators group. +There are a number of approaches to how this can be implemented. +The "members" property will set a specific list of members for the group, making sure that every user/group in the list is in the group and all others that are members and who are not in this list will be removed. +The "MembersToInclude" and "MembersToExclude" properties will allow you to control a specific set of users to add or remove, without changing any other members that are in the group already that may not be specified here, allowing for some manual management outside of this configuration resource. + +**Example** + + xSPFarmAdministrators LocalFarmAdmins + { + Name = "Farm Administrators" + Members = @("CONTOSO\user1", "CONTOSO\user2") + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPFarmAdministrators")] class MSFT_xSPFarmAdministrators : OMI_BaseResource { From f50b915750f7a7d278f01b52dc264e8186b30c41 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 26 Nov 2015 23:11:58 +1100 Subject: [PATCH 069/147] Rearranged function placement --- .../MSFT_xSPAntivirusSettings.psm1 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 index ba0d58cbb..c69fc340b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 @@ -1,9 +1,3 @@ -function Get-ContentService -{ - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - return [Microsoft.SharePoint.Administration.SPWebService]::ContentService -} - function Get-TargetResource { [CmdletBinding()] @@ -121,5 +115,10 @@ function Test-TargetResource return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters } +function Get-ContentService +{ + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + return [Microsoft.SharePoint.Administration.SPWebService]::ContentService +} Export-ModuleMember -Function *-TargetResource From f9a2ad1b94e7feb033f8dde2e356b5f8742ab713 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Thu, 26 Nov 2015 15:07:21 +0200 Subject: [PATCH 070/147] fixing a small typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73190c936..7c6199a20 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Please leave comments, feature requests, and bug reports in the Q & A tab for th If you would like to modify xSharePoint module, please feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify this resource as long as they are used on the Windows Platform. -Pleaes refer to the [Contribution Guidelines](https://github.com/PowerShell/xSharePoint/wiki/Contributing%20to%20xSharePoint) for information about style guides, testing and patterns for contributing to DSC resources. +Please refer to the [Contribution Guidelines](https://github.com/PowerShell/xSharePoint/wiki/Contributing%20to%20xSharePoint) for information about style guides, testing and patterns for contributing to DSC resources. ## Installation From c4995de3c5e36c25cc8e122d6dc381933e22e701 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Thu, 26 Nov 2015 15:08:43 +0200 Subject: [PATCH 071/147] Adding a unit test for issue #100, and removing dependency between tests --- .../xSharePoint.xSPInstallPrereqs.Tests.ps1 | 68 ++++++++++++++++--- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 index e66f9f35c..31fd4f3c4 100644 --- a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 @@ -14,11 +14,7 @@ Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName Describe "xSPInstallPrereqs" { InModuleScope $ModuleName { - $testParams = @{ - InstallerPath = "C:\SPInstall" - OnlineMode = $true - Ensure = "Present" - } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") Mock Invoke-xSharePointCommand { @@ -37,6 +33,12 @@ Describe "xSPInstallPrereqs" { Mock Get-ChildItem { return $null } Context "Prerequisites are not installed but should be and are to be installed in online mode" { + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $true + Ensure = "Present" + } + Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $false}) } Mock Get-CimInstance { return @() } Mock Get-ChildItem { return @() } @@ -90,7 +92,13 @@ Describe "xSPInstallPrereqs" { } Context "Prerequisites are installed and should be" { - Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $true }) } + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $true + Ensure = "Present" + } + + Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $true }) } if ($majorBuildNumber -eq 15) { Mock Get-CimInstance { return @( @{ Name = "Microsoft CCR and DSS Runtime 2008 R3"} @@ -131,7 +139,11 @@ Describe "xSPInstallPrereqs" { } Context "Prerequisites are installed but should not be" { - $testParams.Ensure = "Absent" + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $true + Ensure = "Absent" + } It "throws an exception from the set method" { {Test-TargetResource @testParams} | Should Throw @@ -143,8 +155,12 @@ Describe "xSPInstallPrereqs" { } Context "Prerequisites are not installed but should be and are to be installed in offline mode" { - $testParams.OnlineMode = $false - $testParams.Ensure = "Present" + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $false + Ensure = "Present" + } + Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $false}) } Mock Get-CimInstance { return @() } Mock Get-ChildItem { return @() } @@ -165,9 +181,43 @@ Describe "xSPInstallPrereqs" { It "does not throw an exception where the required parameters are included" { Mock Start-Process { return @{ ExitCode = 0 } } + Mock Test-Path { return $true } {Set-TargetResource @testParams} | Should Not Throw } + } + + Context "Prerequisites are not installed but should be and are to be installed in offline mode, but invalid paths have been passed" { + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $false + Ensure = "Present" + } + + Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $false }) } + Mock Get-CimInstance { return @() } + Mock Get-ChildItem { return @() } + + It "throws an exception in the set method if required parameters are not set" { + {Set-TargetResource @testParams} | Should Throw + } + + if ($majorBuildNumber -eq 15) { + $requiredParams = @("SQLNCli","PowerShell","NETFX","IDFX","Sync","AppFabric","IDFX11","MSIPCClient","WCFDataServices","KB2671763","WCFDataServices56") + } + if ($majorBuildNumber -eq 16) { + $requiredParams = @("SQLNCli","Sync","AppFabric","IDFX11","MSIPCClient","WCFDataServices","KB2671763","WCFDataServices56","KB2898850","MSVCRT12") + } + $requiredParams | ForEach-Object { + $testParams.Add($_, "C:\fake\value.exe") + } + + It "does not throw an exception where the required parameters are included" { + Mock Start-Process { return @{ ExitCode = 0 } } + Mock Test-Path { return $false } + + {Set-TargetResource @testParams} | Should Throw + } } } } \ No newline at end of file From 6e07e852450feb8e65a10fd2f08d5c59ecd85002 Mon Sep 17 00:00:00 2001 From: Hilton Giesenow Date: Thu, 26 Nov 2015 15:12:40 +0200 Subject: [PATCH 072/147] fixing tabs -> spaces --- .../MSFT_xSPInstallPrereqs.psm1 | 2 +- .../xSharePoint.xSPInstallPrereqs.Tests.ps1 | 58 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 index 558116680..3d01b0159 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 @@ -126,7 +126,7 @@ function Set-TargetResource if (($PSBoundParameters.ContainsKey($_) -and [string]::IsNullOrEmpty($PSBoundParameters.$_)) -or (-not $PSBoundParameters.ContainsKey($_))) { throw "In offline mode for version $majorVersion parameter $_ is required" } - if ((Test-Path $PSBoundParameters.$_) -eq $false) { + if ((Test-Path $PSBoundParameters.$_) -eq $false) { throw "The $_ parameter has been passed but the file cannot be found at the path supplied: `"$($PSBoundParameters.$_)`"" } } diff --git a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 index 31fd4f3c4..c5182cac4 100644 --- a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 @@ -33,11 +33,11 @@ Describe "xSPInstallPrereqs" { Mock Get-ChildItem { return $null } Context "Prerequisites are not installed but should be and are to be installed in online mode" { - $testParams = @{ - InstallerPath = "C:\SPInstall" - OnlineMode = $true - Ensure = "Present" - } + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $true + Ensure = "Present" + } Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $false}) } Mock Get-CimInstance { return @() } @@ -92,13 +92,13 @@ Describe "xSPInstallPrereqs" { } Context "Prerequisites are installed and should be" { - $testParams = @{ - InstallerPath = "C:\SPInstall" - OnlineMode = $true - Ensure = "Present" - } - - Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $true }) } + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $true + Ensure = "Present" + } + + Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $true }) } if ($majorBuildNumber -eq 15) { Mock Get-CimInstance { return @( @{ Name = "Microsoft CCR and DSS Runtime 2008 R3"} @@ -139,11 +139,11 @@ Describe "xSPInstallPrereqs" { } Context "Prerequisites are installed but should not be" { - $testParams = @{ - InstallerPath = "C:\SPInstall" - OnlineMode = $true - Ensure = "Absent" - } + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $true + Ensure = "Absent" + } It "throws an exception from the set method" { {Test-TargetResource @testParams} | Should Throw @@ -155,11 +155,11 @@ Describe "xSPInstallPrereqs" { } Context "Prerequisites are not installed but should be and are to be installed in offline mode" { - $testParams = @{ - InstallerPath = "C:\SPInstall" - OnlineMode = $false - Ensure = "Present" - } + $testParams = @{ + InstallerPath = "C:\SPInstall" + OnlineMode = $false + Ensure = "Present" + } Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $false}) } Mock Get-CimInstance { return @() } @@ -181,18 +181,18 @@ Describe "xSPInstallPrereqs" { It "does not throw an exception where the required parameters are included" { Mock Start-Process { return @{ ExitCode = 0 } } - Mock Test-Path { return $true } + Mock Test-Path { return $true } {Set-TargetResource @testParams} | Should Not Throw } } - Context "Prerequisites are not installed but should be and are to be installed in offline mode, but invalid paths have been passed" { + Context "Prerequisites are not installed but should be and are to be installed in offline mode, but invalid paths have been passed" { $testParams = @{ - InstallerPath = "C:\SPInstall" - OnlineMode = $false - Ensure = "Present" - } + InstallerPath = "C:\SPInstall" + OnlineMode = $false + Ensure = "Present" + } Mock Get-WindowsFeature { @( @{ Name = "ExampleFeature"; Installed = $false }) } Mock Get-CimInstance { return @() } @@ -214,7 +214,7 @@ Describe "xSPInstallPrereqs" { It "does not throw an exception where the required parameters are included" { Mock Start-Process { return @{ ExitCode = 0 } } - Mock Test-Path { return $false } + Mock Test-Path { return $false } {Set-TargetResource @testParams} | Should Throw } From 0d38ce6b42fbce8c2e2417db7c74e80784b37409 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 27 Nov 2015 10:28:14 +1100 Subject: [PATCH 073/147] Fixed placement of function --- .../MSFT_xSPAntivirusSettings.psm1 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 index c69fc340b..c9145900f 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 @@ -17,6 +17,12 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] + + function Get-ContentService + { + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + return [Microsoft.SharePoint.Administration.SPWebService]::ContentService + } try { $spFarm = Get-SPFarm @@ -63,6 +69,12 @@ function Set-TargetResource Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] + function Get-ContentService + { + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + return [Microsoft.SharePoint.Administration.SPWebService]::ContentService + } + try { $spFarm = Get-SPFarm } catch { @@ -115,10 +127,4 @@ function Test-TargetResource return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters } -function Get-ContentService -{ - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - return [Microsoft.SharePoint.Administration.SPWebService]::ContentService -} - Export-ModuleMember -Function *-TargetResource From 5984775ce4f46b599147591dfe21ea0fae930982 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 27 Nov 2015 13:09:49 +1100 Subject: [PATCH 074/147] Fixed structure of functions to allow for propper testing --- .../MSFT_xSPAntivirusSettings.psm1 | 16 ++-------------- .../xSharePoint.Util/xSharePoint.Util.psm1 | 5 +++++ Modules/xSharePoint/xSharePoint.psd1 | 1 + .../xSharePoint.xSPAntivirusSettings.Tests.ps1 | 6 +++--- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 index c9145900f..2c9944e80 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 @@ -17,12 +17,6 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - - function Get-ContentService - { - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - return [Microsoft.SharePoint.Administration.SPWebService]::ContentService - } try { $spFarm = Get-SPFarm @@ -32,7 +26,7 @@ function Get-TargetResource } # Get a reference to the Administration WebService - $admService = Get-ContentService + $admService = Get-xSharePointContentService return @{ # Set the antivirus settings @@ -69,12 +63,6 @@ function Set-TargetResource Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - function Get-ContentService - { - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - return [Microsoft.SharePoint.Administration.SPWebService]::ContentService - } - try { $spFarm = Get-SPFarm } catch { @@ -83,7 +71,7 @@ function Set-TargetResource } Write-Verbose -Message "Start update" - $admService = Get-ContentService + $admService = Get-xSharePointContentService # Set the antivirus settings if ($params.ContainsKey("AllowDownloadInfected")) { diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index ca1790e55..29c153d39 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -27,6 +27,11 @@ function Get-xSharePointAssemblyVersion() { return (Get-Command $PathToAssembly).FileVersionInfo.FileMajorPart } +function Get-xSharePointContentService() { + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + return [Microsoft.SharePoint.Administration.SPWebService]::ContentService +} + function Get-xSharePointInstalledProductVersion() { $pathToSearch = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\*\ISAPI\Microsoft.SharePoint.dll" $fullPath = Get-Item $pathToSearch | Sort-Object { $_.Directory } -Descending | Select-Object -First 1 diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index 7d7cf4054..84504e4ed 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -71,6 +71,7 @@ FunctionsToExport = '*' # Cmdlets to export from this module CmdletsToExport = @("Invoke-xSharePointCommand", "Get-xSharePointInstalledProductVersion", + "Get-xSharePointContentService", "Rename-xSharePointParamValue", "Add-xSharePointUserToLocalAdmin", "Remove-xSharePointUserToLocalAdmin", diff --git a/Tests/xSharePoint/xSharePoint.xSPAntivirusSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPAntivirusSettings.Tests.ps1 index 54c7598da..ec71788e0 100644 --- a/Tests/xSharePoint/xSharePoint.xSPAntivirusSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPAntivirusSettings.Tests.ps1 @@ -27,7 +27,7 @@ Describe "xSPAntivirusSettings" { Mock Invoke-xSharePointCommand { return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope } - + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue Context "The server is not part of SharePoint farm" { @@ -47,7 +47,7 @@ Describe "xSPAntivirusSettings" { } Context "The server is in a farm and the incorrect settings have been applied" { - Mock Get-ContentService { + Mock Get-xSharePointContentService { $returnVal = @{ AntivirusSettings = @{ AllowDownload = $false @@ -81,7 +81,7 @@ Describe "xSPAntivirusSettings" { } Context "The server is in a farm and the correct settings have been applied" { - Mock Get-ContentService { + Mock Get-xSharePointContentService { $returnVal = @{ AntivirusSettings = @{ AllowDownload = $true From 8915d78f0fd0cf2d5879afb2d42fffb2d477277d Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Fri, 27 Nov 2015 09:50:38 +0100 Subject: [PATCH 075/147] Merged changes made by Brian and other commits from Master branch --- .../MSFT_xSPAntivirusSettings.psm1 | 23 ------ .../MSFT_xSPAntivirusSettings.schema.mof | 5 +- .../MSFT_xSPFarmAdministrators.psm1 | 77 ++----------------- .../MSFT_xSPFarmAdministrators.schema.mof | 5 +- 4 files changed, 8 insertions(+), 102 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 index a270a633a..2c9944e80 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.psm1 @@ -18,14 +18,6 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] -<<<<<<< HEAD - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - - # Get a reference to the Administration WebService - $admService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService - - if ($null -eq $admService) { return $null } -======= try { $spFarm = Get-SPFarm } catch { @@ -35,7 +27,6 @@ function Get-TargetResource # Get a reference to the Administration WebService $admService = Get-xSharePointContentService ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 return @{ # Set the antivirus settings @@ -71,15 +62,6 @@ function Set-TargetResource Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] -<<<<<<< HEAD - - Write-Verbose -Message "Start update" - # Load the SharePoint Assembly, using old style for backward compatibility with V1 - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - - # Get a reference to the Administration WebService - $admService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService -======= try { $spFarm = Get-SPFarm @@ -90,7 +72,6 @@ function Set-TargetResource Write-Verbose -Message "Start update" $admService = Get-xSharePointContentService ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 # Set the antivirus settings if ($params.ContainsKey("AllowDownloadInfected")) { @@ -134,8 +115,4 @@ function Test-TargetResource return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters } -<<<<<<< HEAD - -======= ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof index 79af41554..59389c869 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.schema.mof @@ -1,6 +1,3 @@ -<<<<<<< HEAD - -======= /* **Description** @@ -18,7 +15,7 @@ Note that this will not scan documents for viruses on it's own, an external tool AttemptToClean = $false } */ ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 + [ClassVersion("1.0.0.0"), FriendlyName("xSPAntivirusSettings")] class MSFT_xSPAntivirusSettings : OMI_BaseResource { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 index 89d4c7e26..d7a568742 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.psm1 @@ -11,16 +11,6 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) -<<<<<<< HEAD - Write-Verbose -Message "Getting all Farm Administrators" - - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} - $caWeb = Get-SPweb($caWebapp.Url) - $farmAdminGroup = $caWeb.AssociatedOwnerGroup - $farmAdministratorsGroup = $caWeb.SiteGroups[$farmAdminGroup] - return $farmAdministratorsGroup.users.UserLogin -======= if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" } @@ -49,7 +39,6 @@ function Get-TargetResource MembersToExclude = $params.MembersToExclude InstallAccount = $params.InstallAccount } ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 } return $result } @@ -73,9 +62,6 @@ function Set-TargetResource Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" } -<<<<<<< HEAD - $CurrentValues = Get-TargetResource @PSBoundParameters -======= if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" } @@ -84,17 +70,15 @@ function Set-TargetResource if ($null -eq $CurrentValues) { throw "Unable to locate central administration website" } ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 + $changeUsers = @{} $runChange = $false if ($Members) { Write-Verbose "Processing Members parameter" -<<<<<<< HEAD - $differences = Compare-Object -ReferenceObject $CurrentValues -DifferenceObject $Members -======= + $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 + if ($differences -eq $null) { Write-Verbose "Farm Administrators group matches. No further processing required" } else { @@ -134,11 +118,7 @@ function Set-TargetResource $addUsers = @() ForEach ($member in $MembersToInclude) { -<<<<<<< HEAD - if (-not($CurrentValues.Contains($member))) { -======= if (-not($CurrentValues.Members.Contains($member))) { ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 Write-Verbose "$member is not a Farm Administrator. Add user to Add list" $addUsers += $member } else { @@ -158,11 +138,7 @@ function Set-TargetResource $removeUsers = @() ForEach ($member in $MembersToExclude) { -<<<<<<< HEAD - if ($CurrentValues.Contains($member)) { -======= if ($CurrentValues.Members.Contains($member)) { ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 Write-Verbose "$member is a Farm Administrator. Add user to Remove list" $removeUsers += $member } else { @@ -197,8 +173,8 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) -<<<<<<< HEAD -======= + Write-Verbose -Message "Testing Farm Administrator settings" + if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" } @@ -207,27 +183,14 @@ function Test-TargetResource throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" } ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 - Write-Verbose -Message "Testing Farm Administrator settings" - - if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { - Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" - } - $CurrentValues = Get-TargetResource @PSBoundParameters -<<<<<<< HEAD - - if ($Members) { - Write-Verbose "Processing Members parameter" - $differences = Compare-Object -ReferenceObject $CurrentValues -DifferenceObject $Members -======= if ($null -eq $CurrentValues) { return $false } if ($Members) { Write-Verbose "Processing Members parameter" $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 + if ($differences -eq $null) { Write-Verbose "Farm Administrators group matches" return $true @@ -241,11 +204,7 @@ function Test-TargetResource if ($MembersToInclude) { Write-Verbose "Processing MembersToInclude parameter" ForEach ($member in $MembersToInclude) { -<<<<<<< HEAD - if (-not($CurrentValues.Contains($member))) { -======= if (-not($CurrentValues.Members.Contains($member))) { ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 Write-Verbose "$member is not a Farm Administrator. Set result to false" $result = $false } else { @@ -257,11 +216,7 @@ function Test-TargetResource if ($MembersToExclude) { Write-Verbose "Processing MembersToExclude parameter" ForEach ($member in $MembersToExclude) { -<<<<<<< HEAD - if ($CurrentValues.Contains($member)) { -======= if ($CurrentValues.Members.Contains($member)) { ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 Write-Verbose "$member is a Farm Administrator. Set result to false" $result = $false } else { @@ -279,15 +234,6 @@ Param ([Hashtable] $changeUsers) $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $changeUsers -ScriptBlock { $changeUsers = $args[0] -<<<<<<< HEAD - if ($changeUsers.ContainsKey("Add")) { - $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} - $caWeb = Get-SPweb($caWebapp.Url) - $farmAdminGroup = $caWeb.AssociatedOwnerGroup - - ForEach ($loginName in $changeUsers.Add) { - $caWeb.SiteGroups[$farmAdminGroup].AddUser($loginName,"","","") -======= $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} if ($null -eq $caWebapp) { throw "Unable to locate central administration website" @@ -298,24 +244,13 @@ Param ([Hashtable] $changeUsers) if ($changeUsers.ContainsKey("Add")) { ForEach ($loginName in $changeUsers.Add) { $caWeb.SiteGroups.GetByName($farmAdminGroup).AddUser($loginName,"","","") ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 } } if ($changeUsers.ContainsKey("Remove")) { -<<<<<<< HEAD - $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} - $caWeb = Get-SPweb($caWebapp.Url) - $farmAdminGroup = $caWeb.AssociatedOwnerGroup - - ForEach ($loginName in $changeUsers.Remove) { - $removeUser = get-spuser $loginName -web $caWebapp.Url - $caWeb.SiteGroups[$farmAdminGroup].RemoveUser($removeUser) -======= ForEach ($loginName in $changeUsers.Remove) { $removeUser = get-spuser $loginName -web $caWebapp.Url $caWeb.SiteGroups.GetByName($farmAdminGroup).RemoveUser($removeUser) ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 } } } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof index dd77018f0..2692d405c 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPFarmAdministrators/MSFT_xSPFarmAdministrators.schema.mof @@ -1,6 +1,3 @@ -<<<<<<< HEAD - -======= /* **Description** @@ -17,7 +14,7 @@ The "MembersToInclude" and "MembersToExclude" properties will allow you to contr Members = @("CONTOSO\user1", "CONTOSO\user2") } */ ->>>>>>> 5984775ce4f46b599147591dfe21ea0fae930982 + [ClassVersion("1.0.0.0"), FriendlyName("xSPFarmAdministrators")] class MSFT_xSPFarmAdministrators : OMI_BaseResource { From 92f18c650df7540c9685e30281f97d3c77ff22be Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 27 Nov 2015 22:44:42 +1100 Subject: [PATCH 076/147] Merging in to existing dev branch --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 87 ++++++++ .../MSFT_xSPOutgoingEmailSettings.schema.mof | 11 + .../MSFT_xSPPasswordChangeSettings.psm1 | 88 ++++++++ .../MSFT_xSPPasswordChangeSettings.schema.mof | 9 + .../MSFT_xSPWebApplication.Set.ps1 | 188 ++++++++++++++++ .../MSFT_xSPWebApplication.psm1 | 207 +++++++++++++++++- .../MSFT_xSPWebApplication.schema.mof | 70 +++++- Modules/xSharePoint/xSharePoint.psd1 | 1 + Modules/xSharePoint/xSharePoint.pssproj | 6 + Tests/Tests.pssproj | 2 + .../xSharePoint/xSharePoint.Global.Tests.ps1 | 2 +- .../xSharePoint/xSharePoint.TestHelpers.psm1 | 2 +- ...rePoint.xSPOutgoingEmailSettings.Tests.ps1 | 101 +++++++++ ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 102 +++++++++ .../xSharePoint.xSPWebApplication.Tests.ps1 | 159 ++++++++++++++ 15 files changed, 1026 insertions(+), 9 deletions(-) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 create mode 100644 Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 create mode 100644 Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 new file mode 100644 index 000000000..ec120c409 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -0,0 +1,87 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + + ) + + Write-Verbose -Message "Retrieving outgoing email settings configuration " + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration -ErrorAction SilentlyContinue + + if ($null -eq $webApp ) { + return $null + } + return @{ + WebAppUrl = $webApp.Url + SMTPServer= $webApp.OutboundMailServiceInstance + FromAddress= $webApp.OutboundMailSenderAddress + ReplyToAddress= $webApp.OutboundMailReplyToAddress + CharacterSet = $webApp.OutboundMailCodePage + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $webApp = $null + Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + if($null -eq $webApp) + { + throw "Web Application $webAppUrl not found" + } + $webApp.UpdateMailSettings($params.SMTPServer, $params.FromAddress, $params.ReplyToAddress, $params.CharacterSet) + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Comparing Current and Target Outgoing email settings" + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("WebAppUrl", "SMTPServer","FromAddress","ReplyToAddress","CharacterSet") +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof new file mode 100644 index 000000000..b6f92db87 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -0,0 +1,11 @@ +[ClassVersion("1.0.0.0"), FriendlyName("xSPOutgoingEmailSettings")] +class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource +{ + [key] string WebAppUrl; + [Write] string SMTPServer; + [Write] string FromAddress; + [Write] string ReplyToAddress; + [Write] string CharacterSet; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 new file mode 100644 index 000000000..ef256a103 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -0,0 +1,88 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Retrieving farm wide automatic password change settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $farm = Get-SPFarm + if ($null -eq $farm ) { return $null } + return @{ + MailAddress = $farm.PasswordChangeEmailAddress + PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime + NumberOfRetries= $farm.PasswordChangeMaximumTries + DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $false)][ValidateRange(0,356 )][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99 )][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Updating farm wide automatic password change settings" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $farm = Get-SPFarm -ErrorAction Continue + + if ($null -eq $farm ) { return $null } + + $farm.PasswordChangeEmailAddress=$params.MailAddress; + if($params.PasswordChangeWaitTimeSeconds -ne $null){ + $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds + } + if($params.NumberOfRetries -ne $null){ + $farm.PasswordChangeMaximumTries=$params.NumberOfRetries + } + if($params.DaysBeforeExpiry -ne $null){ + $farm.DaysBeforePasswordExpirationToSendEmail=$params.DaysBeforeExpiry + } + $farm.Update(); + + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing retrieving farm wide automatic password change settings" + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("MailAddress", "DaysBeforeExpiry","PasswordChangeWaitTimeSeconds","NumberOfRetries") +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof new file mode 100644 index 000000000..3ff4a1652 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -0,0 +1,9 @@ +[ClassVersion("1.0.0.0"), FriendlyName("xSPPasswordChangeSettings")] +class MSFT_xSPPasswordChangeSettings : OMI_BaseResource +{ + [key] string MailAddress; + [Write] Uint32 DaysBeforeExpiry; + [Write] Uint32 PasswordChangeWaitTimeSeconds; + [Write] Uint32 NumberOfRetries; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 new file mode 100644 index 000000000..c3af6e4d3 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 @@ -0,0 +1,188 @@ +function Set-BlockedFiles($blockedFiles, $wa) +{ + + if($blockedFiles -eq $null){return;} + if($blockedFiles.Blocked -ne $null ){ + $wa.BlockedFileExtensions.Clear(); + $blockedFiles.Blocked| % { + $wa.BlockedFileExtensions.Add($_) ; + + } + } + if($blockedFiles.EnsureBlocked -ne $null){ + $blockedFiles.EnsureBlocked| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } + } + } + if($blockedFiles.EnsureAllowed -ne $null){ + $blockedFiles.EnsureAllowed | % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } + } + } + +} +function Get-ValueOrDefault($input, $attribute, $defaultValue) +{ + try{ + if($input."$attribute" -ne $null) + { + return $input."$attribute" + }else { + return $defaultValue + } + }catch + { + return $defaultValue + } +} +function Set-GeneralSettings($generalSettings, $wa) +{ + if($generalSettings -eq $null){ return;} + + #TODO: Quota Template + $wa.DefaultTimeZone =Get-ValueOrDefault $generalSettings "TimeZone" $wa.DefaultTimeZone + $wa.AlertsEnabled = Get-ValueOrDefault $generalSettings "Alerts" $wa.AlertsEnabled + $wa.AlertsMaximum = Get-ValueOrDefault $generalSettings "AlertsLimit" $wa.AlertsMaximum + $wa.SyndicationEnabled = Get-ValueOrDefault $generalSettings "RSS" $wa.RSS + $wa.MetaWeblogEnabled = Get-ValueOrDefault $generalSettings "BlogAPI" $wa.BlogAPI + $wa.MetaWeblogAuthenticationEnabled = Get-ValueOrDefault $generalSettings "BlogAPIAuthenticated" $wa.BlogAPIAuthenticated + $wa.BrowserFileHandling = Get-ValueOrDefault $generalSettings "BrowserFileHandling" $wa.BrowserFileHandling + $wa.FormDigestSettings.Enabled = Get-ValueOrDefault $generalSettings "SecurityValidation" $wa.FormDigestSettings.Enabled + $wa.MaximumFileSize = Get-ValueOrDefault $generalSettings "MaximumUploadSize" $wa.MaximumUploadSize + $wa.RecycleBinEnabled = Get-ValueOrDefault $generalSettings "RecycleBinEnabled" $wa.RecycleBinEnabled + $wa.RecycleBinCleanupEnabled = Get-ValueOrDefault $generalSettings "RecycleBinCleanupEnabled" $wa.RecycleBinCleanupEnabled + $wa.RecycleBinRetentionPeriod = Get-ValueOrDefault $generalSettings "RecycleBinRetentionPeriod" $wa.RecycleBinRetentionPeriod + $wa.SecondStageRecycleBinQuota = Get-ValueOrDefault $generalSettings "SecondStageRecycleBinEnabled" $wa.SecondStageRecycleBinQuota + $wa.BrowserCEIPEnabled = Get-ValueOrDefault $generalSettings "CustomerExperienceProgram" $wa.BrowserCEIPEnabled + $wa.PresenceEnabled = Get-ValueOrDefault $generalSettings "Presence" $wa.BrowserCEIPEnabled + $wa.Update(); +} +function Set-WorkflowSettings ($workflowSettings, $wa) +{ + if($workflowSettings -eq $null ){ return;} + if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ + $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; + } + if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ + $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; + } + if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ + $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; + } + + $wa.UpdateWorkflowConfigurationSettings(); + $wa.Update(); +} + +function Set-ThrottlingSettings ($throttlingSettings, $wa) +{ + if($throttlingSettings -eq $null){ return;} + if($throttlingSettings.ListViewThreshold -ne $null ){ + $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold + } + if($throttlingSettings.AllowObjectModelOverride -ne $null){ + $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride + } + if($throttlingSettings.AdminThreshold -ne $null){ + $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold + } + if($throttlingSettings.ListViewLookupThreshold -ne $null){ + $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold + } + if($throttlingSettings.HappyHourEnabled -ne $null){ + $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled + } + if($throttlingSettings.HappyHour -ne $null){ + $happyHour =$throttlingSettings.HappyHour; + if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ + if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ + $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour + $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute + $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration + }else{ + throw "the valid range hour, minute and duration is 0-24"; + } + + }else { + throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; + } + } + if($throttlingSettings.UniquePermissionThreshold){ + $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold + } + if($throttlingSettings.EventHandlersEnabled){ + $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled + } + if($throttlingSettings.RequestThrottling){ + $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling + } + if($throttlingSettings.ChangeLogEnabled){ + $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled + } + if($throttlingSettings.ChangeLogExpiryDays){ + $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays + } + $wa.Update(); +} + +function GetAndRemove-Parameter($params, $name){ + $result =$null + if($params.ContainsKey($name)) + { + $result = $params.$name + $params.Remove( $name) + } + return $result; +} +function Sanitize-ComplexTypes{ + param( + [Parameter(Position = 0)] + + $params + ) + +$blocked =GetAndRemove-Parameter $params "BlockedFileTypes" + return @{ + GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" + WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" + Extensions = GetAndRemove-Parameter $params "Extensions" + ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" + BlockedFileTypes = $blocked + } +} + + +$params = $args[0] + +$settings = Sanitize-ComplexTypes $params + +$wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue +if ($null -eq $wa) { + if ($params.ContainsKey("AuthenticationMethod") -eq $true) { + if ($params.AuthenticationMethod -eq "NTLM") { + $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos + } else { + $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication + } + $params.Remove("AuthenticationMethod") + $params.Add("AuthenticationProvider", $ap) + } + + if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } + if ($params.ContainsKey("AllowAnonymous")) { + $params.Remove("AllowAnonymous") | Out-Null + $params.Add("AllowAnonymousAccess", $true) + } + + $wa = New-SPWebApplication @params +} + +Set-ThrottlingSettings $settings.ThrottlingSettings $wa +Set-WorkflowSettings $settings.WorkflowSettings $wa +Set-BlockedFiles $settings.BlockedFileTypes $wa +Set-GeneralSettings $settings.GeneralSettings $wa + \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 1b519c8a6..4edb6efd1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -1,3 +1,26 @@ +function GetAndRemove-Parameter($params, $name){ + $result =$null + if($params.ContainsKey($name)) + { + $result = $params.$name + $params.Remove( $name) + } + return $result; +} +function Sanitize-ComplexTypes{ + param( + [Parameter(Position = 0)] + $params + ) + return @{ + GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" + WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" + Extensions = GetAndRemove-Parameter $params "Extensions" + ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" + BlockedFileTypes = GetAndRemove-Parameter $params "BlockedFileTypes" + } +} + function Get-TargetResource { [CmdletBinding()] @@ -15,7 +38,11 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) Write-Verbose -Message "Getting web application '$Name'" @@ -66,15 +93,22 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) Write-Verbose -Message "Creating web application '$Name'" - + $settings = Sanitize-ComplexTypes $PSBoundParameters + $PSBoundParameters.Add("Settings", $settings) + Write-Verbose -Message "Creating web application '$Name'" $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - + $settings =$params.Settings + $params.Remove("Settings") | Out-Null $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { if ($params.ContainsKey("AuthenticationMethod") -eq $true) { @@ -92,9 +126,166 @@ function Set-TargetResource $params.Remove("AllowAnonymous") | Out-Null $params.Add("AllowAnonymousAccess", $true) } + + $wa = New-SPWebApplication @params + } +#region throttling settings + + $throttlingSettings = $settings.ThrottlingSettings - New-SPWebApplication @params + if($throttlingSettings -ne $null){ + if($throttlingSettings.ListViewThreshold -ne $null ){ + $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold + } + if($throttlingSettings.AllowObjectModelOverride -ne $null){ + $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride + } + if($throttlingSettings.AdminThreshold -ne $null){ + $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold + } + if($throttlingSettings.ListViewLookupThreshold -ne $null){ + $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold + } + if($throttlingSettings.HappyHourEnabled -ne $null){ + $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled + } + if($throttlingSettings.HappyHour -ne $null){ + $happyHour =$throttlingSettings.HappyHour; + if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ + if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ + $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour + $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute + $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration + }else{ + throw "the valid hour, minute and duration range is 0-24"; + } + + }else { + throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; + } + } + if($throttlingSettings.UniquePermissionThreshold){ + $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold + } + if($throttlingSettings.EventHandlersEnabled){ + $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled + } + if($throttlingSettings.RequestThrottling){ + $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling + } + if($throttlingSettings.ChangeLogEnabled){ + $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled + } + if($throttlingSettings.ChangeLogExpiryDays){ + $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays + } + } +#endregion +#region WorkflowSettings + #Set-WorkflowSettings $settings.WorkflowSettings $wa + $workflowSettings = $settings.WorkflowSettings + if($workflowSettings -ne $null ){ + if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ + $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; + } + if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ + $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; + } + if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ + $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; + } + + $wa.UpdateWorkflowConfigurationSettings(); } +#endregion + Write-Verbose "applying extended settings" +#region blockedFiles + $blockedFiles= $settings.BlockedFileTypes + if($blockedFiles -ne $null){ + if($blockedFiles.Blocked -ne $null ){ + $wa.BlockedFileExtensions.Clear(); + $blockedFiles.Blocked| % { + $wa.BlockedFileExtensions.Add($_); + + } + } + if($blockedFiles.EnsureBlocked -ne $null){ + $blockedFiles.EnsureBlocked| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_); + } + } + } + if($blockedFiles.EnsureAllowed -ne $null){ + $blockedFiles.EnsureAllowed | % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_); + } + } + } + } + +#endregion + +#region General settings + + $generalSettings = $settings.GeneralSettings + if($generalSettings -ne $null){ + #TODO: Quota Template + if($generalSettings.TimeZone -ne $null){ + $wa.DefaultTimeZone =$generalSettings.TimeZone + } + if($generalSettings.Alerts -ne $null){ + $wa.AlertsEnabled = $generalSettings.Alerts + } + if($generalSettings.AlertsLimit -ne $null){ + $wa.AlertsMaximum = $generalSettings.AlertsLimit + } + if($generalSettings.RSS -ne $null){ + $wa.SyndicationEnabled = $generalSettings.RSS + } + if($generalSettings.AlertsLimit){ + $wa.MetaWeblogEnabled = $generalSettings.BlogAPI + } + if($generalSettings.BlogAPIAuthenticated){ + $wa.MetaWeblogAuthenticationEnabled = $generalSettings.BlogAPIAuthenticated + } + if($generalSettings.BrowserFileHandling){ + $wa.BrowserFileHandling = $generalSettings.BrowserFileHandling + } + if($generalSettings.SecurityValidation){ + $wa.FormDigestSettings.Enabled = $generalSettings.SecurityValidation + } + if($generalSettings.MaximumUploadSize){ + $wa.MaximumFileSize = $generalSettings.MaximumUploadSize + } + if($generalSettings.RecycleBinEnabled){ + $wa.RecycleBinEnabled = $generalSettings.RecycleBinEnabled + } + if($generalSettings.RecycleBinCleanupEnabled){ + $wa.RecycleBinCleanupEnabled = $generalSettings.RecycleBinCleanupEnabled + } + if($generalSettings.RecycleBinRetentionPeriod){ + $wa.RecycleBinRetentionPeriod = $generalSettings.RecycleBinRetentionPeriod + } + if($generalSettings.SecondStageRecycleBinEnabled){ + $wa.SecondStageRecycleBinQuota = $generalSettings.SecondStageRecycleBinEnabled + } + if($generalSettings.CustomerExperienceProgram){ + $wa.BrowserCEIPEnabled = $generalSettings.CustomerExperienceProgram + } + if($generalSettings.Presence -ne $null){ + $wa.PresenceEnabled = $generalSettings.Presence + } + } + if( ($settings.WorkflowSettings -ne $null) -or + ($settings.GeneralSettings -ne $null) -or + ($settings.ThrottlingSettings -ne $null) -or + ($settings.BlockedFileTypes -ne $null) + ){ + $wa.Update() + } +#endregion } } @@ -116,7 +307,11 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 7b9d4c942..b884768a6 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,3 +1,67 @@ +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationHappyHour")] +Class MSFT_xSPFilesTypes +{ + [write]String Blocked[]; + [write]String EnsureBlocked[]; + [write]String EnsureAllowed[]; +}; + +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationHappyHour")] +Class MSFT_xSPWebApplicationHappyHour +{ + [write] uint32 Hour; + [write] uint32 Minute; + [write] uint32 Duration; + +}; + +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationThrottling")] +Class MSFT_xSPWebApplicationThrottling +{ + [write]uint32 ListViewThreshold; + [write]boolean AllowObjectModelOverride; + [write]uint32 AdminThreshold; + [write]uint32 ListViewLookupThreshold; + [write]boolean HappyHourEnabled; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationHappyHour")] String HappyHour; + [write]uint32 UniquePermissionThreshold; + [write]boolean RequestThrottling; + [write]boolean ChangeLogEnabled; + [write]uint32 ChangeLogExpiryDays; + [write]boolean EventHandlersEnabled; + +}; + +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationWorkflowSettings")] +Class MSFT_xSPWebApplicationWorkflowSettings +{ + [write]boolean ExternalWorkflowParticipantsEnabled; + [write]boolean UserDefinedWorkflowsEnabled; + [write]boolean EmailToNoPermissionWorkflowParticipantsEnable; +}; + +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationSettings")] +Class MSFT_xSPWebApplicationSettings +{ + [write]uint32 TimeZone; + [write]String DefaultQuotaTemplate; + [write]boolean Alerts; + [write]uint32 AlertsLimit; + [write]boolean RSS; + [write]boolean BlogAPI; + [write]boolean BlogAPIAuthenticated; + [write, ValueMap{"Strict","Permissive"}, Values{"Stric","Permissive"}] String BrowserFileHandling; + [write]boolean SecurityValidation; + [write]boolean RecycleBinEnabled; + [write]boolean SecondStageRecycleBinEnabled; + [write]boolean RecycleBinCleanupEnabled ; + [write]uint32 RecycleBinRetentionPeriod; + [write]uint32 SecondStageRecycleBinQuota; + [write]uint32 MaximumUploadSize; + [write]boolean CustomerExperienceProgram; + [write]boolean PresenceEnabled; +}; + /* **Description** @@ -20,7 +84,7 @@ The resource will provision the web application with all of the current settings PsDscRunAsCredential = $InstallAccount } */ -[ClassVersion("1.0.0.0"), FriendlyName("xSPWebApplication")] +[ClassVersion("1.1.0.0"), FriendlyName("xSPWebApplication")] class MSFT_xSPWebApplication : OMI_BaseResource { [Key] string Name; @@ -35,5 +99,9 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Path; [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationSettings")] String GeneralSettings; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationWorkflowSettings")] String WorkflowSettings; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationThrottling")] String ThrottlingSettings; + [Write, EmbeddedInstance("MSFT_xSPFilesTypes")] String BlockedFileTypes; }; diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index 84504e4ed..751449604 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -99,5 +99,6 @@ AliasesToExport = '*' # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # DefaultCommandPrefix = '' + } diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 47c5802f9..76c9bf861 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -64,6 +64,7 @@ + @@ -74,6 +75,7 @@ + @@ -109,6 +111,9 @@ + + + @@ -136,6 +141,7 @@ + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index f74ac4f7c..1ebcfcde5 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -67,6 +67,8 @@ + + diff --git a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 index 12aa7e7b4..c1f212a9e 100644 --- a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 @@ -93,4 +93,4 @@ Describe 'xSharePoint whole of module tests' { $errors.Count | Should Be 0 } } -} \ No newline at end of file +} diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 index 1b7fc8bd8..17b735acc 100644 --- a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 +++ b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 @@ -215,4 +215,4 @@ function Get-ParseErrors { return $errors } -Export-ModuleMember * \ No newline at end of file +Export-ModuleMember * diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 new file mode 100644 index 000000000..f3e206d1e --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -0,0 +1,101 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPOutgoingEmailSettings" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPOutgoingEmailSettings" { + InModuleScope $ModuleName { + $testParams = @{ + WebAppUrl = "http://sharepoint.contoso.com" + SMTPServer = "smtp.contoso.com" + FromAddress = "from@email.com" + ReplyToAddress = "reply@email.com" + CharacterSet= "65001" + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + + + Context " Web Application isn't available " { + Mock Get-SPWebApplication -MockWith { return $null + } + + It "returns null from the get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should be $false + } + + } + + Context " Properties match" { + Mock Get-SPWebApplication { + return @{ + Url= "http://sharepoint.contoso.com" + OutboundMailServiceInstance= "smtp.contoso.com" + OutboundMailSenderAddress = "from@email.com" + OutboundMailReplyToAddress= "reply@email.com" + OutboundMailCodePage= "65001" + } + } + + It "returns web app properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + + + Context " Properties update tests " { + Mock Get-SPWebApplication { + $result = @{ + Url= "http://sharepoint.contoso.com" + OutboundMailServiceInstance= "smtp2.contoso.com" + OutboundMailSenderAddress = "from@email.com" + OutboundMailReplyToAddress= "reply@email.com" + OutboundMailCodePage= "65001" + } + $result = $result | Add-Member ScriptMethod UpdateMailSettings { + param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) + $Global:UpdateMailSettingsCalled = $true; + return ; } -passThru + return $result + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "calls the new and set methods from the set function" { + $Global:UpdateMailSettingsCalled=$false; + Set-TargetResource @testParams + Assert-MockCalled Get-SPWebApplication + $Global:UpdateMailSettingsCalled | Should Be $true + } + } + + + + } +} \ No newline at end of file diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 new file mode 100644 index 000000000..0f19af5e3 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -0,0 +1,102 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPPasswordChangeSettings" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPPasswordChangeSettings" { + InModuleScope $ModuleName { + $testParams = @{ + MailAddress = "e@mail.com" + DaysBeforeExpiry = 7 + PasswordChangeWaitTimeSeconds = 60 + + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Context " Farm isn't available " { + Mock Get-SPFarm { return $null + } + + It "returns null from the get method" { + Get-TargetResource @testParams | Should Throw + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should be $false + } + + } + + + Context " Properties already set tests " { + Mock Get-SPFarm { + return @{ + PasswordChangeEmailAddress = "e@mail.com" + DaysBeforePasswordExpirationToSendEmail = 7 + PasswordChangeGuardTime = 60 + PasswordChangeMaximumTries = 3 + } + } + + It "returns farm properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + + + Context " Properties update tests " { + Mock Get-SPFarm { + $result = @{ + PasswordChangeEmailAddress=""; + PasswordChangeGuardTime=0 + PasswordChangeMaximumTries=0 + DaysBeforePasswordExpirationToSendEmail=0 + } + $result = $result | Add-Member ScriptMethod Update { + $Global:SPFarmUpdateCalled = $true; + return $true; + + } -passThru + return $result + } + + It "returns farm properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "calls the new and set methods from the set function" { + $Global:SPFarmUpdateCalled =$false; + Set-TargetResource @testParams + Assert-MockCalled Get-SPFarm + $Global:SPFarmUpdateCalled | Should Be $true + } + } + + + + } +} \ No newline at end of file diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 9bcb0d0bf..3ce3df3e4 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -21,6 +21,7 @@ Describe "xSPWebApplication" { Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") Mock Invoke-xSharePointCommand { @@ -150,5 +151,163 @@ Describe "xSPWebApplication" { Test-TargetResource @testParams | Should Be $true } } + + + + $testParams = @{ + Name = "Complex types Web App" + ApplicationPool = "SharePoint complex type Web App" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + BlockedFileTypes = @{ + Blocked = @("java", "vbs", "exe","xxx") + EnsureBlocked = @("java", "rar", "exe","xxx") + EnsureAllowed = @("exe", "vbs","zip") + } + WorkflowSettings = @{ + ExternalWorkflowParticipantsEnabled=$false + UserDefinedWorkflowsEnabled=$true + EmailToNoPermissionWorkflowParticipantsEnable=$false + } + ThrottlingSettings = @{ + ListViewThreshold = 10000 + AllowObjectModelOverride = $true + AdminThreshold=55000 + ListViewLookupThreshold=10 + HappyHourEnabled= $true + HappyHour = @{ + Hour = 20 + Minute = 5 + Duration = 2 + } + UniquePermissionThreshold = 133000 + RequestThrottling=$false + ChangeLogEnabled=$true + ChangeLogExpiryDays = 19 + EventHandlersEnabled=$true + } + GeneralSettings=@{ + TimeZone = 10 + DefaultQuotaTemplate = "" + Alerts = $true + AlertsLimit = 10 + RSS = $true + BlogAPI = $true + BlogAPIAuthenticated = $true + BrowserFileHandling = "Permissive" + SecurityValidation = $true + RecycleBinEnabled = $true + SecondStageRecycleBinEnabled = $true + RecycleBinCleanupEnabled = $true + RecycleBinRetentionPeriod = 10 + SecondStageRecycleBinQuota = 500 + MaximumUploadSize = 555 + CustomerExperienceProgram = $true + PresenceEnabled = $true + } + + } + + Context "set target resorce works with complex types filled in" { + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } + + $mockedapp= { + $result= @(@{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + MaxItemsPerThrottledOperation=5000 + AllowOMCodeOverrideThrottleSettings=$true + MaxItemsPerThrottledOperationOverride = 10000 + MaxQueryLookupFields = 8 + UnthrottledPrivilegedOperationWindowEnabled =$true + DailyStartUnthrottledPrivilegedOperationsHour = $null + DailyStartUnthrottledPrivilegedOperationsMinute = $null + DailyUnthrottledPrivilegedOperationsDuration = $null + + MaxUniquePermScopesPerList = 50000 + EventHandlersEnabled = $true + HttpThrottleSettings = @{ + PerformThrottle = $true + } + FormDigestSettings = @{ + Enabled =$true + } + ChangeLogExpirationEnabled = $true + ChangeLogRetentionPeriod = New-TimeSpan -Days 10 + }) + + $result= $result | Add-Member ScriptMethod UpdateWorkflowConfigurationSettings { + $Global:UpdateWorkflowCalled = $true; + } -PassThru + + $blockedFileTypes = new-object PSObject + + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Remove { + $Global:BlockedFilesRemoveCalled = $true; + return $true; + } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { + $Global:BlockedFilesClearCalled = $true; + return $true; + } -passThru + + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod ContainExtension { + + param($extension) + $Global:BlockedFilesContainsCalled = $true; + if($extension -eq "exe"){ + return $true + } + return $false + + } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { + param( [string]$fileType) + $Global:BlockedFilesAddCalled = $true; + return $true; + } -passThru + + $result=$result| Add-Member ScriptMethod Update { + $Global:SPWebApplicationUpdateCalled = $true; + return $true; + } -PassThru + $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru + return $result + } + Mock Get-SPWebApplication $mockedapp + Mock New-SPWebApplication $mockedapp + + It "calls the new cmdlet from the set method and does update blockedFileExtensions" { + $Global:BlockedFilesAddCalled = $false; + $Global:BlockedFilesClearCalled = $false; + $Global:BlockedFilesRemoveCalled = $false; + $Global:BlockedFilesContainsCalled = $false; + $Global:SPWebApplicationUpdateCalled =$false ; + Set-TargetResource @testParams + $Global:BlockedFilesAddCalled| Should be $true; + $Global:BlockedFilesContainsCalled| Should be $true; + $Global:SPWebApplicationUpdateCalled| Should be $true; + $Global:BlockedFilesRemoveCalled| Should be $true; + + Assert-MockCalled Get-SPWebApplication + } + + } + + } } \ No newline at end of file From f99b68695e504ceea08f7550a2347a900363adc8 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 27 Nov 2015 23:12:15 +1100 Subject: [PATCH 077/147] Minor tweaks to outgoing email settings, added MOF documentation --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 32 +++++++++---------- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 18 +++++++++++ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 index ec120c409..6db88c98e 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -4,11 +4,11 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, - [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -17,9 +17,9 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration -ErrorAction SilentlyContinue + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration -ErrorAction SilentlyContinue - if ($null -eq $webApp ) { + if ($null -eq $webApp) { return $null } return @{ @@ -38,11 +38,11 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -67,11 +67,11 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -79,7 +79,7 @@ function Test-TargetResource Write-Verbose -Message "Comparing Current and Target Outgoing email settings" if ($null -eq $CurrentValues) { return $false } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("WebAppUrl", "SMTPServer","FromAddress","ReplyToAddress","CharacterSet") + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("SMTPServer","FromAddress","ReplyToAddress","CharacterSet") } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index b6f92db87..862c3206a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -1,3 +1,21 @@ +/* +**Description** + +This resource is used to set the outgoing email settings for either a single web application, or the whole farm. +To configure the resource for a specific web app, use the URL of the web application for the WebAppUrl property, to change the settings for the whole farm use the URL of the central admin website instead. +It is possible to set the outgoing server, from address, reply to address and the character set to be used for emails. + +**Example** + + xSPOutgoingEmailSettings FarmWideEmailSettings + { + WebAppUrl = "http://sharepoint1:2013" + SMTPServer = "smtp.contoso.com" + FromAddress = "sharepoint@contoso.com" + ReplyToAddress = "noreply@contoso.com" + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPOutgoingEmailSettings")] class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource { From 47536e7a926b7410d4c61563821b6cf99f5ae70c Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 27 Nov 2015 23:12:59 +1100 Subject: [PATCH 078/147] fixed tabs - see Camilo, it happens to me too --- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index 862c3206a..ac95787f2 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -12,7 +12,7 @@ It is possible to set the outgoing server, from address, reply to address and th WebAppUrl = "http://sharepoint1:2013" SMTPServer = "smtp.contoso.com" FromAddress = "sharepoint@contoso.com" - ReplyToAddress = "noreply@contoso.com" + ReplyToAddress = "noreply@contoso.com" PsDscRunAsCredential = $InstallAccount } */ From 0c8eeeea5efeea32ace29e8e82dcd6b54e728199 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 27 Nov 2015 23:17:51 +1100 Subject: [PATCH 079/147] Minor formatting changes to outgoing email tests --- ...xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index f3e206d1e..375748c55 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -30,8 +30,7 @@ Describe "xSPOutgoingEmailSettings" { Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue - - Context " Web Application isn't available " { + Context "The Web Application isn't available" { Mock Get-SPWebApplication -MockWith { return $null } @@ -43,9 +42,13 @@ Describe "xSPOutgoingEmailSettings" { Test-TargetResource @testParams | Should be $false } + It "throws an exception in the set method" { + { Set-TargetResource @testParams } | Should throw + } } - Context " Properties match" { + + Context "The web application exists and the properties match" { Mock Get-SPWebApplication { return @{ Url= "http://sharepoint.contoso.com" @@ -63,11 +66,10 @@ Describe "xSPOutgoingEmailSettings" { It "returns true from the test method" { Test-TargetResource @testParams | Should Be $true } - } - Context " Properties update tests " { + Context "The web application exists and the properties don't match" { Mock Get-SPWebApplication { $result = @{ Url= "http://sharepoint.contoso.com" @@ -94,8 +96,5 @@ Describe "xSPOutgoingEmailSettings" { $Global:UpdateMailSettingsCalled | Should Be $true } } - - - } } \ No newline at end of file From f40597bca42e23a3b9732788ac03734af9e475dd Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 27 Nov 2015 23:29:10 +1100 Subject: [PATCH 080/147] Minor tweaks and MOF documentation for password change settings --- .../MSFT_xSPPasswordChangeSettings.psm1 | 39 +++++++++---------- .../MSFT_xSPPasswordChangeSettings.schema.mof | 18 +++++++++ 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index ef256a103..083a038b5 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -4,10 +4,10 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $false)] [ValidateRange(0,356)] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)] [ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)] [ValidateRange(0,99)] [System.UInt32] $NumberOfRetries, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -33,10 +33,10 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $false)][ValidateRange(0,356 )][System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99 )][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $false)] [ValidateRange(0,356)] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)] [ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)] [ValidateRange(0,99)] [System.UInt32] $NumberOfRetries, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -47,18 +47,17 @@ function Set-TargetResource if ($null -eq $farm ) { return $null } - $farm.PasswordChangeEmailAddress=$params.MailAddress; - if($params.PasswordChangeWaitTimeSeconds -ne $null){ - $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds + $farm.PasswordChangeEmailAddress = $params.MailAddress; + if($params.PasswordChangeWaitTimeSeconds -ne $null) { + $farm.PasswordChangeGuardTime = $params.PasswordChangeWaitTimeSeconds } - if($params.NumberOfRetries -ne $null){ - $farm.PasswordChangeMaximumTries=$params.NumberOfRetries + if($params.NumberOfRetries -ne $null) { + $farm.PasswordChangeMaximumTries = $params.NumberOfRetries } - if($params.DaysBeforeExpiry -ne $null){ - $farm.DaysBeforePasswordExpirationToSendEmail=$params.DaysBeforeExpiry + if($params.DaysBeforeExpiry -ne $null) { + $farm.DaysBeforePasswordExpirationToSendEmail = $params.DaysBeforeExpiry } $farm.Update(); - } } @@ -69,10 +68,10 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $false)] [ValidateRange(0,356)] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)] [ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)] [ValidateRange(0,99)] [System.UInt32] $NumberOfRetries, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index 3ff4a1652..8a9b15557 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -1,3 +1,21 @@ +/* +**Description** + +This resource is used to control settings that relate to the automatic changing of passwords for managed accounts (where they opt-in to be managed by SharePoint). +These settings can be manually controlled through central administration, or configured in this resource. +The settings relate to email notifications of when passwords are reset, as well as behavior when a reset occurs such as a time out and number of retries. + +**Example** + + xSPPasswordChangeSettings ManagedAccountPasswordResetSettings + { + MailAddress = "sharepoint@contoso.com" + DaysBeforeExpiry = "14" + PasswordChangeWaitTimeSeconds = "60" + NumberOfRetries = "3" + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0.0"), FriendlyName("xSPPasswordChangeSettings")] class MSFT_xSPPasswordChangeSettings : OMI_BaseResource { From d2a5793e417c96cc1bac4100576da73dbb746c11 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 27 Nov 2015 23:33:00 +1100 Subject: [PATCH 081/147] Minor tweaks to password change settings tests --- ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 0f19af5e3..510fed3c7 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -28,9 +28,8 @@ Describe "xSPPasswordChangeSettings" { Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue - Context " Farm isn't available " { - Mock Get-SPFarm { return $null - } + Context "No local SharePoint farm is available" { + Mock Get-SPFarm { return $null } It "returns null from the get method" { Get-TargetResource @testParams | Should Throw @@ -39,18 +38,17 @@ Describe "xSPPasswordChangeSettings" { It "returns false from the test method" { Test-TargetResource @testParams | Should be $false } - } - Context " Properties already set tests " { + Context "There is a local SharePoint farm and the properties are set correctly" { Mock Get-SPFarm { return @{ - PasswordChangeEmailAddress = "e@mail.com" - DaysBeforePasswordExpirationToSendEmail = 7 - PasswordChangeGuardTime = 60 - PasswordChangeMaximumTries = 3 - } + PasswordChangeEmailAddress = "e@mail.com" + DaysBeforePasswordExpirationToSendEmail = 7 + PasswordChangeGuardTime = 60 + PasswordChangeMaximumTries = 3 + } } It "returns farm properties from the get method" { @@ -60,23 +58,22 @@ Describe "xSPPasswordChangeSettings" { It "returns true from the test method" { Test-TargetResource @testParams | Should Be $true } - } - Context " Properties update tests " { + Context "There is a local SharePoint farm and the properties are not set correctly" { Mock Get-SPFarm { $result = @{ - PasswordChangeEmailAddress=""; - PasswordChangeGuardTime=0 - PasswordChangeMaximumTries=0 - DaysBeforePasswordExpirationToSendEmail=0 - } + PasswordChangeEmailAddress = ""; + PasswordChangeGuardTime = 0 + PasswordChangeMaximumTries = 0 + DaysBeforePasswordExpirationToSendEmail = 0 + } $result = $result | Add-Member ScriptMethod Update { $Global:SPFarmUpdateCalled = $true; return $true; - } -passThru + } -PassThru return $result } @@ -89,7 +86,7 @@ Describe "xSPPasswordChangeSettings" { } It "calls the new and set methods from the set function" { - $Global:SPFarmUpdateCalled =$false; + $Global:SPFarmUpdateCalled = $false; Set-TargetResource @testParams Assert-MockCalled Get-SPFarm $Global:SPFarmUpdateCalled | Should Be $true From 6d99fe31030b9dced8b5f7771c72ebb7aa0ca51f Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 28 Nov 2015 00:55:14 +1100 Subject: [PATCH 082/147] Work in progress on refactor of xSPWebApplication --- .../MSFT_xSPWebApplication.Set.ps1 | 59 +------- .../MSFT_xSPWebApplication.psm1 | 132 +++++++----------- .../MSFT_xSPWebApplication.schema.mof | 23 ++- .../xSPWebApplication.BlockedFileTypes.psm1 | 33 +++++ .../xSPWebApplication.Throttling.psm1 | 110 +++++++++++++++ .../xSPWebApplication.Workflow.psm1 | 44 ++++++ 6 files changed, 253 insertions(+), 148 deletions(-) create mode 100644 Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 create mode 100644 Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 create mode 100644 Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 index c3af6e4d3..d855f9275 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 @@ -78,57 +78,6 @@ function Set-WorkflowSettings ($workflowSettings, $wa) $wa.Update(); } -function Set-ThrottlingSettings ($throttlingSettings, $wa) -{ - if($throttlingSettings -eq $null){ return;} - if($throttlingSettings.ListViewThreshold -ne $null ){ - $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold - } - if($throttlingSettings.AllowObjectModelOverride -ne $null){ - $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride - } - if($throttlingSettings.AdminThreshold -ne $null){ - $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold - } - if($throttlingSettings.ListViewLookupThreshold -ne $null){ - $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold - } - if($throttlingSettings.HappyHourEnabled -ne $null){ - $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled - } - if($throttlingSettings.HappyHour -ne $null){ - $happyHour =$throttlingSettings.HappyHour; - if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ - if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ - $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour - $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute - $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration - }else{ - throw "the valid range hour, minute and duration is 0-24"; - } - - }else { - throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; - } - } - if($throttlingSettings.UniquePermissionThreshold){ - $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold - } - if($throttlingSettings.EventHandlersEnabled){ - $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled - } - if($throttlingSettings.RequestThrottling){ - $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling - } - if($throttlingSettings.ChangeLogEnabled){ - $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled - } - if($throttlingSettings.ChangeLogExpiryDays){ - $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays - } - $wa.Update(); -} - function GetAndRemove-Parameter($params, $name){ $result =$null if($params.ContainsKey($name)) @@ -179,10 +128,4 @@ if ($null -eq $wa) { } $wa = New-SPWebApplication @params -} - -Set-ThrottlingSettings $settings.ThrottlingSettings $wa -Set-WorkflowSettings $settings.WorkflowSettings $wa -Set-BlockedFiles $settings.BlockedFileTypes $wa -Set-GeneralSettings $settings.GeneralSettings $wa - \ No newline at end of file +} \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 4edb6efd1..af0013a51 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -39,7 +39,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $GeneralSettings, [parameter(Mandatory = $false)] $WorkflowSettings, [parameter(Mandatory = $false)] $ThrottlingSettings, [parameter(Mandatory = $false)] $BlockedFileTypes @@ -55,9 +55,11 @@ function Get-TargetResource if ($null -eq $wa) { return $null } $authProvider = Get-SPAuthenticationProvider -WebApplication $wa.Url -Zone "Default" - if ($authProvider.DisableKerberos -eq $true) { $localAuthMode = "NTLM" } else { $localAuthMode = "Kerberos" } + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + return @{ Name = $wa.DisplayName ApplicationPool = $wa.ApplicationPool.Name @@ -71,6 +73,8 @@ function Get-TargetResource Port = (New-Object System.Uri $wa.Url).Port AuthenticationMethod = $localAuthMode InstallAccount = $params.InstallAccount + ThrottlingSettings = (Get-xSPWebApplicationThrottlingSettings -WebApplication $wa) + WorkflowSettings = (Get-xSPWebApplicationWorkflowSettings -WebApplication $wa) } } return $result @@ -94,7 +98,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $GeneralSettings, [parameter(Mandatory = $false)] $WorkflowSettings, [parameter(Mandatory = $false)] $ThrottlingSettings, [parameter(Mandatory = $false)] $BlockedFileTypes @@ -111,93 +115,44 @@ function Set-TargetResource $params.Remove("Settings") | Out-Null $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { + $newWebAppParams = @{ + Name = $params.Name + ApplicationPool = $params.ApplicationPool + ApplicationPoolAccount = $params.ApplicationPoolAccount + Url = $params.Url + } if ($params.ContainsKey("AuthenticationMethod") -eq $true) { if ($params.AuthenticationMethod -eq "NTLM") { $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos } else { $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication } - $params.Remove("AuthenticationMethod") - $params.Add("AuthenticationProvider", $ap) + $newWebAppParams.Add("AuthenticationProvider", $ap) } - - if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } if ($params.ContainsKey("AllowAnonymous")) { - $params.Remove("AllowAnonymous") | Out-Null - $params.Add("AllowAnonymousAccess", $true) + $newWebAppParams.Add("AllowAnonymousAccess", $true) } + if ($params.ContainsKey("DatabaseName") -eq $true) { $newWebAppParams.Add("DatabaseName", $params.DatabaseName) } + if ($params.ContainsKey("DatabaseServer") -eq $true) { $newWebAppParams.Add("DatabaseServer", $params.DatabaseServer) } + if ($params.ContainsKey("HostHeader") -eq $true) { $newWebAppParams.Add("HostHeader", $params.HostHeader) } + if ($params.ContainsKey("Path") -eq $true) { $newWebAppParams.Add("Path", $params.Path) } + if ($params.ContainsKey("Port") -eq $true) { $newWebAppParams.Add("Port", $params.Port) } - $wa = New-SPWebApplication @params + $wa = New-SPWebApplication @newWebAppParams } -#region throttling settings - - $throttlingSettings = $settings.ThrottlingSettings - if($throttlingSettings -ne $null){ - if($throttlingSettings.ListViewThreshold -ne $null ){ - $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold - } - if($throttlingSettings.AllowObjectModelOverride -ne $null){ - $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride - } - if($throttlingSettings.AdminThreshold -ne $null){ - $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold - } - if($throttlingSettings.ListViewLookupThreshold -ne $null){ - $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold - } - if($throttlingSettings.HappyHourEnabled -ne $null){ - $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled - } - if($throttlingSettings.HappyHour -ne $null){ - $happyHour =$throttlingSettings.HappyHour; - if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ - if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ - $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour - $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute - $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration - }else{ - throw "the valid hour, minute and duration range is 0-24"; - } - - }else { - throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; - } - } - if($throttlingSettings.UniquePermissionThreshold){ - $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold - } - if($throttlingSettings.EventHandlersEnabled){ - $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled - } - if($throttlingSettings.RequestThrottling){ - $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling - } - if($throttlingSettings.ChangeLogEnabled){ - $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled - } - if($throttlingSettings.ChangeLogExpiryDays){ - $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays - } + # Resource throttling settings + if ($params.ContainsKey("ThrottlingSettings") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + Set-xSPWebApplicationThrottlingSettings -WebApplication $wa -Settings $params.ThrottlingSettings } -#endregion -#region WorkflowSettings - #Set-WorkflowSettings $settings.WorkflowSettings $wa - $workflowSettings = $settings.WorkflowSettings - if($workflowSettings -ne $null ){ - if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ - $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; - } - if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ - $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; - } - if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ - $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; - } - - $wa.UpdateWorkflowConfigurationSettings(); + + # Workflow settings + if ($params.ContainsKey("WorkflowSettings") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + Set-xSPWebApplicationWorkflowSettingsSettings -WebApplication $wa -Settings $params.ThrottlingSettings } -#endregion + Write-Verbose "applying extended settings" #region blockedFiles $blockedFiles= $settings.BlockedFileTypes @@ -308,7 +263,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $GeneralSettings, [parameter(Mandatory = $false)] $WorkflowSettings, [parameter(Mandatory = $false)] $ThrottlingSettings, [parameter(Mandatory = $false)] $BlockedFileTypes @@ -317,7 +272,28 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters Write-Verbose -Message "Testing for web application '$Name'" if ($null -eq $CurrentValues) { return $false } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") + + $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentValues ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @("ApplicationPool") + + if ($testReturn -eq $false) { return $false } + + # Resource throttling settings + if ($PSBoundParameters.ContainsKey("ThrottlingSettings") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + $testReturn = Test-xSPWebApplicationThrottlingSettings -CurrentSettings $CurrentValues.ThrottlingSettings -DesiredSettings $ThrottlingSettings + } + if ($testReturn -eq $false) { return $false } + + # Workflow settings + if ($PSBoundParameters.ContainsKey("WorkflowSettings") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + $testReturn = Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues.WorkflowSettings -DesiredSettings $WorkflowSettings + } + if ($testReturn -eq $false) { return $false } + + return $testReturn } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index b884768a6..35977ab98 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,4 +1,4 @@ -[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationHappyHour")] +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationBlockedFileTypes")] Class MSFT_xSPFilesTypes { [write]String Blocked[]; @@ -18,18 +18,17 @@ Class MSFT_xSPWebApplicationHappyHour [ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationThrottling")] Class MSFT_xSPWebApplicationThrottling { - [write]uint32 ListViewThreshold; - [write]boolean AllowObjectModelOverride; - [write]uint32 AdminThreshold; - [write]uint32 ListViewLookupThreshold; - [write]boolean HappyHourEnabled; + [write] uint32 ListViewThreshold; + [write] boolean AllowObjectModelOverride; + [write] uint32 AdminThreshold; + [write] uint32 ListViewLookupThreshold; + [write] boolean HappyHourEnabled; [Write, EmbeddedInstance("MSFT_xSPWebApplicationHappyHour")] String HappyHour; - [write]uint32 UniquePermissionThreshold; - [write]boolean RequestThrottling; - [write]boolean ChangeLogEnabled; - [write]uint32 ChangeLogExpiryDays; - [write]boolean EventHandlersEnabled; - + [write] uint32 UniquePermissionThreshold; + [write] boolean RequestThrottling; + [write] boolean ChangeLogEnabled; + [write] uint32 ChangeLogExpiryDays; + [write] boolean EventHandlersEnabled; }; [ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationWorkflowSettings")] diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 new file mode 100644 index 000000000..8f40ebe67 --- /dev/null +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -0,0 +1,33 @@ +function Get-xSPWebApplicationBlockedFileTypes { + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param( + [parameter(Mandatory = $true)] $WebApplication + ) + return @{ + Blocked = @() + } +} + +function Set-xSPWebApplicationBlockedFileTypes { + [CmdletBinding()] + param( + [parameter(Mandatory = $true)] $WebApplication, + [parameter(Mandatory = $true)] $Settings + ) + +} + +function Test-xSPWebApplicationBlockedFileTypes { + [CmdletBinding()] + [OutputType([System.Boolean])] + param( + [parameter(Mandatory = $true)] $CurrentSettings, + [parameter(Mandatory = $true)] $DesiredSettings + ) + + $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` + -DesiredValues $DesiredSettings + return $testReturn +} + diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 new file mode 100644 index 000000000..5e134eeaf --- /dev/null +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -0,0 +1,110 @@ +function Get-xSPWebApplicationThrottlingSettings { + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param( + [parameter(Mandatory = $true)] $WebApplication + ) + return @{ + ListViewThreshold = $WebApplication.MaxItemsPerThrottledOperation + AllowObjectModelOverride = $WebApplication.AllowOMCodeOverrideThrottleSettings + AdminThreshold = $WebApplication.MaxItemsPerThrottledOperationOverride + ListViewLookupThreshold = $WebApplication.MaxQueryLookupFields + HappyHourEnabled = $WebApplication.UnthrottledPrivilegedOperationWindowEnabled + HappyHour = @{ + Hour = $WebApplication.DailyStartUnthrottledPrivilegedOperationsHour + Minute = $WebApplication.DailyStartUnthrottledPrivilegedOperationsMinute + Duration = $WebApplication.DailyUnthrottledPrivilegedOperationsDuration + } + UniquePermissionThreshold = $WebApplication.MaxUniquePermScopesPerList + RequestThrottling = $WebApplication.HttpThrottleSettings.PerformThrottle + ChangeLogEnabled = $WebApplication.ChangeLogExpirationEnabled + ChangeLogExpiryDays = $WebApplication.ChangeLogRetentionPeriod.Days + EventHandlersEnabled = $WebApplication.EventHandlersEnabled + } +} + +function Set-xSPWebApplicationThrottlingSettings { + [CmdletBinding()] + param( + [parameter(Mandatory = $true)] $WebApplication, + [parameter(Mandatory = $true)] $Settings + ) + + if($Settings.ListViewThreshold -ne $null ){ + $WebApplication.MaxItemsPerThrottledOperation = $Settings.ListViewThreshold + } + if($Settings.AllowObjectModelOverride -ne $null){ + $WebApplication.AllowOMCodeOverrideThrottleSettings = $Settings.AllowObjectModelOverride + } + if($Settings.AdminThreshold -ne $null){ + $WebApplication.MaxItemsPerThrottledOperationOverride = $Settings.AdminThreshold + } + if($Settings.ListViewLookupThreshold -ne $null){ + $WebApplication.MaxQueryLookupFields = $Settings.ListViewLookupThreshold + } + if($Settings.HappyHourEnabled -ne $null){ + $WebApplication.UnthrottledPrivilegedOperationWindowEnabled =$Settings.HappyHourEnabled + } + if($Settings.HappyHour -ne $null){ + $happyHour =$Settings.HappyHour; + if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ + if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ + $WebApplication.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour + $WebApplication.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute + $WebApplication.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration + }else{ + throw "the valid hour, minute and duration range is 0-24"; + } + + }else { + throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; + } + } + if($Settings.UniquePermissionThreshold){ + $WebApplication.MaxUniquePermScopesPerList = $Settings.UniquePermissionThreshold + } + if($Settings.EventHandlersEnabled){ + $WebApplication.EventHandlersEnabled = $Settings.EventHandlersEnabled + } + if($Settings.RequestThrottling){ + $WebApplication.HttpThrottleSettings.PerformThrottle = $Settings.RequestThrottling + } + if($Settings.ChangeLogEnabled){ + $WebApplication.ChangeLogExpirationEnabled = $Settings.ChangeLogEnabled + } + if($Settings.ChangeLogExpiryDays){ + $WebApplication.ChangeLogRetentionPeriod = New-TimeSpan -Days $Settings.ChangeLogExpiryDays + } +} + +function Test-xSPWebApplicationThrottlingSettings { + [CmdletBinding()] + [OutputType([System.Boolean])] + param( + [parameter(Mandatory = $true)] $CurrentSettings, + [parameter(Mandatory = $true)] $DesiredSettings + ) + + $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` + -DesiredValues $DesiredSettings ` + -ValuesToCheck @( + "ListViewThreshold", + "AllowObjectModelOverride", + "AdminThreshold", + "ListViewLookupThreshold", + "HappyHourEnabled", + "UniquePermissionThreshold", + "RequestThrottling", + "ChangeLogEnabled", + "ChangeLogExpiryDays", + "EventHandlersEnabled" + ) + if ($testReturn -eq $true) { + if ($Settings.ContainsKey("HappyHour") -eq $true) { + $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings.HappyHour ` + -DesiredValues $DesiredSettings.HappyHour + } + } + return $testReturn +} + diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 new file mode 100644 index 000000000..411461f45 --- /dev/null +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 @@ -0,0 +1,44 @@ +function Get-xSPWebApplicationWorkflowSettings { + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param( + [parameter(Mandatory = $true)] $WebApplication + ) + return @{ + ExternalWorkflowParticipantsEnabled = $WebApplication.ExternalWorkflowParticipantsEnabled + UserDefinedWorkflowsEnabled = $WebApplication.UserDefinedWorkflowsEnabled + EmailToNoPermissionWorkflowParticipantsEnable = $WebApplication.EmailToNoPermissionWorkflowParticipantsEnabled + } +} + +function Set-xSPWebApplicationWorkflowSettings { + [CmdletBinding()] + param( + [parameter(Mandatory = $true)] $WebApplication, + [parameter(Mandatory = $true)] $Settings + ) + if($Settings.UserDefinedWorkflowsEnabled -ne $null){ + $WebApplication.UserDefinedWorkflowsEnabled = $Settings.UserDefinedWorkflowsEnabled; + } + if($Settings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ + $WebApplication.EmailToNoPermissionWorkflowParticipantsEnabled = $Settings.EmailToNoPermissionWorkflowParticipantsEnable; + } + if($Settings.ExternalWorkflowParticipantsEnabled -ne $null){ + $WebApplication.ExternalWorkflowParticipantsEnabled = $Settings.ExternalWorkflowParticipantsEnabled; + } + $WebApplication.UpdateWorkflowConfigurationSettings(); +} + +function Test-xSPWebApplicationWorkflowSettings { + [CmdletBinding()] + [OutputType([System.Boolean])] + param( + [parameter(Mandatory = $true)] $CurrentSettings, + [parameter(Mandatory = $true)] $DesiredSettings + ) + + $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` + -DesiredValues $DesiredSettings + return $testReturn +} + From 601c79dd1f79a93125cf54d43e7605eb53372e80 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 11:53:16 +1100 Subject: [PATCH 083/147] Added blocked file types to xSPWebApplication --- .../MSFT_xSPWebApplication.psm1 | 42 +++++-------- .../xSPWebApplication.BlockedFileTypes.psm1 | 61 +++++++++++++++++-- Modules/xSharePoint/xSharePoint.pssproj | 4 ++ 3 files changed, 75 insertions(+), 32 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index af0013a51..6722c0922 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -59,6 +59,7 @@ function Get-TargetResource Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) return @{ Name = $wa.DisplayName @@ -75,6 +76,7 @@ function Get-TargetResource InstallAccount = $params.InstallAccount ThrottlingSettings = (Get-xSPWebApplicationThrottlingSettings -WebApplication $wa) WorkflowSettings = (Get-xSPWebApplicationWorkflowSettings -WebApplication $wa) + BlockedFileTypes = (Get-xSPWebApplicationBlockedFileTypes -WebApplication $wa) } } return $result @@ -150,38 +152,15 @@ function Set-TargetResource # Workflow settings if ($params.ContainsKey("WorkflowSettings") -eq $true) { Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - Set-xSPWebApplicationWorkflowSettingsSettings -WebApplication $wa -Settings $params.ThrottlingSettings + Set-xSPWebApplicationWorkflowSettings -WebApplication $wa -Settings $params.ThrottlingSettings } - Write-Verbose "applying extended settings" -#region blockedFiles - $blockedFiles= $settings.BlockedFileTypes - if($blockedFiles -ne $null){ - if($blockedFiles.Blocked -ne $null ){ - $wa.BlockedFileExtensions.Clear(); - $blockedFiles.Blocked| % { - $wa.BlockedFileExtensions.Add($_); - - } - } - if($blockedFiles.EnsureBlocked -ne $null){ - $blockedFiles.EnsureBlocked| % { - if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_); - } - } - } - if($blockedFiles.EnsureAllowed -ne $null){ - $blockedFiles.EnsureAllowed | % { - if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_); - } - } - } + # Blocked file types + if ($params.ContainsKey("BlockedFileTypes") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) + Set-xSPWebApplicationBlockedFileTypes -WebApplication $wa -Settings $params.BlockedFileTypes } -#endregion - #region General settings $generalSettings = $settings.GeneralSettings @@ -293,6 +272,13 @@ function Test-TargetResource } if ($testReturn -eq $false) { return $false } + # Blocked file types + if ($PSBoundParameters.ContainsKey("BlockedFileTypes") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) + $testReturn = Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues.BlockedFileTypes -DesiredSettings $BlockedFileTypes + } + if ($testReturn -eq $false) { return $false } + return $testReturn } diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 index 8f40ebe67..2ede67189 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -4,8 +4,10 @@ function Get-xSPWebApplicationBlockedFileTypes { param( [parameter(Mandatory = $true)] $WebApplication ) + $result = @() + $WebApplication.BlockedFileExtensions | ForEach-Object { $result += $_ } return @{ - Blocked = @() + Blocked = $result } } @@ -16,6 +18,36 @@ function Set-xSPWebApplicationBlockedFileTypes { [parameter(Mandatory = $true)] $Settings ) + if ($Settings.Blocked -ne $null -and (($Settings.EnsureBlocked -ne $null) -or ($Settings.EnsureAllowed -ne $null))) { + throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." + } + + if ($Settings.Blocked -eq $null -and $Settings.EnsureBlocked -eq $null -and $Settings.EnsureAllowed -eq $null) { + throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" + } + + if($Settings.Blocked -ne $null ){ + $WebApplication.BlockedFileExtensions.Clear(); + $blockedFiles.Blocked | ForEach-Object { + $WebApplication.BlockedFileExtensions.Add($_); + } + } + + if($Settings.EnsureBlocked -ne $null){ + $blockedFiles.EnsureBlocked | ForEach-Object { + if(!$WebApplication.BlockedFileExtensions.ContainExtension($_)){ + $WebApplication.BlockedFileExtensions.Add($_); + } + } + } + + if($Settings.EnsureAllowed -ne $null){ + $blockedFiles.EnsureAllowed | ForEach-Object { + if($WebApplication.BlockedFileExtensions.ContainExtension($_)){ + $WebApplication.BlockedFileExtensions.Remove($_); + } + } + } } function Test-xSPWebApplicationBlockedFileTypes { @@ -26,8 +58,29 @@ function Test-xSPWebApplicationBlockedFileTypes { [parameter(Mandatory = $true)] $DesiredSettings ) - $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` - -DesiredValues $DesiredSettings - return $testReturn + if ($DesiredSettings.Blocked -ne $null -and (($DesiredSettings.EnsureBlocked -ne $null) -or ($DesiredSettings.EnsureAllowed -ne $null))) { + throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." + } + + if ($DesiredSettings.Blocked -eq $null -and $DesiredSettings.EnsureBlocked -eq $null -and $DesiredSettings.EnsureAllowed -eq $null) { + throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" + } + + if ($DesiredSettings.Blocked -ne $null) { + $compareResult = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.Blocked + if ($compareResult -eq $null) { return $true } else { return $false } + } + + if($DesiredSettings.EnsureBlocked -ne $null){ + $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked -IncludeEqual -ExcludeDifferent + if ($itemsToRemove -ne $null) { return $false } + } + + if($DesiredSettings.EnsureAllowed -ne $null){ + $itemsToAdd = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureAllowed | Where-Object { $_.SideIndicator -eq "=>"} + if ($itemsToAdd -ne $null) { return $false } + } + + return $true } diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 76c9bf861..3abbaebe6 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -79,6 +79,7 @@ + @@ -138,6 +139,9 @@ + + + From e61dc5d7b5774087308ab9e2d0f3b457b53c60e8 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 16:12:15 +1100 Subject: [PATCH 084/147] Added general settings support to xSPWebApplication --- .../MSFT_xSPWebApplication.psm1 | 99 ++++--------------- .../MSFT_xSPWebApplication.schema.mof | 30 +++--- .../xSPWebApplication.GeneralSettings.psm1 | 60 +++++++++++ 3 files changed, 93 insertions(+), 96 deletions(-) create mode 100644 Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 6722c0922..9bda4569c 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -1,26 +1,3 @@ -function GetAndRemove-Parameter($params, $name){ - $result =$null - if($params.ContainsKey($name)) - { - $result = $params.$name - $params.Remove( $name) - } - return $result; -} -function Sanitize-ComplexTypes{ - param( - [Parameter(Position = 0)] - $params - ) - return @{ - GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" - WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" - Extensions = GetAndRemove-Parameter $params "Extensions" - ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" - BlockedFileTypes = GetAndRemove-Parameter $params "BlockedFileTypes" - } -} - function Get-TargetResource { [CmdletBinding()] @@ -60,6 +37,7 @@ function Get-TargetResource Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) return @{ Name = $wa.DisplayName @@ -77,6 +55,7 @@ function Get-TargetResource ThrottlingSettings = (Get-xSPWebApplicationThrottlingSettings -WebApplication $wa) WorkflowSettings = (Get-xSPWebApplicationWorkflowSettings -WebApplication $wa) BlockedFileTypes = (Get-xSPWebApplicationBlockedFileTypes -WebApplication $wa) + GeneralSettings = (Get-xSPWebApplicationGeneralSettings -WebApplication $wa) } } return $result @@ -161,65 +140,18 @@ function Set-TargetResource Set-xSPWebApplicationBlockedFileTypes -WebApplication $wa -Settings $params.BlockedFileTypes } -#region General settings - - $generalSettings = $settings.GeneralSettings - if($generalSettings -ne $null){ - #TODO: Quota Template - if($generalSettings.TimeZone -ne $null){ - $wa.DefaultTimeZone =$generalSettings.TimeZone - } - if($generalSettings.Alerts -ne $null){ - $wa.AlertsEnabled = $generalSettings.Alerts - } - if($generalSettings.AlertsLimit -ne $null){ - $wa.AlertsMaximum = $generalSettings.AlertsLimit - } - if($generalSettings.RSS -ne $null){ - $wa.SyndicationEnabled = $generalSettings.RSS - } - if($generalSettings.AlertsLimit){ - $wa.MetaWeblogEnabled = $generalSettings.BlogAPI - } - if($generalSettings.BlogAPIAuthenticated){ - $wa.MetaWeblogAuthenticationEnabled = $generalSettings.BlogAPIAuthenticated - } - if($generalSettings.BrowserFileHandling){ - $wa.BrowserFileHandling = $generalSettings.BrowserFileHandling - } - if($generalSettings.SecurityValidation){ - $wa.FormDigestSettings.Enabled = $generalSettings.SecurityValidation - } - if($generalSettings.MaximumUploadSize){ - $wa.MaximumFileSize = $generalSettings.MaximumUploadSize - } - if($generalSettings.RecycleBinEnabled){ - $wa.RecycleBinEnabled = $generalSettings.RecycleBinEnabled - } - if($generalSettings.RecycleBinCleanupEnabled){ - $wa.RecycleBinCleanupEnabled = $generalSettings.RecycleBinCleanupEnabled - } - if($generalSettings.RecycleBinRetentionPeriod){ - $wa.RecycleBinRetentionPeriod = $generalSettings.RecycleBinRetentionPeriod - } - if($generalSettings.SecondStageRecycleBinEnabled){ - $wa.SecondStageRecycleBinQuota = $generalSettings.SecondStageRecycleBinEnabled - } - if($generalSettings.CustomerExperienceProgram){ - $wa.BrowserCEIPEnabled = $generalSettings.CustomerExperienceProgram - } - if($generalSettings.Presence -ne $null){ - $wa.PresenceEnabled = $generalSettings.Presence - } + # General Settings + if ($params.ContainsKey("GeneralSettings") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) + Set-xSPWebApplicationGeneralSettings -WebApplication $wa -Settings $params.GeneralSettings } - if( ($settings.WorkflowSettings -ne $null) -or - ($settings.GeneralSettings -ne $null) -or - ($settings.ThrottlingSettings -ne $null) -or - ($settings.BlockedFileTypes -ne $null) - ){ + + if( ($params.WorkflowSettings -ne $null) -or + ($params.GeneralSettings -ne $null) -or + ($params.ThrottlingSettings -ne $null) -or + ($params.BlockedFileTypes -ne $null) ) { $wa.Update() - } -#endregion + } } } @@ -279,6 +211,13 @@ function Test-TargetResource } if ($testReturn -eq $false) { return $false } + # General settings + if ($PSBoundParameters.ContainsKey("GeneralSettings") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) + $testReturn = Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues.GeneralSettings -DesiredSettings $GeneralSettings + } + if ($testReturn -eq $false) { return $false } + return $testReturn } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 35977ab98..3cf205877 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -42,23 +42,21 @@ Class MSFT_xSPWebApplicationWorkflowSettings [ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationSettings")] Class MSFT_xSPWebApplicationSettings { - [write]uint32 TimeZone; - [write]String DefaultQuotaTemplate; - [write]boolean Alerts; - [write]uint32 AlertsLimit; - [write]boolean RSS; - [write]boolean BlogAPI; - [write]boolean BlogAPIAuthenticated; + [write] uint32 TimeZone; + [write] boolean Alerts; + [write] uint32 AlertsLimit; + [write] boolean RSS; + [write] boolean BlogAPI; + [write] boolean BlogAPIAuthenticated; [write, ValueMap{"Strict","Permissive"}, Values{"Stric","Permissive"}] String BrowserFileHandling; - [write]boolean SecurityValidation; - [write]boolean RecycleBinEnabled; - [write]boolean SecondStageRecycleBinEnabled; - [write]boolean RecycleBinCleanupEnabled ; - [write]uint32 RecycleBinRetentionPeriod; - [write]uint32 SecondStageRecycleBinQuota; - [write]uint32 MaximumUploadSize; - [write]boolean CustomerExperienceProgram; - [write]boolean PresenceEnabled; + [write] boolean SecurityValidation; + [write] boolean RecycleBinEnabled; + [write] boolean RecycleBinCleanupEnabled; + [write] uint32 RecycleBinRetentionPeriod; + [write] uint32 SecondStageRecycleBinQuota; + [write] uint32 MaximumUploadSize; + [write] boolean CustomerExperienceProgram; + [write] boolean PresenceEnabled; }; /* diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 new file mode 100644 index 000000000..b5306661f --- /dev/null +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 @@ -0,0 +1,60 @@ +function Get-xSPWebApplicationGeneralSettings { + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param( + [parameter(Mandatory = $true)] $WebApplication + ) + + return @{ + TimeZone = $WebApplication.DefaultTimeZone + Alerts = $WebApplication.AlertsEnabled + AlertsLimit = $WebApplication.AlertsMaximum + RSS = $WebApplication.SyndicationEnabled + BlogAPI = $WebApplication.MetaWeblogEnabled + BlogAPIAuthenticated = $WebApplication.MetaWeblogAuthenticationEnabled + BrowserFileHandling = $WebApplication.BrowserFileHandling + SecurityValidation = $WebApplication.FormDigestSettings.Enabled + RecycleBinEnabled = $WebApplication.RecycleBinEnabled + RecycleBinCleanupEnabled = $WebApplication.RecycleBinCleanupEnabled + RecycleBinRetentionPeriod = $WebApplication.RecycleBinRetentionPeriod + SecondStageRecycleBinQuota = $WebApplication.SecondStageRecycleBinQuota + MaximumUploadSize = $WebApplication.MaximumFileSize + CustomerExperienceProgram = $WebApplication.BrowserCEIPEnabled + PresenceEnabled = $WebApplication.PresenceEnabled + } +} + +function Set-xSPWebApplicationGeneralSettings { + [CmdletBinding()] + param( + [parameter(Mandatory = $true)] $WebApplication, + [parameter(Mandatory = $true)] $Settings + ) + + if ($Settings.TimeZone -ne $null) { $WebApplication.DefaultTimeZone = $Settings.TimeZone } + if ($Settings.Alerts -ne $null) { $WebApplication.AlertsEnabled = $Settings.Alerts } + if ($Settings.AlertsLimit -ne $null) { $WebApplication.AlertsMaximum = $Settings.AlertsLimit } + if ($Settings.RSS -ne $null) { $WebApplication.SyndicationEnabled = $Settings.RSS } + if ($Settings.AlertsLimit) { $WebApplication.MetaWeblogEnabled = $Settings.BlogAPI } + if ($Settings.BlogAPIAuthenticated) { $WebApplication.MetaWeblogAuthenticationEnabled = $Settings.BlogAPIAuthenticated } + if ($Settings.BrowserFileHandling) { $WebApplication.BrowserFileHandling = $Settings.BrowserFileHandling } + if ($Settings.SecurityValidation) { $WebApplication.FormDigestSettings.Enabled = $Settings.SecurityValidation } + if ($Settings.MaximumUploadSize) { $WebApplication.MaximumFileSize = $Settings.MaximumUploadSize } + if ($Settings.RecycleBinEnabled) { $WebApplication.RecycleBinEnabled = $Settings.RecycleBinEnabled } + if ($Settings.RecycleBinCleanupEnabled) { $WebApplication.RecycleBinCleanupEnabled = $Settings.RecycleBinCleanupEnabled } + if ($Settings.RecycleBinRetentionPeriod) { $WebApplication.RecycleBinRetentionPeriod = $Settings.RecycleBinRetentionPeriod } + if ($Settings.SecondStageRecycleBinQuota) { $WebApplication.SecondStageRecycleBinQuota = $Settings.SecondStageRecycleBinQuota } + if ($Settings.CustomerExperienceProgram) { $WebApplication.BrowserCEIPEnabled = $Settings.CustomerExperienceProgram } + if ($Settings.Presence -ne $null) { $WebApplication.PresenceEnabled = $Settings.Presence } +} + +function Test-xSPWebApplicationGeneralSettings { + [CmdletBinding()] + [OutputType([System.Boolean])] + param( + [parameter(Mandatory = $true)] $CurrentSettings, + [parameter(Mandatory = $true)] $DesiredSettings + ) + +} + From 8c8e00706db5b1555fbc94a1c642439585ee41c3 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 18:05:53 +1100 Subject: [PATCH 085/147] Added throttling specific tests for xSPWebApplication --- .../MSFT_xSPWebApplication.Set.ps1 | 131 -------------- .../MSFT_xSPWebApplication.psm1 | 5 - .../xSPWebApplication.BlockedFileTypes.psm1 | 16 +- .../xSPWebApplication.GeneralSettings.psm1 | 34 ++-- .../xSPWebApplication.Throttling.psm1 | 33 ++-- .../xSPWebApplication.Workflow.psm1 | 6 +- .../xSharePoint.xSPWebApplication.Tests.ps1 | 160 +----------------- 7 files changed, 46 insertions(+), 339 deletions(-) delete mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 deleted file mode 100644 index d855f9275..000000000 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 +++ /dev/null @@ -1,131 +0,0 @@ -function Set-BlockedFiles($blockedFiles, $wa) -{ - - if($blockedFiles -eq $null){return;} - if($blockedFiles.Blocked -ne $null ){ - $wa.BlockedFileExtensions.Clear(); - $blockedFiles.Blocked| % { - $wa.BlockedFileExtensions.Add($_) ; - - } - } - if($blockedFiles.EnsureBlocked -ne $null){ - $blockedFiles.EnsureBlocked| % { - if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; - } - } - } - if($blockedFiles.EnsureAllowed -ne $null){ - $blockedFiles.EnsureAllowed | % { - if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) - } - } - } - -} -function Get-ValueOrDefault($input, $attribute, $defaultValue) -{ - try{ - if($input."$attribute" -ne $null) - { - return $input."$attribute" - }else { - return $defaultValue - } - }catch - { - return $defaultValue - } -} -function Set-GeneralSettings($generalSettings, $wa) -{ - if($generalSettings -eq $null){ return;} - - #TODO: Quota Template - $wa.DefaultTimeZone =Get-ValueOrDefault $generalSettings "TimeZone" $wa.DefaultTimeZone - $wa.AlertsEnabled = Get-ValueOrDefault $generalSettings "Alerts" $wa.AlertsEnabled - $wa.AlertsMaximum = Get-ValueOrDefault $generalSettings "AlertsLimit" $wa.AlertsMaximum - $wa.SyndicationEnabled = Get-ValueOrDefault $generalSettings "RSS" $wa.RSS - $wa.MetaWeblogEnabled = Get-ValueOrDefault $generalSettings "BlogAPI" $wa.BlogAPI - $wa.MetaWeblogAuthenticationEnabled = Get-ValueOrDefault $generalSettings "BlogAPIAuthenticated" $wa.BlogAPIAuthenticated - $wa.BrowserFileHandling = Get-ValueOrDefault $generalSettings "BrowserFileHandling" $wa.BrowserFileHandling - $wa.FormDigestSettings.Enabled = Get-ValueOrDefault $generalSettings "SecurityValidation" $wa.FormDigestSettings.Enabled - $wa.MaximumFileSize = Get-ValueOrDefault $generalSettings "MaximumUploadSize" $wa.MaximumUploadSize - $wa.RecycleBinEnabled = Get-ValueOrDefault $generalSettings "RecycleBinEnabled" $wa.RecycleBinEnabled - $wa.RecycleBinCleanupEnabled = Get-ValueOrDefault $generalSettings "RecycleBinCleanupEnabled" $wa.RecycleBinCleanupEnabled - $wa.RecycleBinRetentionPeriod = Get-ValueOrDefault $generalSettings "RecycleBinRetentionPeriod" $wa.RecycleBinRetentionPeriod - $wa.SecondStageRecycleBinQuota = Get-ValueOrDefault $generalSettings "SecondStageRecycleBinEnabled" $wa.SecondStageRecycleBinQuota - $wa.BrowserCEIPEnabled = Get-ValueOrDefault $generalSettings "CustomerExperienceProgram" $wa.BrowserCEIPEnabled - $wa.PresenceEnabled = Get-ValueOrDefault $generalSettings "Presence" $wa.BrowserCEIPEnabled - $wa.Update(); -} -function Set-WorkflowSettings ($workflowSettings, $wa) -{ - if($workflowSettings -eq $null ){ return;} - if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ - $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; - } - if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ - $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; - } - if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ - $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; - } - - $wa.UpdateWorkflowConfigurationSettings(); - $wa.Update(); -} - -function GetAndRemove-Parameter($params, $name){ - $result =$null - if($params.ContainsKey($name)) - { - $result = $params.$name - $params.Remove( $name) - } - return $result; -} -function Sanitize-ComplexTypes{ - param( - [Parameter(Position = 0)] - - $params - ) - -$blocked =GetAndRemove-Parameter $params "BlockedFileTypes" - return @{ - GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" - WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" - Extensions = GetAndRemove-Parameter $params "Extensions" - ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" - BlockedFileTypes = $blocked - } -} - - -$params = $args[0] - -$settings = Sanitize-ComplexTypes $params - -$wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue -if ($null -eq $wa) { - if ($params.ContainsKey("AuthenticationMethod") -eq $true) { - if ($params.AuthenticationMethod -eq "NTLM") { - $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos - } else { - $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication - } - $params.Remove("AuthenticationMethod") - $params.Add("AuthenticationProvider", $ap) - } - - if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } - if ($params.ContainsKey("AllowAnonymous")) { - $params.Remove("AllowAnonymous") | Out-Null - $params.Add("AllowAnonymousAccess", $true) - } - - $wa = New-SPWebApplication @params -} \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 9bda4569c..6aee1db55 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -85,15 +85,10 @@ function Set-TargetResource [parameter(Mandatory = $false)] $BlockedFileTypes ) - Write-Verbose -Message "Creating web application '$Name'" - $settings = Sanitize-ComplexTypes $PSBoundParameters - $PSBoundParameters.Add("Settings", $settings) Write-Verbose -Message "Creating web application '$Name'" $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $settings =$params.Settings - $params.Remove("Settings") | Out-Null $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { $newWebAppParams = @{ diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 index 2ede67189..5e818f783 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -18,31 +18,31 @@ function Set-xSPWebApplicationBlockedFileTypes { [parameter(Mandatory = $true)] $Settings ) - if ($Settings.Blocked -ne $null -and (($Settings.EnsureBlocked -ne $null) -or ($Settings.EnsureAllowed -ne $null))) { + if ($Settings.ContainsKey("Blocked") -eq $true -and (($Settings.ContainsKey("EnsureBlocked") -eq $true) -or ($Settings.ContainsKey("EnsureAllowed") -eq $true))) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } - if ($Settings.Blocked -eq $null -and $Settings.EnsureBlocked -eq $null -and $Settings.EnsureAllowed -eq $null) { + if ($Settings.ContainsKey("Blocked") -eq $false -and $Settings.ContainsKey("EnsureBlocked") -eq $false -and $Settings.ContainsKey("EnsureAllowed") -eq $false) { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if($Settings.Blocked -ne $null ){ + if($Settings.ContainsKey("Blocked") -ne $null ) { $WebApplication.BlockedFileExtensions.Clear(); - $blockedFiles.Blocked | ForEach-Object { + $Settings.Blocked | ForEach-Object { $WebApplication.BlockedFileExtensions.Add($_); } } - if($Settings.EnsureBlocked -ne $null){ - $blockedFiles.EnsureBlocked | ForEach-Object { + if($Settings.ContainsKey("EnsureBlocked") -ne $null) { + $Settings.EnsureBlocked | ForEach-Object { if(!$WebApplication.BlockedFileExtensions.ContainExtension($_)){ $WebApplication.BlockedFileExtensions.Add($_); } } } - if($Settings.EnsureAllowed -ne $null){ - $blockedFiles.EnsureAllowed | ForEach-Object { + if($Settings.ContainsKey("EnsureAllowed") -ne $null) { + $Settings.EnsureAllowed | ForEach-Object { if($WebApplication.BlockedFileExtensions.ContainExtension($_)){ $WebApplication.BlockedFileExtensions.Remove($_); } diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 index b5306661f..96653a71f 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 @@ -31,21 +31,21 @@ function Set-xSPWebApplicationGeneralSettings { [parameter(Mandatory = $true)] $Settings ) - if ($Settings.TimeZone -ne $null) { $WebApplication.DefaultTimeZone = $Settings.TimeZone } - if ($Settings.Alerts -ne $null) { $WebApplication.AlertsEnabled = $Settings.Alerts } - if ($Settings.AlertsLimit -ne $null) { $WebApplication.AlertsMaximum = $Settings.AlertsLimit } - if ($Settings.RSS -ne $null) { $WebApplication.SyndicationEnabled = $Settings.RSS } - if ($Settings.AlertsLimit) { $WebApplication.MetaWeblogEnabled = $Settings.BlogAPI } - if ($Settings.BlogAPIAuthenticated) { $WebApplication.MetaWeblogAuthenticationEnabled = $Settings.BlogAPIAuthenticated } - if ($Settings.BrowserFileHandling) { $WebApplication.BrowserFileHandling = $Settings.BrowserFileHandling } - if ($Settings.SecurityValidation) { $WebApplication.FormDigestSettings.Enabled = $Settings.SecurityValidation } - if ($Settings.MaximumUploadSize) { $WebApplication.MaximumFileSize = $Settings.MaximumUploadSize } - if ($Settings.RecycleBinEnabled) { $WebApplication.RecycleBinEnabled = $Settings.RecycleBinEnabled } - if ($Settings.RecycleBinCleanupEnabled) { $WebApplication.RecycleBinCleanupEnabled = $Settings.RecycleBinCleanupEnabled } - if ($Settings.RecycleBinRetentionPeriod) { $WebApplication.RecycleBinRetentionPeriod = $Settings.RecycleBinRetentionPeriod } - if ($Settings.SecondStageRecycleBinQuota) { $WebApplication.SecondStageRecycleBinQuota = $Settings.SecondStageRecycleBinQuota } - if ($Settings.CustomerExperienceProgram) { $WebApplication.BrowserCEIPEnabled = $Settings.CustomerExperienceProgram } - if ($Settings.Presence -ne $null) { $WebApplication.PresenceEnabled = $Settings.Presence } + if ($Settings.ContainsKey("TimeZone") -eq $true) { $WebApplication.DefaultTimeZone = $Settings.TimeZone } + if ($Settings.ContainsKey("Alerts") -eq $true) { $WebApplication.AlertsEnabled = $Settings.Alerts } + if ($Settings.ContainsKey("AlertsLimit") -eq $true) { $WebApplication.AlertsMaximum = $Settings.AlertsLimit } + if ($Settings.ContainsKey("RSS") -eq $true) { $WebApplication.SyndicationEnabled = $Settings.RSS } + if ($Settings.ContainsKey("AlertsLimit") -eq $true) { $WebApplication.MetaWeblogEnabled = $Settings.BlogAPI } + if ($Settings.ContainsKey("BlogAPIAuthenticated") -eq $true) { $WebApplication.MetaWeblogAuthenticationEnabled = $Settings.BlogAPIAuthenticated } + if ($Settings.ContainsKey("BrowserFileHandling") -eq $true) { $WebApplication.BrowserFileHandling = $Settings.BrowserFileHandling } + if ($Settings.ContainsKey("SecurityValidation") -eq $true) { $WebApplication.FormDigestSettings.Enabled = $Settings.SecurityValidation } + if ($Settings.ContainsKey("MaximumUploadSize") -eq $true) { $WebApplication.MaximumFileSize = $Settings.MaximumUploadSize } + if ($Settings.ContainsKey("RecycleBinEnabled") -eq $true) { $WebApplication.RecycleBinEnabled = $Settings.RecycleBinEnabled } + if ($Settings.ContainsKey("RecycleBinCleanupEnabled") -eq $true) { $WebApplication.RecycleBinCleanupEnabled = $Settings.RecycleBinCleanupEnabled } + if ($Settings.ContainsKey("RecycleBinRetentionPeriod") -eq $true) { $WebApplication.RecycleBinRetentionPeriod = $Settings.RecycleBinRetentionPeriod } + if ($Settings.ContainsKey("SecondStageRecycleBinQuota") -eq $true) { $WebApplication.SecondStageRecycleBinQuota = $Settings.SecondStageRecycleBinQuota } + if ($Settings.ContainsKey("CustomerExperienceProgram") -eq $true) { $WebApplication.BrowserCEIPEnabled = $Settings.CustomerExperienceProgram } + if ($Settings.ContainsKey("Presence") -eq $true) { $WebApplication.PresenceEnabled = $Settings.Presence } } function Test-xSPWebApplicationGeneralSettings { @@ -55,6 +55,8 @@ function Test-xSPWebApplicationGeneralSettings { [parameter(Mandatory = $true)] $CurrentSettings, [parameter(Mandatory = $true)] $DesiredSettings ) - + $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` + -DesiredValues $DesiredSettings + return $testReturn } diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 index 5e134eeaf..aec19d95b 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -30,49 +30,48 @@ function Set-xSPWebApplicationThrottlingSettings { [parameter(Mandatory = $true)] $Settings ) - if($Settings.ListViewThreshold -ne $null ){ + if($Settings.ContainsKey("ListViewThreshold") -eq $true) { $WebApplication.MaxItemsPerThrottledOperation = $Settings.ListViewThreshold } - if($Settings.AllowObjectModelOverride -ne $null){ + if($Settings.ContainsKey("AllowObjectModelOverride") -eq $true) { $WebApplication.AllowOMCodeOverrideThrottleSettings = $Settings.AllowObjectModelOverride } - if($Settings.AdminThreshold -ne $null){ + if($Settings.ContainsKey("AdminThreshold") -eq $true) { $WebApplication.MaxItemsPerThrottledOperationOverride = $Settings.AdminThreshold } - if($Settings.ListViewLookupThreshold -ne $null){ + if($Settings.ContainsKey("ListViewLookupThreshold") -eq $true) { $WebApplication.MaxQueryLookupFields = $Settings.ListViewLookupThreshold } - if($Settings.HappyHourEnabled -ne $null){ + if($Settings.ContainsKey("HappyHourEnabled") -eq $true) { $WebApplication.UnthrottledPrivilegedOperationWindowEnabled =$Settings.HappyHourEnabled } - if($Settings.HappyHour -ne $null){ - $happyHour =$Settings.HappyHour; + if($Settings.ContainsKey("HappyHour") -eq $true) { + $happyHour = $Settings.HappyHour; if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ $WebApplication.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour $WebApplication.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute $WebApplication.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration - }else{ + } else { throw "the valid hour, minute and duration range is 0-24"; - } - - }else { + } + } else { throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; } } - if($Settings.UniquePermissionThreshold){ + if($Settings.ContainsKey("UniquePermissionThreshold") -eq $true) { $WebApplication.MaxUniquePermScopesPerList = $Settings.UniquePermissionThreshold } - if($Settings.EventHandlersEnabled){ + if($Settings.ContainsKey("EventHandlersEnabled") -eq $true) { $WebApplication.EventHandlersEnabled = $Settings.EventHandlersEnabled } - if($Settings.RequestThrottling){ + if($Settings.ContainsKey("RequestThrottling") -eq $true) { $WebApplication.HttpThrottleSettings.PerformThrottle = $Settings.RequestThrottling } - if($Settings.ChangeLogEnabled){ + if($Settings.ContainsKey("ChangeLogEnabled") -eq $true) { $WebApplication.ChangeLogExpirationEnabled = $Settings.ChangeLogEnabled } - if($Settings.ChangeLogExpiryDays){ + if($Settings.ContainsKey("ChangeLogExpiryDays") -eq $true) { $WebApplication.ChangeLogRetentionPeriod = New-TimeSpan -Days $Settings.ChangeLogExpiryDays } } @@ -100,7 +99,7 @@ function Test-xSPWebApplicationThrottlingSettings { "EventHandlersEnabled" ) if ($testReturn -eq $true) { - if ($Settings.ContainsKey("HappyHour") -eq $true) { + if ($DesiredSettings.ContainsKey("HappyHour") -eq $true) { $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings.HappyHour ` -DesiredValues $DesiredSettings.HappyHour } diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 index 411461f45..ddd1ef759 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 @@ -17,13 +17,13 @@ function Set-xSPWebApplicationWorkflowSettings { [parameter(Mandatory = $true)] $WebApplication, [parameter(Mandatory = $true)] $Settings ) - if($Settings.UserDefinedWorkflowsEnabled -ne $null){ + if($Settings.ContainsKey("UserDefinedWorkflowsEnabled") -eq $true) { $WebApplication.UserDefinedWorkflowsEnabled = $Settings.UserDefinedWorkflowsEnabled; } - if($Settings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ + if($Settings.ContainsKey("EmailToNoPermissionWorkflowParticipantsEnable") -eq $true) { $WebApplication.EmailToNoPermissionWorkflowParticipantsEnabled = $Settings.EmailToNoPermissionWorkflowParticipantsEnable; } - if($Settings.ExternalWorkflowParticipantsEnabled -ne $null){ + if($Settings.ContainsKey("ExternalWorkflowParticipantsEnabled") -eq $true) { $WebApplication.ExternalWorkflowParticipantsEnabled = $Settings.ExternalWorkflowParticipantsEnabled; } $WebApplication.UpdateWorkflowConfigurationSettings(); diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 3ce3df3e4..22f1e0493 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -15,7 +15,7 @@ Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName Describe "xSPWebApplication" { InModuleScope $ModuleName { $testParams = @{ - Name = "Managed Metadata Service App" + Name = "SharePoint Sites" ApplicationPool = "SharePoint Web Apps" ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" @@ -151,163 +151,5 @@ Describe "xSPWebApplication" { Test-TargetResource @testParams | Should Be $true } } - - - - $testParams = @{ - Name = "Complex types Web App" - ApplicationPool = "SharePoint complex type Web App" - ApplicationPoolAccount = "DEMO\ServiceAccount" - Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = @{ - Blocked = @("java", "vbs", "exe","xxx") - EnsureBlocked = @("java", "rar", "exe","xxx") - EnsureAllowed = @("exe", "vbs","zip") - } - WorkflowSettings = @{ - ExternalWorkflowParticipantsEnabled=$false - UserDefinedWorkflowsEnabled=$true - EmailToNoPermissionWorkflowParticipantsEnable=$false - } - ThrottlingSettings = @{ - ListViewThreshold = 10000 - AllowObjectModelOverride = $true - AdminThreshold=55000 - ListViewLookupThreshold=10 - HappyHourEnabled= $true - HappyHour = @{ - Hour = 20 - Minute = 5 - Duration = 2 - } - UniquePermissionThreshold = 133000 - RequestThrottling=$false - ChangeLogEnabled=$true - ChangeLogExpiryDays = 19 - EventHandlersEnabled=$true - } - GeneralSettings=@{ - TimeZone = 10 - DefaultQuotaTemplate = "" - Alerts = $true - AlertsLimit = 10 - RSS = $true - BlogAPI = $true - BlogAPIAuthenticated = $true - BrowserFileHandling = "Permissive" - SecurityValidation = $true - RecycleBinEnabled = $true - SecondStageRecycleBinEnabled = $true - RecycleBinCleanupEnabled = $true - RecycleBinRetentionPeriod = 10 - SecondStageRecycleBinQuota = 500 - MaximumUploadSize = 555 - CustomerExperienceProgram = $true - PresenceEnabled = $true - } - - } - - Context "set target resorce works with complex types filled in" { - Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } - - $mockedapp= { - $result= @(@{ - DisplayName = $testParams.Name - ApplicationPool = @{ - Name = $testParams.ApplicationPool - Username = $testParams.ApplicationPoolAccount - } - ContentDatabases = @( - @{ - Name = "SP_Content_01" - Server = "sql.domain.local" - } - ) - IisSettings = @( - @{ Path = "C:\inetpub\wwwroot\something" } - ) - Url = $testParams.Url - MaxItemsPerThrottledOperation=5000 - AllowOMCodeOverrideThrottleSettings=$true - MaxItemsPerThrottledOperationOverride = 10000 - MaxQueryLookupFields = 8 - UnthrottledPrivilegedOperationWindowEnabled =$true - DailyStartUnthrottledPrivilegedOperationsHour = $null - DailyStartUnthrottledPrivilegedOperationsMinute = $null - DailyUnthrottledPrivilegedOperationsDuration = $null - - MaxUniquePermScopesPerList = 50000 - EventHandlersEnabled = $true - HttpThrottleSettings = @{ - PerformThrottle = $true - } - FormDigestSettings = @{ - Enabled =$true - } - ChangeLogExpirationEnabled = $true - ChangeLogRetentionPeriod = New-TimeSpan -Days 10 - }) - - $result= $result | Add-Member ScriptMethod UpdateWorkflowConfigurationSettings { - $Global:UpdateWorkflowCalled = $true; - } -PassThru - - $blockedFileTypes = new-object PSObject - - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Remove { - $Global:BlockedFilesRemoveCalled = $true; - return $true; - } -passThru - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { - $Global:BlockedFilesClearCalled = $true; - return $true; - } -passThru - - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod ContainExtension { - - param($extension) - $Global:BlockedFilesContainsCalled = $true; - if($extension -eq "exe"){ - return $true - } - return $false - - } -passThru - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { - param( [string]$fileType) - $Global:BlockedFilesAddCalled = $true; - return $true; - } -passThru - - $result=$result| Add-Member ScriptMethod Update { - $Global:SPWebApplicationUpdateCalled = $true; - return $true; - } -PassThru - $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru - return $result - } - Mock Get-SPWebApplication $mockedapp - Mock New-SPWebApplication $mockedapp - - It "calls the new cmdlet from the set method and does update blockedFileExtensions" { - $Global:BlockedFilesAddCalled = $false; - $Global:BlockedFilesClearCalled = $false; - $Global:BlockedFilesRemoveCalled = $false; - $Global:BlockedFilesContainsCalled = $false; - $Global:SPWebApplicationUpdateCalled =$false ; - Set-TargetResource @testParams - $Global:BlockedFilesAddCalled| Should be $true; - $Global:BlockedFilesContainsCalled| Should be $true; - $Global:SPWebApplicationUpdateCalled| Should be $true; - $Global:BlockedFilesRemoveCalled| Should be $true; - - Assert-MockCalled Get-SPWebApplication - } - - } - - } } \ No newline at end of file From aac5c9b8e58459b7cd48b384b6cefda811f21acb Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 18:06:18 +1100 Subject: [PATCH 086/147] Added file missing from last check-in --- ...int.xSPWebApplication.Throttling.Tests.ps1 | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 new file mode 100644 index 000000000..0a8c9e7f7 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -0,0 +1,144 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPWebApplication" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPWebApplication (Throttling)" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + ThrottlingSettings = @{ + ListViewThreshold = 1000 + AllowObjectModelOverride = $true + AdminThreshold = 2000 + ListViewLookupThreshold = 12 + HappyHourEnabled = $true + HappyHour = @{ + Hour = 2 + Minute = 0 + Duration = 60 + } + UniquePermissionThreshold = 100 + RequestThrottling = $true + ChangeLogEnabled = $true + ChangeLogExpiryDays = 30 + EventHandlersEnabled = $true + } + } + + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Mock New-SPAuthenticationProvider { } + Mock New-SPWebApplication { } + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $true; AllowAnonymous = $false } } + + Context "The web appliation exists and uses incorrect throttling settings" { + Mock Get-SPWebApplication { return @(@{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + MaxItemsPerThrottledOperation = 1 + AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride + MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold + MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold + UnthrottledPrivilegedOperationWindowEnabled = $testParams.ThrottlingSettings.HappyHourEnabled + DailyStartUnthrottledPrivilegedOperationsHour = $testParams.ThrottlingSettings.HappyHour.Hour + DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.ThrottlingSettings.HappyHour.Minute + DailyUnthrottledPrivilegedOperationsDuration = $testParams.ThrottlingSettings.HappyHour.Duration + MaxUniquePermScopesPerList = $testParams.ThrottlingSettings.UniquePermissionThreshold + HttpThrottleSettings = @{ + PerformThrottle = $testParams.ThrottlingSettings.RequestThrottling + } + ChangeLogExpirationEnabled = $testParams.ThrottlingSettings.ChangeLogEnabled + ChangeLogRetentionPeriod = @{ + Days = $testParams.ThrottlingSettings.ChangeLogExpiryDays + } + EventHandlersEnabled = $testParams.ThrottlingSettings.EventHandlersEnabled + })} + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $false + } + } + + Context "The web appliation exists and has the correct settings" { + Mock Get-SPWebApplication { return @(@{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + MaxItemsPerThrottledOperation = $testParams.ThrottlingSettings.ListViewThreshold + AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride + MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold + MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold + UnthrottledPrivilegedOperationWindowEnabled = $testParams.ThrottlingSettings.HappyHourEnabled + DailyStartUnthrottledPrivilegedOperationsHour = $testParams.ThrottlingSettings.HappyHour.Hour + DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.ThrottlingSettings.HappyHour.Minute + DailyUnthrottledPrivilegedOperationsDuration = $testParams.ThrottlingSettings.HappyHour.Duration + MaxUniquePermScopesPerList = $testParams.ThrottlingSettings.UniquePermissionThreshold + HttpThrottleSettings = @{ + PerformThrottle = $testParams.ThrottlingSettings.RequestThrottling + } + ChangeLogExpirationEnabled = $testParams.ThrottlingSettings.ChangeLogEnabled + ChangeLogRetentionPeriod = @{ + Days = $testParams.ThrottlingSettings.ChangeLogExpiryDays + } + EventHandlersEnabled = $testParams.ThrottlingSettings.EventHandlersEnabled + })} + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + } +} \ No newline at end of file From 68143ce95ab77b557278545cfd28c7addb579b20 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 18:59:00 +1100 Subject: [PATCH 087/147] Fixed throttling tests --- .../xSPWebApplication.Throttling.psm1 | 21 ++- ...int.xSPWebApplication.Throttling.Tests.ps1 | 176 ++++++++++++++---- 2 files changed, 150 insertions(+), 47 deletions(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 index aec19d95b..e9f241ba8 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -47,16 +47,19 @@ function Set-xSPWebApplicationThrottlingSettings { } if($Settings.ContainsKey("HappyHour") -eq $true) { $happyHour = $Settings.HappyHour; - if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ - if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ - $WebApplication.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour - $WebApplication.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute - $WebApplication.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration - } else { - throw "the valid hour, minute and duration range is 0-24"; - } + if ($happyHour.ContainsKey("Hour") -eq $false -or $happyHour.ContainsKey("Minute") -eq $false -or $happyHour.ContainsKey("Duration") -eq $false) { + throw "Happy hour settings must include 'hour', 'minute' and 'duration'" } else { - throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; + if ($happyHour.Hour -lt 0 -or $happyHour.Hour -gt 23) { + throw "Happy hour setting 'hour' must be between 0 and 23" + } + if ($happyHour.Minute -lt 0 -or $happyHour.Minute -gt 59) { + throw "Happy hour setting 'minute' must be between 0 and 59" + } + if ($happyHour.Duration -lt 0 -or $happyHour.Duration -gt 23) { + throw "Happy hour setting 'hour' must be between 0 and 23" + } + $WebApplication.SetDailyUnthrottledPrivilegedOperationWindow($happyHour.Hour, $happyHour.Minute, $happyHour.Duration) } } if($Settings.ContainsKey("UniquePermissionThreshold") -eq $true) { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index 0a8c9e7f7..ad530150b 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -29,7 +29,7 @@ Describe "xSPWebApplication (Throttling)" { HappyHour = @{ Hour = 2 Minute = 0 - Duration = 60 + Duration = 1 } UniquePermissionThreshold = 100 RequestThrottling = $true @@ -51,7 +51,7 @@ Describe "xSPWebApplication (Throttling)" { Mock New-SPWebApplication { } Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $true; AllowAnonymous = $false } } - Context "The web appliation exists and uses incorrect throttling settings" { + Context "The web appliation exists and has the correct throttling settings" { Mock Get-SPWebApplication { return @(@{ DisplayName = $testParams.Name ApplicationPool = @{ @@ -68,7 +68,7 @@ Describe "xSPWebApplication (Throttling)" { @{ Path = "C:\inetpub\wwwroot\something" } ) Url = $testParams.Url - MaxItemsPerThrottledOperation = 1 + MaxItemsPerThrottledOperation = $testParams.ThrottlingSettings.ListViewThreshold AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold @@ -92,52 +92,152 @@ Describe "xSPWebApplication (Throttling)" { } It "returns true from the test method" { - Test-TargetResource @testParams | Should Be $false + Test-TargetResource @testParams | Should Be $true } } - Context "The web appliation exists and has the correct settings" { - Mock Get-SPWebApplication { return @(@{ - DisplayName = $testParams.Name - ApplicationPool = @{ - Name = $testParams.ApplicationPool - Username = $testParams.ApplicationPoolAccount - } - ContentDatabases = @( - @{ - Name = "SP_Content_01" - Server = "sql.domain.local" + Context "The web appliation exists and uses incorrect throttling settings" { + Mock Get-SPWebApplication { + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount } - ) - IisSettings = @( - @{ Path = "C:\inetpub\wwwroot\something" } - ) - Url = $testParams.Url - MaxItemsPerThrottledOperation = $testParams.ThrottlingSettings.ListViewThreshold - AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride - MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold - MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold - UnthrottledPrivilegedOperationWindowEnabled = $testParams.ThrottlingSettings.HappyHourEnabled - DailyStartUnthrottledPrivilegedOperationsHour = $testParams.ThrottlingSettings.HappyHour.Hour - DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.ThrottlingSettings.HappyHour.Minute - DailyUnthrottledPrivilegedOperationsDuration = $testParams.ThrottlingSettings.HappyHour.Duration - MaxUniquePermScopesPerList = $testParams.ThrottlingSettings.UniquePermissionThreshold - HttpThrottleSettings = @{ - PerformThrottle = $testParams.ThrottlingSettings.RequestThrottling - } - ChangeLogExpirationEnabled = $testParams.ThrottlingSettings.ChangeLogEnabled - ChangeLogRetentionPeriod = @{ - Days = $testParams.ThrottlingSettings.ChangeLogExpiryDays + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + MaxItemsPerThrottledOperation = 1 + AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride + MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold + MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold + UnthrottledPrivilegedOperationWindowEnabled = $testParams.ThrottlingSettings.HappyHourEnabled + DailyStartUnthrottledPrivilegedOperationsHour = $testParams.ThrottlingSettings.HappyHour.Hour + DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.ThrottlingSettings.HappyHour.Minute + DailyUnthrottledPrivilegedOperationsDuration = $testParams.ThrottlingSettings.HappyHour.Duration + MaxUniquePermScopesPerList = $testParams.ThrottlingSettings.UniquePermissionThreshold + HttpThrottleSettings = @{ + PerformThrottle = $testParams.ThrottlingSettings.RequestThrottling + } + ChangeLogExpirationEnabled = $testParams.ThrottlingSettings.ChangeLogEnabled + ChangeLogRetentionPeriod = @{ + Days = $testParams.ThrottlingSettings.ChangeLogExpiryDays + } + EventHandlersEnabled = $testParams.ThrottlingSettings.EventHandlersEnabled } - EventHandlersEnabled = $testParams.ThrottlingSettings.EventHandlersEnabled - })} + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru | Add-Member ScriptMethod SetDailyUnthrottledPrivilegedOperationWindow { + $Global:xSPWebApplicationUpdateHappyHourCalled = $true + } -PassThru + return @($webApp) + } It "returns the current data from the get method" { Get-TargetResource @testParams | Should Not BeNullOrEmpty } It "returns true from the test method" { - Test-TargetResource @testParams | Should Be $true + Test-TargetResource @testParams | Should Be $false + } + + $Global:xSPWebApplicationUpdateCalled = $false + $Global:xSPWebApplicationUpdateHappyHourCalled = $false + It "updates the throttling settings" { + Set-TargetResource @testParams + $Global:xSPWebApplicationUpdateCalled | Should Be $true + } + + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + ThrottlingSettings = @{ + ListViewThreshold = 1000 + AllowObjectModelOverride = $true + AdminThreshold = 2000 + ListViewLookupThreshold = 12 + HappyHourEnabled = $true + HappyHour = @{ + Hour = 5 + Minute = 0 + Duration = 1 + } + UniquePermissionThreshold = 100 + RequestThrottling = $true + ChangeLogEnabled = $true + ChangeLogExpiryDays = 30 + EventHandlersEnabled = $true + } + } + $Global:xSPWebApplicationUpdateCalled = $false + $Global:xSPWebApplicationUpdateHappyHourCalled = $false + It "updates the incorrect happy hour settings" { + Set-TargetResource @testParams + $Global:xSPWebApplicationUpdateCalled | Should Be $true + $Global:xSPWebApplicationUpdateHappyHourCalled | Should Be $true + } + + it "throws exceptions where invalid happy hour settings are provided" { + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + ThrottlingSettings = @{ + HappyHourEnabled = $true + HappyHour = @{ + Hour = 100 + Minute = 0 + Duration = 1 + } + } + } + { Set-TargetResource @testParams } | Should throw + + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + ThrottlingSettings = @{ + HappyHourEnabled = $true + HappyHour = @{ + Hour = 5 + Minute = 100 + Duration = 1 + } + } + } + { Set-TargetResource @testParams } | Should throw + + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + ThrottlingSettings = @{ + HappyHourEnabled = $true + HappyHour = @{ + Hour = 5 + Minute = 0 + Duration = 100 + } + } + } + { Set-TargetResource @testParams } | Should throw } } } From b3b3132b18a0b00b967b7a1ca3ee1f778abc5bf7 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 18:59:58 +1100 Subject: [PATCH 088/147] Saved VS project files --- Modules/xSharePoint/xSharePoint.pssproj | 1 + Tests/Tests.pssproj | 1 + 2 files changed, 2 insertions(+) diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 3abbaebe6..d0d73181d 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -139,6 +139,7 @@ + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 1ebcfcde5..770e01c86 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -72,6 +72,7 @@ + From b5f2c228ad5a6c39e38cc3fb1789c428bfc2d845 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 19:22:38 +1100 Subject: [PATCH 089/147] Added workflow tests for xSPWebApplication --- .../MSFT_xSPWebApplication.psm1 | 2 +- Tests/Tests.pssproj | 1 + ...int.xSPWebApplication.Throttling.Tests.ps1 | 2 +- ...Point.xSPWebApplication.Workflow.Tests.ps1 | 120 ++++++++++++++++++ 4 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 6aee1db55..30437f8b4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -126,7 +126,7 @@ function Set-TargetResource # Workflow settings if ($params.ContainsKey("WorkflowSettings") -eq $true) { Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - Set-xSPWebApplicationWorkflowSettings -WebApplication $wa -Settings $params.ThrottlingSettings + Set-xSPWebApplicationWorkflowSettings -WebApplication $wa -Settings $params.WorkflowSettings } # Blocked file types diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 770e01c86..a7de00f9a 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -72,6 +72,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index ad530150b..512586772 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -144,7 +144,7 @@ Describe "xSPWebApplication (Throttling)" { Get-TargetResource @testParams | Should Not BeNullOrEmpty } - It "returns true from the test method" { + It "returns false from the test method" { Test-TargetResource @testParams | Should Be $false } diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 new file mode 100644 index 000000000..e80dd9148 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 @@ -0,0 +1,120 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPWebApplication" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPWebApplication (Workflow)" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + WorkflowSettings = @{ + ExternalWorkflowParticipantsEnabled = $true + UserDefinedWorkflowsEnabled = $true + EmailToNoPermissionWorkflowParticipantsEnable = $true + } + } + + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Mock New-SPAuthenticationProvider { } + Mock New-SPWebApplication { } + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $true; AllowAnonymous = $false } } + + Context "The web appliation exists and has the correct workflow settings" { + Mock Get-SPWebApplication { return @(@{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + UserDefinedWorkflowsEnabled = $true + EmailToNoPermissionWorkflowParticipantsEnabled = $true + ExternalWorkflowParticipantsEnabled = $true + })} + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "The web appliation exists and uses incorrect workflow settings" { + Mock Get-SPWebApplication { + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + UserDefinedWorkflowsEnabled = $false + EmailToNoPermissionWorkflowParticipantsEnabled = $false + ExternalWorkflowParticipantsEnabled = $false + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru | Add-Member ScriptMethod UpdateWorkflowConfigurationSettings { + $Global:xSPWebApplicationUpdateWorkflowCalled = $true + } -PassThru + return @($webApp) + } + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + $Global:xSPWebApplicationUpdateCalled = $false + $Global:xSPWebApplicationUpdateWorkflowCalled = $false + It "updates the workflow settings" { + Set-TargetResource @testParams + $Global:xSPWebApplicationUpdateCalled | Should Be $true + $Global:xSPWebApplicationUpdateWorkflowCalled | Should Be $true + } + } + } +} \ No newline at end of file From 5432b14cd81bf38a978bd2875f04372d432e5592 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 21:28:23 +1100 Subject: [PATCH 090/147] Added test for blocked file types on xSPWEbApplication --- .../MSFT_xSPWebApplication.psm1 | 4 +- .../xSPWebApplication.BlockedFileTypes.psm1 | 35 +- ...PWebApplication.BlockedFileTypes.Tests.ps1 | 302 ++++++++++++++++++ 3 files changed, 324 insertions(+), 17 deletions(-) create mode 100644 Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 30437f8b4..6b7fe484e 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -202,14 +202,14 @@ function Test-TargetResource # Blocked file types if ($PSBoundParameters.ContainsKey("BlockedFileTypes") -eq $true) { Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues.BlockedFileTypes -DesiredSettings $BlockedFileTypes + $testReturn = Test-xSPWebApplicationBlockedFileTypes -CurrentSettings $CurrentValues.BlockedFileTypes -DesiredSettings $BlockedFileTypes } if ($testReturn -eq $false) { return $false } # General settings if ($PSBoundParameters.ContainsKey("GeneralSettings") -eq $true) { Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues.GeneralSettings -DesiredSettings $GeneralSettings + $testReturn = Test-xSPWebApplicationGeneralSettings -CurrentSettings $CurrentValues.GeneralSettings -DesiredSettings $GeneralSettings } if ($testReturn -eq $false) { return $false } diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 index 5e818f783..1d7542ac5 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -26,25 +26,25 @@ function Set-xSPWebApplicationBlockedFileTypes { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if($Settings.ContainsKey("Blocked") -ne $null ) { + if($Settings.ContainsKey("Blocked") -eq $true) { $WebApplication.BlockedFileExtensions.Clear(); $Settings.Blocked | ForEach-Object { - $WebApplication.BlockedFileExtensions.Add($_); + $WebApplication.BlockedFileExtensions.Add($_.ToLower()); } } - if($Settings.ContainsKey("EnsureBlocked") -ne $null) { + if($Settings.ContainsKey("EnsureBlocked") -eq $true) { $Settings.EnsureBlocked | ForEach-Object { - if(!$WebApplication.BlockedFileExtensions.ContainExtension($_)){ - $WebApplication.BlockedFileExtensions.Add($_); + if(!$WebApplication.BlockedFileExtensions.Contains($_.ToLower())){ + $WebApplication.BlockedFileExtensions.Add($_.ToLower()); } } } - if($Settings.ContainsKey("EnsureAllowed") -ne $null) { + if($Settings.ContainsKey("EnsureAllowed") -eq $true) { $Settings.EnsureAllowed | ForEach-Object { - if($WebApplication.BlockedFileExtensions.ContainExtension($_)){ - $WebApplication.BlockedFileExtensions.Remove($_); + if($WebApplication.BlockedFileExtensions.Contains($_.ToLower())){ + $WebApplication.BlockedFileExtensions.Remove($_.ToLower()); } } } @@ -58,27 +58,32 @@ function Test-xSPWebApplicationBlockedFileTypes { [parameter(Mandatory = $true)] $DesiredSettings ) - if ($DesiredSettings.Blocked -ne $null -and (($DesiredSettings.EnsureBlocked -ne $null) -or ($DesiredSettings.EnsureAllowed -ne $null))) { + if ($DesiredSettings.ContainsKey("Blocked") -eq $true -and (($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) -or ($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true))) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } - if ($DesiredSettings.Blocked -eq $null -and $DesiredSettings.EnsureBlocked -eq $null -and $DesiredSettings.EnsureAllowed -eq $null) { + if ($DesiredSettings.ContainsKey("Blocked") -eq $false -and $DesiredSettings.ContainsKey("EnsureBlocked") -eq $false -and $DesiredSettings.ContainsKey("EnsureAllowed") -eq $false) { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if ($DesiredSettings.Blocked -ne $null) { + if ($DesiredSettings.ContainsKey("Blocked") -eq $true) { $compareResult = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.Blocked if ($compareResult -eq $null) { return $true } else { return $false } } - if($DesiredSettings.EnsureBlocked -ne $null){ - $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked -IncludeEqual -ExcludeDifferent + if($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) { + $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked -ExcludeDifferent if ($itemsToRemove -ne $null) { return $false } } - if($DesiredSettings.EnsureAllowed -ne $null){ + if($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true) { $itemsToAdd = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureAllowed | Where-Object { $_.SideIndicator -eq "=>"} - if ($itemsToAdd -ne $null) { return $false } + if ($itemsToAdd -ne $null) { + $compareResult = Compare-Object -ReferenceObject $DesiredSettings.EnsureAllowed -DifferenceObject $itemsToAdd.InputObject + if ($compareResult -ne $null) { return $false } + } else { + return $false + } } return $true diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 new file mode 100644 index 000000000..e9909f82a --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -0,0 +1,302 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPWebApplication" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPWebApplication (Blocked file types)" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + BlockedFileTypes = @{ + Blocked = @("exe", "dll", "ps1") + } + } + + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Mock New-SPAuthenticationProvider { } + Mock New-SPWebApplication { } + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $true; AllowAnonymous = $false } } + + Context "The web appliation exists and a specific blocked file type list matches" { + Mock Get-SPWebApplication { + [Collections.Generic.List[String]]$CurrentBlockedFiles = @("exe", "ps1", "dll") + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + BlockedFileExtensions = $CurrentBlockedFiles + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru + return @($webApp) + } + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "The web appliation exists and a specific blocked file type list does not match" { + Mock Get-SPWebApplication { + [Collections.Generic.List[String]]$CurrentBlockedFiles = @("exe", "pdf", "dll") + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + BlockedFileExtensions = $CurrentBlockedFiles + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru + return @($webApp) + } + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + $Global:xSPWebApplicationUpdateCalled = $false + It "updates the workflow settings" { + Set-TargetResource @testParams + $Global:xSPWebApplicationUpdateCalled | Should Be $true + } + } + + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + BlockedFileTypes = @{ + EnsureBlocked = @("exe") + EnsureAllowed = @("pdf") + } + } + + Context "The web appliation exists and a list of types to include and exclude both match" { + Mock Get-SPWebApplication { + [Collections.Generic.List[String]]$CurrentBlockedFiles = @("exe", "ps1", "dll") + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + BlockedFileExtensions = $CurrentBlockedFiles + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru + return @($webApp) + } + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "The web appliation exists and a list of types to include and exclude both failed" { + Mock Get-SPWebApplication { + [Collections.Generic.List[String]]$CurrentBlockedFiles = @("pdf", "dll") + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + BlockedFileExtensions = $CurrentBlockedFiles + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru + return @($webApp) + } + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + $Global:xSPWebApplicationUpdateCalled = $false + It "updates the workflow settings" { + Set-TargetResource @testParams + $Global:xSPWebApplicationUpdateCalled | Should Be $true + } + } + + Context "All blocked file type parameters are passed to the methods" { + Mock Get-SPWebApplication { + [Collections.Generic.List[String]]$CurrentBlockedFiles = @("pdf", "dll") + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + BlockedFileExtensions = $CurrentBlockedFiles + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru + return @($webApp) + } + + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + BlockedFileTypes = @{ + Blocked = @("exe", "dll", "ps1") + EnsureBlocked = @("exe", "dll") + EnsureAllowed = @("ps1") + } + } + + It "throws an exception on the test method" { + { Test-TargetResource @testParams } | Should throw + } + + It "throws an exception on the set method" { + { Set-TargetResource @testParams } | Should throw + } + } + + Context "No blocked file type parameters are passed to the methods" { + Mock Get-SPWebApplication { + [Collections.Generic.List[String]]$CurrentBlockedFiles = @("pdf", "dll") + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + BlockedFileExtensions = $CurrentBlockedFiles + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru + return @($webApp) + } + + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + BlockedFileTypes = @{ } + } + + It "throws an exception on the test method" { + { Test-TargetResource @testParams } | Should throw + } + + It "throws an exception on the set method" { + { Set-TargetResource @testParams } | Should throw + } + } + } +} \ No newline at end of file From 2205a2727e969d18882192b0c88be0da8074c8a6 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 21:51:04 +1100 Subject: [PATCH 091/147] Added general settings tests for xSPWebApplication --- Tests/Tests.pssproj | 2 + ...SPWebApplication.GeneralSettings.Tests.ps1 | 162 ++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index a7de00f9a..7d475469d 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -72,6 +72,8 @@ + + diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 new file mode 100644 index 000000000..a2d8d8313 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -0,0 +1,162 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPWebApplication" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPWebApplication (General Settings)" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + GeneralSettings = @{ + TimeZone = 3081 + Alerts = $true + AlertsLimit = 10 + RSS = $true + BlogAPI = $true + BlogAPIAuthenticated = $true + BrowserFileHandling = "Permissive" + SecurityValidation = $true + RecycleBinEnabled = $true + RecycleBinCleanupEnabled = $true + RecycleBinRetentionPeriod = 30 + SecondStageRecycleBinQuota = 30 + MaximumUploadSize = 100 + CustomerExperienceProgram = $true + PresenceEnabled = $true + } + } + + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Mock New-SPAuthenticationProvider { } + Mock New-SPWebApplication { } + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $true; AllowAnonymous = $false } } + + Context "The web appliation exists and has the correct general settings" { + Mock Get-SPWebApplication { + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + DefaultTimeZone = $testParams.GeneralSettings.TimeZone + AlertsEnabled = $testParams.GeneralSettings.Alerts + AlertsMaximum = $testParams.GeneralSettings.AlertsLimit + SyndicationEnabled = $testParams.GeneralSettings.RSS + MetaWeblogEnabled = $testParams.GeneralSettings.BlogAPI + MetaWeblogAuthenticationEnabled = $testParams.GeneralSettings.BlogAPIAuthenticated + BrowserFileHandling = $testParams.GeneralSettings.BrowserFileHandling + FormDigestSettings = @{ + Enabled = $testParams.GeneralSettings.SecurityValidation + } + RecycleBinEnabled = $testParams.GeneralSettings.RecycleBinEnabled + RecycleBinCleanupEnabled = $testParams.GeneralSettings.RecycleBinCleanupEnabled + RecycleBinRetentionPeriod = $testParams.GeneralSettings.RecycleBinRetentionPeriod + SecondStageRecycleBinQuota = $testParams.GeneralSettings.SecondStageRecycleBinQuota + MaximumFileSize = $testParams.GeneralSettings.MaximumUploadSize + BrowserCEIPEnabled = $testParams.GeneralSettings.CustomerExperienceProgram + PresenceEnabled = $testParams.GeneralSettings.PresenceEnabled + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru + return @($webApp) + } + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "The web appliation exists and uses incorrect general settings" { + Mock Get-SPWebApplication { + $webApp = @{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + DefaultTimeZone = 1 + AlertsEnabled = $false + AlertsMaximum = 1 + SyndicationEnabled = $false + MetaWeblogEnabled = $false + MetaWeblogAuthenticationEnabled = $false + BrowserFileHandling = "Strict" + FormDigestSettings = @{ + Enabled = $false + } + RecycleBinEnabled = $false + RecycleBinCleanupEnabled = $false + RecycleBinRetentionPeriod = 1 + SecondStageRecycleBinQuota = 1 + MaximumFileSize = 1 + BrowserCEIPEnabled = $false + PresenceEnabled = $false + } + $webApp = $webApp | Add-Member ScriptMethod Update { + $Global:xSPWebApplicationUpdateCalled = $true + } -PassThru + return @($webApp) + } + + It "returns the current data from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + $Global:xSPWebApplicationUpdateCalled = $false + It "updates the workflow settings" { + Set-TargetResource @testParams + $Global:xSPWebApplicationUpdateCalled | Should Be $true + } + } + } +} \ No newline at end of file From a7f0606eb06165aba9f4fceef9645ecb9acc80af Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 29 Nov 2015 23:55:43 +1100 Subject: [PATCH 092/147] Minor tweaks to schema --- .../MSFT_xSPWebApplication.schema.mof | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 3cf205877..a407d5d93 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,12 +1,12 @@ -[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationBlockedFileTypes")] +[ClassVersion("1.0.0")] Class MSFT_xSPFilesTypes { - [write]String Blocked[]; - [write]String EnsureBlocked[]; - [write]String EnsureAllowed[]; + [write] string Blocked[]; + [write] string EnsureBlocked[]; + [write] string EnsureAllowed[]; }; -[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationHappyHour")] +[ClassVersion("1.0.0")] Class MSFT_xSPWebApplicationHappyHour { [write] uint32 Hour; @@ -15,7 +15,7 @@ Class MSFT_xSPWebApplicationHappyHour }; -[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationThrottling")] +[ClassVersion("1.0.0")] Class MSFT_xSPWebApplicationThrottling { [write] uint32 ListViewThreshold; @@ -23,7 +23,7 @@ Class MSFT_xSPWebApplicationThrottling [write] uint32 AdminThreshold; [write] uint32 ListViewLookupThreshold; [write] boolean HappyHourEnabled; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationHappyHour")] String HappyHour; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationHappyHour")] string HappyHour; [write] uint32 UniquePermissionThreshold; [write] boolean RequestThrottling; [write] boolean ChangeLogEnabled; @@ -31,15 +31,15 @@ Class MSFT_xSPWebApplicationThrottling [write] boolean EventHandlersEnabled; }; -[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationWorkflowSettings")] +[ClassVersion("1.0.0")] Class MSFT_xSPWebApplicationWorkflowSettings { - [write]boolean ExternalWorkflowParticipantsEnabled; - [write]boolean UserDefinedWorkflowsEnabled; - [write]boolean EmailToNoPermissionWorkflowParticipantsEnable; + [write] boolean ExternalWorkflowParticipantsEnabled; + [write] boolean UserDefinedWorkflowsEnabled; + [write] boolean EmailToNoPermissionWorkflowParticipantsEnable; }; -[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationSettings")] +[ClassVersion("1.0.0")] Class MSFT_xSPWebApplicationSettings { [write] uint32 TimeZone; @@ -95,10 +95,10 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string HostHeader; [Write] string Path; [Write] string Port; - [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationSettings")] String GeneralSettings; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationWorkflowSettings")] String WorkflowSettings; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationThrottling")] String ThrottlingSettings; - [Write, EmbeddedInstance("MSFT_xSPFilesTypes")] String BlockedFileTypes; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationSettings")] string GeneralSettings; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationWorkflowSettings")] string WorkflowSettings; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationThrottling")] string ThrottlingSettings; + [Write, EmbeddedInstance("MSFT_xSPFilesTypes")] string BlockedFileTypes; }; From ff637b3bb79b6b40a32f6e0ef0bedd77590cf86e Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 30 Nov 2015 18:15:55 +1100 Subject: [PATCH 093/147] Fixed update conflict bug in xSPWebApplication --- .../MSFT_xSPWebApplication.psm1 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 6b7fe484e..3e82c7d49 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -122,13 +122,7 @@ function Set-TargetResource Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) Set-xSPWebApplicationThrottlingSettings -WebApplication $wa -Settings $params.ThrottlingSettings } - - # Workflow settings - if ($params.ContainsKey("WorkflowSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - Set-xSPWebApplicationWorkflowSettings -WebApplication $wa -Settings $params.WorkflowSettings - } - + # Blocked file types if ($params.ContainsKey("BlockedFileTypes") -eq $true) { Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) @@ -141,12 +135,19 @@ function Set-TargetResource Set-xSPWebApplicationGeneralSettings -WebApplication $wa -Settings $params.GeneralSettings } - if( ($params.WorkflowSettings -ne $null) -or - ($params.GeneralSettings -ne $null) -or + if( ($params.GeneralSettings -ne $null) -or ($params.ThrottlingSettings -ne $null) -or ($params.BlockedFileTypes -ne $null) ) { $wa.Update() } + + # Workflow settings + if ($params.ContainsKey("WorkflowSettings") -eq $true) { + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + # Workflow uses a seperate update method, to avoid update conflicts get a fresh web app object + $wa2 = Get-SPWebApplication -Identity $params.Name + Set-xSPWebApplicationWorkflowSettings -WebApplication $wa2 -Settings $params.WorkflowSettings + } } } From 37fba85a614d2965a61e398051400999c1a96e7f Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Thu, 12 Nov 2015 07:32:29 +0000 Subject: [PATCH 094/147] adding xSPPasswordChangeSettings --- .../MSFT_xSPPasswordChangeSettings.psm1 | 87 +++++++++++++++++ .../MSFT_xSPPasswordChangeSettings.schema.mof | 8 ++ Modules/xSharePoint/xSharePoint.pssproj | 3 + Tests/Tests.pssproj | 1 + ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 95 +++++++++++++++++++ 5 files changed, 194 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 new file mode 100644 index 000000000..4a14d0817 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -0,0 +1,87 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + ) + + Write-Verbose -Message "Retrieving farm wide automatic password change settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $farm = Get-SPFarm + if ($null -eq $farm ) { return $null } + return @{ + + MailAddress = $farm.PasswordChangeEmailAddress + PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime + NumberOfRetries= $farm.PasswordChangeMaximumTries + DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + ) + + Write-Verbose -Message "Updating farm wide automatic password change settings" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + <#$updateParams = @{ + PasswordChangeEmailAddress = $params.MailAddress + DaysBeforePasswordExpirationToSendEmail = $params.DaysBeforeExpiry + PasswordChangeMaximumTries = $params.NumberOfRetries + PasswordChangeGuardTime = $params.PasswordChangeWaitTimeSeconds + + }#> + $farm = Get-SPFarm + $farm.PasswordChangeEmailAddress=$params.MailAddress; + $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds + $farm.PasswordChangeMaximumTries=$params.NumberOfRetries + $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry + $farm.Update(); + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing retrieving farm wide automatic password change settings" + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("MailAddress", "DaysBeforeExpiry","PasswordChangeWaitTimeSeconds","NumberOfRetries") +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof new file mode 100644 index 000000000..f08d7a6e9 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -0,0 +1,8 @@ +[ClassVersion("1.0.0.0"), FriendlyName("xSPPasswordChangeSettings")] +class MSFT_xSPPasswordChangeSettings : OMI_BaseResource +{ + [Write] string MailAddress; + [Write] Uint32 DaysBeforeExpiry; + [Write] Uint32 PasswordChangeWaitTimeSeconds; + [Write] Uint32 NumberOfRetries; +}; diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index dd7740cee..41769a7e3 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -72,6 +72,7 @@ + @@ -103,6 +104,7 @@ + @@ -127,6 +129,7 @@ + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 09c494faf..fa1df4831 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -65,6 +65,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 new file mode 100644 index 000000000..1572305b5 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -0,0 +1,95 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPPasswordChangeSettings" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPPasswordChangeSettings" { + InModuleScope $ModuleName { + $testParams = @{ + MailAddress = "e@mail.com" + DaysBeforeExpiry = 7 + PasswordChangeWaitTimeSeconds = 60 + NumberOfRetries = 3 + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Context " Farm isn't available " { + Mock Get-SPFarm { return $null + } + + It "returns null from the get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + } + + Context " Properties already set tests " { + Mock Get-SPFarm { + return @{ + PasswordChangeEmailAddress = "e@mail.com" + DaysBeforePasswordExpirationToSendEmail = 7 + PasswordChangeGuardTime = 60 + PasswordChangeMaximumTries = 3 + } + } + + It "returns farm properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + + + Context " Properties update tests " { + Mock Get-SPFarm { + $result = @{ + PasswordChangeEmailAddress=""; + PasswordChangeGuardTime=0 + PasswordChangeMaximumTries=0 + DaysBeforePasswordExpirationToSendEmail=0 + } + $result = $result | Add-Member ScriptMethod Update { return $true} -passThru + return $result + } + + It "returns farm properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "calls the new and set methods from the set function" { + Set-TargetResource @testParams + Assert-MockCalled Get-SPFarm + } + } + + + + } +} \ No newline at end of file From a612acd10fd27edd9f967dbbba5a84342dfb4795 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Thu, 12 Nov 2015 08:01:08 +0000 Subject: [PATCH 095/147] commiting removing comented out code --- .../MSFT_xSPPasswordChangeSettings.psm1 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 4a14d0817..3a1c74336 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -44,15 +44,7 @@ function Set-TargetResource Write-Verbose -Message "Updating farm wide automatic password change settings" Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - - <#$updateParams = @{ - PasswordChangeEmailAddress = $params.MailAddress - DaysBeforePasswordExpirationToSendEmail = $params.DaysBeforeExpiry - PasswordChangeMaximumTries = $params.NumberOfRetries - PasswordChangeGuardTime = $params.PasswordChangeWaitTimeSeconds - - }#> - $farm = Get-SPFarm + $farm = Get-SPFarm $farm.PasswordChangeEmailAddress=$params.MailAddress; $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds $farm.PasswordChangeMaximumTries=$params.NumberOfRetries From e27f33df1dbe32c0e3ebd51aae67ae739f364b56 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sat, 14 Nov 2015 10:47:45 +0000 Subject: [PATCH 096/147] fixing xSPPasswordChangeSettings and adding xSPOutgoingEmailSettings --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 94 ++++++++++++++++++ .../MSFT_xSPOutgoingEmailSettings.schema.mof | 10 ++ .../MSFT_xSPPasswordChangeSettings.psm1 | 10 +- .../MSFT_xSPPasswordChangeSettings.schema.mof | 2 +- .../xSharePoint.Util/xSharePoint.Util.psm1 | 4 + Modules/xSharePoint/xSharePoint.pssproj | 3 + Tests/Tests.pssproj | 1 + ...rePoint.xSPOutgoingEmailSettings.Tests.ps1 | 99 +++++++++++++++++++ ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 39 ++++---- 9 files changed, 237 insertions(+), 25 deletions(-) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 new file mode 100644 index 000000000..124000077 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -0,0 +1,94 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + + ) + + Write-Verbose -Message "Retrieving outgoing email settings configuration " + + $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $webApp = $null + if([string]::IsNullOrEmpty($params.WebAppUrl)){ + $webApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } + }else{ + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + } + if ($null -eq $webApp ) { + throw "Web Application $webAppUrl not found" + } + return @{ + WebAppUrl = $webApp.Url + SMTPServer= $webApp.OutboundMailServiceInstance + FromAddress= $webApp.OutboundMailSenderAddress + ReplyToAddress= $webApp.OutboundMailReplyToAddress + CharacterSet = $webApp.OutboundMailCodePage + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + ) + + Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" + Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $webApp = $null + if([string]::IsNullOrEmpty($params.WebAppUrl)){ + Write-Verbose -Message "retrieving global(CA) settings" + $webApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } + }else{ + Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + } + if($null -eq $webApp) + { + throw "Web Application $webAppUrl not found" + } + $webApp.UpdateMailSettings($params.SMTPServer, $params.FromAddress, $params.ReplyToAddress, $params.CharacterSet) + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Comparing Current and Target Outgoing email settings" + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("WebAppUrl", "SMTPServer","FromAddress","ReplyToAddress","CharacterSet") +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof new file mode 100644 index 000000000..dd3663744 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -0,0 +1,10 @@ +[ClassVersion("1.0.0.0"), FriendlyName("xSPOutgoingEmailSettings")] +class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource +{ + [key] string WebAppUrl; + [Write] string SMTPServer; + [Write] string FromAddress; + [Write] string ReplyToAddress; + [Write] string CharacterSet; +}; + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 3a1c74336..196490871 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -4,8 +4,7 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $true)] [System.String] $MailAddress, + [parameter(Mandatory = $true)] [System.String] $MailAddress, [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries @@ -13,7 +12,7 @@ function Get-TargetResource Write-Verbose -Message "Retrieving farm wide automatic password change settings" - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $farm = Get-SPFarm @@ -34,7 +33,6 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $true)] [System.String] $MailAddress, [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, @@ -45,11 +43,14 @@ function Set-TargetResource Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $farm = Get-SPFarm + + if ($null -eq $farm ) { return $null } $farm.PasswordChangeEmailAddress=$params.MailAddress; $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds $farm.PasswordChangeMaximumTries=$params.NumberOfRetries $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry $farm.Update(); + } } @@ -60,7 +61,6 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $true)] [System.String] $MailAddress, [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index f08d7a6e9..48fb75dc0 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -1,7 +1,7 @@ [ClassVersion("1.0.0.0"), FriendlyName("xSPPasswordChangeSettings")] class MSFT_xSPPasswordChangeSettings : OMI_BaseResource { - [Write] string MailAddress; + [key] string MailAddress; [Write] Uint32 DaysBeforeExpiry; [Write] Uint32 PasswordChangeWaitTimeSeconds; [Write] Uint32 NumberOfRetries; diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index fa7b44dc9..0915b5557 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -26,6 +26,10 @@ function Get-xSharePointAssemblyVersion() { ) return (Get-Command $PathToAssembly).FileVersionInfo.FileMajorPart } +function Get-UtilAsScriptBlock(){ + $content = Get-Content (Resolve-Path .\xSharePoint.psd1) + write-host [Scriptblock]::Create($content ) +} function Get-xSharePointInstalledProductVersion() { $pathToSearch = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\*\ISAPI\Microsoft.SharePoint.dll" diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 41769a7e3..c494f1883 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -62,6 +62,7 @@ + @@ -104,6 +105,8 @@ + + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index fa1df4831..9337cc013 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -65,6 +65,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 new file mode 100644 index 000000000..5bb8d7b03 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -0,0 +1,99 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPOutgoingEmailSettings" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPOutgoingEmailSettings" { + InModuleScope $ModuleName { + $testParams = @{ + WebAppUrl = "http://sp2013.australiasoutheast.cloudapp.azure.com" + SMTPServer = "smtp.contoso.com" + FromAddress = "from@email.com" + ReplyToAddress = "reply@email.com" + CharacterSet= "65001" + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + + + Context " Web Application isn't available " { + Mock Get-SPWebApplication -MockWith { return $null + } + + It "throws exception from the get method" { + {Get-TargetResource @testParams} | Should Throw + } + + It "throws exception from the test method" { + { Test-TargetResource @testParams } | Should Throw + } + + } + + Context " Properties match" { + Mock Get-SPWebApplication { + return @{ + Url= "http://sp2013.australiasoutheast.cloudapp.azure.com" + OutboundMailServiceInstance= "smtp.contoso.com" + OutboundMailSenderAddress = "from@email.com" + OutboundMailReplyToAddress= "reply@email.com" + OutboundMailCodePage= "65001" + } + } + + It "returns web app properties from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + + + Context " Properties update tests " { + Mock Get-SPWebApplication { + $result = @{ + Url= "http://sp2013.australiasoutheast.cloudapp.azure.com" + OutboundMailServiceInstance= "smtp2.contoso.com" + OutboundMailSenderAddress = "from@email.com" + OutboundMailReplyToAddress= "reply@email.com" + OutboundMailCodePage= "65001" + } + $result = $result | Add-Member ScriptMethod UpdateMailSettings { + param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) + return ; +} -passThru + return $result + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "calls the new and set methods from the set function" { + Set-TargetResource @testParams + Assert-MockCalled Get-SPWebApplication + } + } + + + + } +} \ No newline at end of file diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 1572305b5..0048f3148 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -28,30 +28,31 @@ Describe "xSPPasswordChangeSettings" { Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue - Context " Farm isn't available " { + Context " Farm isn't available " { Mock Get-SPFarm { return $null - } + } It "returns null from the get method" { - Get-TargetResource @testParams | Should BeNullOrEmpty + Get-TargetResource @testParams | Should Throw } It "returns false from the test method" { - Test-TargetResource @testParams | Should Be $false + Test-TargetResource @testParams | Should be $false } } - Context " Properties already set tests " { + + Context " Properties already set tests " { Mock Get-SPFarm { - return @{ + return @{ PasswordChangeEmailAddress = "e@mail.com" DaysBeforePasswordExpirationToSendEmail = 7 PasswordChangeGuardTime = 60 PasswordChangeMaximumTries = 3 - } - } - + } + } + It "returns farm properties from the get method" { Get-TargetResource @testParams | Should Not BeNullOrEmpty } @@ -63,17 +64,17 @@ Describe "xSPPasswordChangeSettings" { } - Context " Properties update tests " { + Context " Properties update tests " { Mock Get-SPFarm { - $result = @{ - PasswordChangeEmailAddress=""; - PasswordChangeGuardTime=0 - PasswordChangeMaximumTries=0 - DaysBeforePasswordExpirationToSendEmail=0 - } - $result = $result | Add-Member ScriptMethod Update { return $true} -passThru - return $result - } + $result = @{ + PasswordChangeEmailAddress=""; + PasswordChangeGuardTime=0 + PasswordChangeMaximumTries=0 + DaysBeforePasswordExpirationToSendEmail=0 + } + $result = $result | Add-Member ScriptMethod Update { return $true} -passThru + return $result + } It "returns farm properties from the get method" { Get-TargetResource @testParams | Should Not BeNullOrEmpty From 4012e6c0f30bc0c3772203250c74ae7a7fbaad01 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sat, 14 Nov 2015 22:42:50 +0000 Subject: [PATCH 097/147] fixing formatting issues --- .../MSFT_xSPPasswordChangeSettings.psm1 | 46 +++++++++---------- .../MSFT_xSPPasswordChangeSettings.schema.mof | 2 +- .../Examples/Single Server/Caller.ps1 | 3 ++ .../xSharePoint.Util/xSharePoint.Util.psm1 | 2 +- ...rePoint.xSPOutgoingEmailSettings.Tests.ps1 | 5 +- 5 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 Modules/xSharePoint/Examples/Single Server/Caller.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 196490871..850d5fac4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -4,10 +4,10 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] [System.String] $MailAddress, - [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries ) Write-Verbose -Message "Retrieving farm wide automatic password change settings" @@ -19,10 +19,10 @@ function Get-TargetResource if ($null -eq $farm ) { return $null } return @{ - MailAddress = $farm.PasswordChangeEmailAddress - PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime - NumberOfRetries= $farm.PasswordChangeMaximumTries - DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail + MailAddress = $farm.PasswordChangeEmailAddress + PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime + NumberOfRetries= $farm.PasswordChangeMaximumTries + DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail } } return $result @@ -33,23 +33,23 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $true)] [System.String] $MailAddress, - [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries ) Write-Verbose -Message "Updating farm wide automatic password change settings" Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $farm = Get-SPFarm + $farm = Get-SPFarm - if ($null -eq $farm ) { return $null } - $farm.PasswordChangeEmailAddress=$params.MailAddress; - $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds - $farm.PasswordChangeMaximumTries=$params.NumberOfRetries - $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry - $farm.Update(); + if ($null -eq $farm ) { return $null } + $farm.PasswordChangeEmailAddress=$params.MailAddress; + $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds + $farm.PasswordChangeMaximumTries=$params.NumberOfRetries + $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry + $farm.Update(); } } @@ -61,16 +61,16 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)] [System.String] $MailAddress, - [parameter(Mandatory = $true)] [ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $true)][System.String] $MailAddress, + [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries - ) + [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + ) $CurrentValues = Get-TargetResource @PSBoundParameters Write-Verbose -Message "Testing retrieving farm wide automatic password change settings" - if ($null -eq $CurrentValues) { return $false } - + if ($null -eq $CurrentValues) { return $false } + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("MailAddress", "DaysBeforeExpiry","PasswordChangeWaitTimeSeconds","NumberOfRetries") } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index 48fb75dc0..3ac447092 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -2,7 +2,7 @@ class MSFT_xSPPasswordChangeSettings : OMI_BaseResource { [key] string MailAddress; - [Write] Uint32 DaysBeforeExpiry; + [Write] Uint32 DaysBeforeExpiry; [Write] Uint32 PasswordChangeWaitTimeSeconds; [Write] Uint32 NumberOfRetries; }; diff --git a/Modules/xSharePoint/Examples/Single Server/Caller.ps1 b/Modules/xSharePoint/Examples/Single Server/Caller.ps1 new file mode 100644 index 000000000..8b65a099b --- /dev/null +++ b/Modules/xSharePoint/Examples/Single Server/Caller.ps1 @@ -0,0 +1,3 @@ +# +# Caller.ps1 +# diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 0915b5557..e1874bbaf 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -28,7 +28,7 @@ function Get-xSharePointAssemblyVersion() { } function Get-UtilAsScriptBlock(){ $content = Get-Content (Resolve-Path .\xSharePoint.psd1) - write-host [Scriptblock]::Create($content ) + write-host [Scriptblock]::Create($content ) } function Get-xSharePointInstalledProductVersion() { diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index 5bb8d7b03..7b049d724 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -77,9 +77,8 @@ Describe "xSPOutgoingEmailSettings" { OutboundMailCodePage= "65001" } $result = $result | Add-Member ScriptMethod UpdateMailSettings { - param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) - return ; -} -passThru + param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) + return ; } -passThru return $result } From bc5ae781c596073147e72edc941906de3332d0cd Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 15 Nov 2015 10:12:48 +0000 Subject: [PATCH 098/147] adding validation and making xSPPasswordSettings parameters optional --- .../MSFT_xSPPasswordChangeSettings.psm1 | 40 +++++++++++-------- ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 2 +- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 850d5fac4..31f0093cb 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -5,9 +5,9 @@ function Get-TargetResource param ( [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries ) Write-Verbose -Message "Retrieving farm wide automatic password change settings" @@ -18,11 +18,10 @@ function Get-TargetResource $farm = Get-SPFarm if ($null -eq $farm ) { return $null } return @{ - - MailAddress = $farm.PasswordChangeEmailAddress - PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime - NumberOfRetries= $farm.PasswordChangeMaximumTries - DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail + MailAddress = $farm.PasswordChangeEmailAddress + PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime + NumberOfRetries= $farm.PasswordChangeMaximumTries + DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail } } return $result @@ -34,9 +33,9 @@ function Set-TargetResource param ( [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,356 )][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99 )][System.UInt32] $NumberOfRetries ) Write-Verbose -Message "Updating farm wide automatic password change settings" @@ -45,10 +44,17 @@ function Set-TargetResource $farm = Get-SPFarm if ($null -eq $farm ) { return $null } + $farm.PasswordChangeEmailAddress=$params.MailAddress; - $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds - $farm.PasswordChangeMaximumTries=$params.NumberOfRetries - $farm.DaysBeforePasswordExpirationToSendEmail =$params.DaysBeforeExpiry + if($params.PasswordChangeWaitTimeSeconds -ne $null){ + $farm.PasswordChangeGuardTime=$params.PasswordChangeWaitTimeSeconds + } + if($params.NumberOfRetries -ne $null){ + $farm.PasswordChangeMaximumTries=$params.NumberOfRetries + } + if($params.DaysBeforeExpiry -ne $null){ + $farm.DaysBeforePasswordExpirationToSendEmail=$params.DaysBeforeExpiry + } $farm.Update(); } @@ -62,9 +68,9 @@ function Test-TargetResource param ( [parameter(Mandatory = $true)][System.String] $MailAddress, - [parameter(Mandatory = $true)][ValidateRange(0,356 )] [System.UInt32] $DaysBeforeExpiry, - [parameter(Mandatory = $true)][ValidateRange(0,36000 )] [System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $true)][ValidateRange(0,99 )] [System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, + [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 0048f3148..0175e8e6f 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -18,7 +18,7 @@ Describe "xSPPasswordChangeSettings" { MailAddress = "e@mail.com" DaysBeforeExpiry = 7 PasswordChangeWaitTimeSeconds = 60 - NumberOfRetries = 3 + } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") From a393649a33bc960dc59c933cb76e1b70f4cf4aee Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 01:01:18 +0000 Subject: [PATCH 099/147] addressing Brian's comments --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 18 +++++------------- .../Examples/Single Server/Caller.ps1 | 3 --- .../xSharePoint.Util/xSharePoint.Util.psm1 | 5 +---- ...arePoint.xSPOutgoingEmailSettings.Tests.ps1 | 15 +++++++++------ ...rePoint.xSPPasswordChangeSettings.Tests.ps1 | 9 ++++++++- 5 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 Modules/xSharePoint/Examples/Single Server/Caller.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 index 124000077..862e8437b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -18,13 +18,10 @@ function Get-TargetResource $params = $args[0] $webApp = $null - if([string]::IsNullOrEmpty($params.WebAppUrl)){ - $webApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } - }else{ - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration - } + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + if ($null -eq $webApp ) { - throw "Web Application $webAppUrl not found" + return $null } return @{ WebAppUrl = $webApp.Url @@ -53,13 +50,8 @@ function Set-TargetResource Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $webApp = $null - if([string]::IsNullOrEmpty($params.WebAppUrl)){ - Write-Verbose -Message "retrieving global(CA) settings" - $webApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } - }else{ - Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration - } + Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration if($null -eq $webApp) { throw "Web Application $webAppUrl not found" diff --git a/Modules/xSharePoint/Examples/Single Server/Caller.ps1 b/Modules/xSharePoint/Examples/Single Server/Caller.ps1 deleted file mode 100644 index 8b65a099b..000000000 --- a/Modules/xSharePoint/Examples/Single Server/Caller.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -# -# Caller.ps1 -# diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index e1874bbaf..e6c9dc35b 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -26,10 +26,7 @@ function Get-xSharePointAssemblyVersion() { ) return (Get-Command $PathToAssembly).FileVersionInfo.FileMajorPart } -function Get-UtilAsScriptBlock(){ - $content = Get-Content (Resolve-Path .\xSharePoint.psd1) - write-host [Scriptblock]::Create($content ) -} + function Get-xSharePointInstalledProductVersion() { $pathToSearch = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\*\ISAPI\Microsoft.SharePoint.dll" diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index 7b049d724..f274d31b7 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -35,12 +35,12 @@ Describe "xSPOutgoingEmailSettings" { Mock Get-SPWebApplication -MockWith { return $null } - It "throws exception from the get method" { - {Get-TargetResource @testParams} | Should Throw + It "returns null from the get method" { + Get-TargetResource @testParams | Should be $null } - It "throws exception from the test method" { - { Test-TargetResource @testParams } | Should Throw + It "returns false from the test method" { + Test-TargetResource @testParams | Should be $false } } @@ -64,7 +64,7 @@ Describe "xSPOutgoingEmailSettings" { Test-TargetResource @testParams | Should Be $true } - } + } Context " Properties update tests " { @@ -78,7 +78,8 @@ Describe "xSPOutgoingEmailSettings" { } $result = $result | Add-Member ScriptMethod UpdateMailSettings { param( [string]$SMTPServer, [string]$FromAddress, [string]$ReplyToAddress, [string]$CharacterSet ) - return ; } -passThru + $Global:UpdateMailSettingsCalled = $true; + return ; } -passThru return $result } @@ -87,8 +88,10 @@ Describe "xSPOutgoingEmailSettings" { } It "calls the new and set methods from the set function" { + $Global:UpdateMailSettingsCalled=$false; Set-TargetResource @testParams Assert-MockCalled Get-SPWebApplication + $Global:UpdateMailSettingsCalled | Should Be $true } } diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 0175e8e6f..f4b74ca28 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -72,7 +72,11 @@ Describe "xSPPasswordChangeSettings" { PasswordChangeMaximumTries=0 DaysBeforePasswordExpirationToSendEmail=0 } - $result = $result | Add-Member ScriptMethod Update { return $true} -passThru + $result = $result | Add-Member ScriptMethod Update { + $Global:UpdateCalledSPFarmUpdateCalled = $true; + return $true; + + } -passThru return $result } @@ -85,8 +89,11 @@ Describe "xSPPasswordChangeSettings" { } It "calls the new and set methods from the set function" { + $Global:UpdateCalledSPFarmUpdateCalled =$false; Set-TargetResource @testParams + Assert-MockCalled Get-SPFarm + $Global:UpdateCalledSPFarmUpdateCalled | Should Be $true } } From 369234b80fe7c4b9addbd86c80a562f458a35d2d Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 01:03:55 +0000 Subject: [PATCH 100/147] fixing formatting issues on test files --- .../xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 | 2 +- .../xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index f274d31b7..747f3d304 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -91,7 +91,7 @@ Describe "xSPOutgoingEmailSettings" { $Global:UpdateMailSettingsCalled=$false; Set-TargetResource @testParams Assert-MockCalled Get-SPWebApplication - $Global:UpdateMailSettingsCalled | Should Be $true + $Global:UpdateMailSettingsCalled | Should Be $true } } diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index f4b74ca28..2ca671f37 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -91,7 +91,6 @@ Describe "xSPPasswordChangeSettings" { It "calls the new and set methods from the set function" { $Global:UpdateCalledSPFarmUpdateCalled =$false; Set-TargetResource @testParams - Assert-MockCalled Get-SPFarm $Global:UpdateCalledSPFarmUpdateCalled | Should Be $true } From d5ed68a8a68cbb8727efcf435e67ebdd15a5206a Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 01:07:57 +0000 Subject: [PATCH 101/147] converting more tabs to 4 spaces.... hate you Brian --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 130 +++++++++--------- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 10 +- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 index 862e8437b..3d7d575ab 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -1,84 +1,84 @@ function Get-TargetResource { - [CmdletBinding()] - [OutputType([System.Collections.Hashtable])] - param - ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, - [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet - - ) + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + + ) - Write-Verbose -Message "Retrieving outgoing email settings configuration " + Write-Verbose -Message "Retrieving outgoing email settings configuration " - $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - - $webApp = $null - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $webApp = $null + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration - if ($null -eq $webApp ) { - return $null - } - return @{ - WebAppUrl = $webApp.Url - SMTPServer= $webApp.OutboundMailServiceInstance - FromAddress= $webApp.OutboundMailSenderAddress - ReplyToAddress= $webApp.OutboundMailReplyToAddress - CharacterSet = $webApp.OutboundMailCodePage - } - } - return $result + if ($null -eq $webApp ) { + return $null + } + return @{ + WebAppUrl = $webApp.Url + SMTPServer= $webApp.OutboundMailServiceInstance + FromAddress= $webApp.OutboundMailSenderAddress + ReplyToAddress= $webApp.OutboundMailReplyToAddress + CharacterSet = $webApp.OutboundMailCodePage + } + } + return $result } function Set-TargetResource { - [CmdletBinding()] - param - ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, - [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet - ) + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + ) - Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" - Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - $webApp = $null - Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration - if($null -eq $webApp) - { - throw "Web Application $webAppUrl not found" - } - $webApp.UpdateMailSettings($params.SMTPServer, $params.FromAddress, $params.ReplyToAddress, $params.CharacterSet) - } + Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" + Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $webApp = $null + Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + if($null -eq $webApp) + { + throw "Web Application $webAppUrl not found" + } + $webApp.UpdateMailSettings($params.SMTPServer, $params.FromAddress, $params.ReplyToAddress, $params.CharacterSet) + } } function Test-TargetResource { - [CmdletBinding()] - [OutputType([System.Boolean])] - param - ( - [parameter(Mandatory = $true)] [System.String] $WebAppUrl, - [parameter(Mandatory = $true)] [System.String] $SMTPServer, - [parameter(Mandatory = $true)] [System.String] $FromAddress, - [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet - ) + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $WebAppUrl, + [parameter(Mandatory = $true)] [System.String] $SMTPServer, + [parameter(Mandatory = $true)] [System.String] $FromAddress, + [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, + [parameter(Mandatory = $true)] [System.String] $CharacterSet + ) - $CurrentValues = Get-TargetResource @PSBoundParameters - Write-Verbose -Message "Comparing Current and Target Outgoing email settings" - if ($null -eq $CurrentValues) { return $false } - - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("WebAppUrl", "SMTPServer","FromAddress","ReplyToAddress","CharacterSet") + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Comparing Current and Target Outgoing email settings" + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("WebAppUrl", "SMTPServer","FromAddress","ReplyToAddress","CharacterSet") } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index dd3663744..2d6785787 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -1,10 +1,10 @@ [ClassVersion("1.0.0.0"), FriendlyName("xSPOutgoingEmailSettings")] class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource { - [key] string WebAppUrl; - [Write] string SMTPServer; - [Write] string FromAddress; - [Write] string ReplyToAddress; - [Write] string CharacterSet; + [key] string WebAppUrl; + [Write] string SMTPServer; + [Write] string FromAddress; + [Write] string ReplyToAddress; + [Write] string CharacterSet; }; From 22e7d55cfdad058c7f22b7752d1bb33718d18759 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 12:34:18 +0000 Subject: [PATCH 102/147] adding BlockedFileTypes --- .../MSFT_xSPWebApplication.psm1 | 28 +++- ...ePoint.xSPPasswordChangeSettings.Tests.ps1 | 6 +- .../xSharePoint.xSPWebApplication.Tests.ps1 | 120 ++++++++++++++++++ 3 files changed, 146 insertions(+), 8 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 1b519c8a6..f152c1963 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -15,7 +15,8 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes ) Write-Verbose -Message "Getting web application '$Name'" @@ -44,6 +45,7 @@ function Get-TargetResource Port = (New-Object System.Uri $wa.Url).Port AuthenticationMethod = $localAuthMode InstallAccount = $params.InstallAccount + BlockedFileTypes = $wa.BlockedFileExtensions } } return $result @@ -66,7 +68,8 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes ) Write-Verbose -Message "Creating web application '$Name'" @@ -74,6 +77,12 @@ function Set-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] + $blockedFileTypes = $null + if($params.ContainsKey("BlockedFileTypes")) + { + $blockedFileTypes =$params.BlockedFileTypes + $params.Remove("BlockedFileTypes") + } $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { @@ -92,9 +101,17 @@ function Set-TargetResource $params.Remove("AllowAnonymous") | Out-Null $params.Add("AllowAnonymousAccess", $true) } - - New-SPWebApplication @params + + $wa = New-SPWebApplication @params } + write-host "bla" + write-debug "bla" + if($blockedFileTypes -ne $null){ + $wa.BlockedFileExtensions.RemoveAll(); + $blockedFileTypes| % {$wa.BlockedFileExtensions.Add($_) } + $wa.Update() + } + } } @@ -116,7 +133,8 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 index 2ca671f37..0f19af5e3 100644 --- a/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPPasswordChangeSettings.Tests.ps1 @@ -73,7 +73,7 @@ Describe "xSPPasswordChangeSettings" { DaysBeforePasswordExpirationToSendEmail=0 } $result = $result | Add-Member ScriptMethod Update { - $Global:UpdateCalledSPFarmUpdateCalled = $true; + $Global:SPFarmUpdateCalled = $true; return $true; } -passThru @@ -89,10 +89,10 @@ Describe "xSPPasswordChangeSettings" { } It "calls the new and set methods from the set function" { - $Global:UpdateCalledSPFarmUpdateCalled =$false; + $Global:SPFarmUpdateCalled =$false; Set-TargetResource @testParams Assert-MockCalled Get-SPFarm - $Global:UpdateCalledSPFarmUpdateCalled | Should Be $true + $Global:SPFarmUpdateCalled | Should Be $true } } diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 9bcb0d0bf..583af04e9 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -32,6 +32,7 @@ Describe "xSPWebApplication" { Mock New-SPAuthenticationProvider { } Mock New-SPWebApplication { } + Context "The web application that uses NTLM doesn't exist but should" { Mock Get-SPWebApplication { return $null } @@ -150,5 +151,124 @@ Describe "xSPWebApplication" { Test-TargetResource @testParams | Should Be $true } } + + Context "backwards compatibility: set target resorce works with null/missing BlockedFileTypes" { + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } + Mock Get-SPWebApplication { + $result = @(@{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + }) + $blockedFileTypes= @(); + $blockedFileTypes= $blockedFileTypes | Add-Member ScriptMethod RemoveAll { + $Global:BlockedFilesRemoveAllCalled = $true; + return $true; + } -passThru + $blockedFileTypes= $blockedFileTypes | Add-Member ScriptMethod Add { + param( [string]$fileType) + $Global:BlockedFilesAddCalled = $true; + return $true; + } -passThru + $result= $result | Add-Member -MemberType MemberSet -value $blockedFileTypes -Name "BlockedFileExtensions" + $result = $result | Add-Member -MemberType ScriptMethod Update { + $Global:SPWebApplicationUpdateCalled = $true; + return $true; + + } -PassThru + return $result; + } + + It "calls the new cmdlet from the set method and does not touch blockedFileExtensions" { + $Global:SPWebApplicationUpdateCalled = $false; + $Global:BlockedFilesAddCalled = $false; + $Global:BlockedFilesRemoveAllCalled = $false; + Set-TargetResource @testParams + $Global:BlockedFilesAddCalled| Should be $false; + $Global:BlockedFilesRemoveAllCalled| Should be $false; + $Global:SPWebApplicationUpdateCalled| Should be $false; + Assert-MockCalled New-SPWebApplication + } + + } + + $testParams = @{ + Name = "Managed Metadata Service App" + ApplicationPool = "SharePoint Web Apps" + ApplicationPoolAccount = "DEMO\ServiceAccount" + Url = "http://sites.sharepoint.com" + AuthenticationMethod = "NTLM" + BlockedFileTypes = @("java", "vbs") + } + + + Context "set target resorce works with blockedFileTypes" { + Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } + + Mock Get-SPWebApplication { $result= @(@{ + DisplayName = $testParams.Name + ApplicationPool = @{ + Name = $testParams.ApplicationPool + Username = $testParams.ApplicationPoolAccount + } + ContentDatabases = @( + @{ + Name = "SP_Content_01" + Server = "sql.domain.local" + } + ) + IisSettings = @( + @{ Path = "C:\inetpub\wwwroot\something" } + ) + Url = $testParams.Url + }) + + $blockedFileTypes = new-object PSObject + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod RemoveAll { + $Global:BlockedFilesRemoveAllCalled = $true; + return $true; + } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { + param( [string]$fileType) + $Global:BlockedFilesAddCalled = $true; + return $true; + } -passThru + + $result=$result| Add-Member ScriptMethod Update { + $Global:SPWebApplicationUpdateCalled = $true; + return $true; + } -PassThru + + $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru + + return $result + } + + It "calls the new cmdlet from the set method and does update blockedFileExtensions" { + $Global:BlockedFilesAddCalled = $false; + $Global:BlockedFilesRemoveAllCalled = $false; + Set-TargetResource @testParams + $Global:BlockedFilesAddCalled| Should be $true; + $Global:BlockedFilesRemoveAllCalled| Should be $true; + $Global:SPWebApplicationUpdateCalled| Should be $true; + + Assert-MockCalled Get-SPWebApplication + } + + } + + } } \ No newline at end of file From f55fdf14c4534bc8528d71edeb96114dd16abc0d Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 16 Nov 2015 13:25:50 +0000 Subject: [PATCH 103/147] Added blocked file types, integration and unit tested --- .../MSFT_xSPWebApplication.psm1 | 2 +- .../MSFT_xSPWebApplication.schema.mof | 1 + .../xSharePoint.xSPWebApplication.Tests.ps1 | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index f152c1963..4c06b4dfb 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -107,7 +107,7 @@ function Set-TargetResource write-host "bla" write-debug "bla" if($blockedFileTypes -ne $null){ - $wa.BlockedFileExtensions.RemoveAll(); + $wa.BlockedFileExtensions.Clear(); $blockedFileTypes| % {$wa.BlockedFileExtensions.Add($_) } $wa.Update() } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index fc82bdb44..da434a758 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -13,5 +13,6 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Path; [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Write] string BlockedFileTypes[]; }; diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 583af04e9..d520bfb12 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -184,7 +184,7 @@ Describe "xSPWebApplication" { } -passThru $result= $result | Add-Member -MemberType MemberSet -value $blockedFileTypes -Name "BlockedFileExtensions" $result = $result | Add-Member -MemberType ScriptMethod Update { - $Global:SPWebApplicationUpdateCalled = $true; + $Global:BlockedFilesClearCalled = $true; return $true; } -PassThru @@ -194,10 +194,10 @@ Describe "xSPWebApplication" { It "calls the new cmdlet from the set method and does not touch blockedFileExtensions" { $Global:SPWebApplicationUpdateCalled = $false; $Global:BlockedFilesAddCalled = $false; - $Global:BlockedFilesRemoveAllCalled = $false; + $Global:BlockedFilesClearCalled = $false; Set-TargetResource @testParams $Global:BlockedFilesAddCalled| Should be $false; - $Global:BlockedFilesRemoveAllCalled| Should be $false; + $Global:BlockedFilesClearCalled| Should be $false; $Global:SPWebApplicationUpdateCalled| Should be $false; Assert-MockCalled New-SPWebApplication } @@ -236,8 +236,8 @@ Describe "xSPWebApplication" { }) $blockedFileTypes = new-object PSObject - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod RemoveAll { - $Global:BlockedFilesRemoveAllCalled = $true; + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { + $Global:BlockedFilesClearCalled = $true; return $true; } -passThru $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { @@ -258,10 +258,10 @@ Describe "xSPWebApplication" { It "calls the new cmdlet from the set method and does update blockedFileExtensions" { $Global:BlockedFilesAddCalled = $false; - $Global:BlockedFilesRemoveAllCalled = $false; + $Global:BlockedFilesClearCalled = $false; Set-TargetResource @testParams $Global:BlockedFilesAddCalled| Should be $true; - $Global:BlockedFilesRemoveAllCalled| Should be $true; + $Global:BlockedFilesClearCalled| Should be $true; $Global:SPWebApplicationUpdateCalled| Should be $true; Assert-MockCalled Get-SPWebApplication From 1dae084a26853ba0eff953675f9fe63b6f95d8ef Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 17 Nov 2015 11:40:50 +1100 Subject: [PATCH 104/147] comments addressed, but no test done. commiting so code is available on integration server --- .../MSFT_xSPOutgoingEmailSettings.psm1 | 27 +++++++-------- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 1 + .../MSFT_xSPPasswordChangeSettings.psm1 | 13 +++++--- .../MSFT_xSPPasswordChangeSettings.schema.mof | 1 + .../MSFT_xSPWebApplication.psm1 | 33 ++++++++++++++----- .../MSFT_xSPWebApplication.schema.mof | 2 ++ ...rePoint.xSPOutgoingEmailSettings.Tests.ps1 | 8 ++--- .../xSharePoint.xSPWebApplication.Tests.ps1 | 25 +++++++++----- 8 files changed, 71 insertions(+), 39 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 index 3d7d575ab..ec120c409 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1 @@ -8,27 +8,26 @@ function Get-TargetResource [parameter(Mandatory = $true)] [System.String] $SMTPServer, [parameter(Mandatory = $true)] [System.String] $FromAddress, [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Retrieving outgoing email settings configuration " - $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - - $webApp = $null - $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration + $webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration -ErrorAction SilentlyContinue if ($null -eq $webApp ) { return $null } return @{ - WebAppUrl = $webApp.Url - SMTPServer= $webApp.OutboundMailServiceInstance - FromAddress= $webApp.OutboundMailSenderAddress - ReplyToAddress= $webApp.OutboundMailReplyToAddress - CharacterSet = $webApp.OutboundMailCodePage + WebAppUrl = $webApp.Url + SMTPServer= $webApp.OutboundMailServiceInstance + FromAddress= $webApp.OutboundMailSenderAddress + ReplyToAddress= $webApp.OutboundMailReplyToAddress + CharacterSet = $webApp.OutboundMailCodePage } } return $result @@ -43,11 +42,12 @@ function Set-TargetResource [parameter(Mandatory = $true)] [System.String] $SMTPServer, [parameter(Mandatory = $true)] [System.String] $FromAddress, [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" - Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $webApp = $null Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" @@ -71,7 +71,8 @@ function Test-TargetResource [parameter(Mandatory = $true)] [System.String] $SMTPServer, [parameter(Mandatory = $true)] [System.String] $FromAddress, [parameter(Mandatory = $true)] [System.String] $ReplyToAddress, - [parameter(Mandatory = $true)] [System.String] $CharacterSet + [parameter(Mandatory = $true)] [System.String] $CharacterSet, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index 2d6785787..f1b5295c6 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -6,5 +6,6 @@ class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource [Write] string FromAddress; [Write] string ReplyToAddress; [Write] string CharacterSet; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 index 31f0093cb..ef256a103 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1 @@ -7,12 +7,13 @@ function Get-TargetResource [parameter(Mandatory = $true)][System.String] $MailAddress, [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Retrieving farm wide automatic password change settings" - $result = Invoke-xSharePointCommand -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $farm = Get-SPFarm @@ -35,13 +36,14 @@ function Set-TargetResource [parameter(Mandatory = $true)][System.String] $MailAddress, [parameter(Mandatory = $false)][ValidateRange(0,356 )][System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99 )][System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,99 )][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Updating farm wide automatic password change settings" Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $farm = Get-SPFarm + $farm = Get-SPFarm -ErrorAction Continue if ($null -eq $farm ) { return $null } @@ -70,7 +72,8 @@ function Test-TargetResource [parameter(Mandatory = $true)][System.String] $MailAddress, [parameter(Mandatory = $false)][ValidateRange(0,356)][System.UInt32] $DaysBeforeExpiry, [parameter(Mandatory = $false)][ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, - [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries + [parameter(Mandatory = $false)][ValidateRange(0,99)][System.UInt32] $NumberOfRetries, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index 3ac447092..294cd6b19 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -5,4 +5,5 @@ class MSFT_xSPPasswordChangeSettings : OMI_BaseResource [Write] Uint32 DaysBeforeExpiry; [Write] Uint32 PasswordChangeWaitTimeSeconds; [Write] Uint32 NumberOfRetries; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 4c06b4dfb..f20b2a8e1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -16,7 +16,8 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, + [parameter(Mandatory = $false)][string[]] $AllowedFileTypes ) Write-Verbose -Message "Getting web application '$Name'" @@ -69,7 +70,8 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, + [parameter(Mandatory = $false)][string[]] $AllowedFileTypes ) Write-Verbose -Message "Creating web application '$Name'" @@ -83,6 +85,12 @@ function Set-TargetResource $blockedFileTypes =$params.BlockedFileTypes $params.Remove("BlockedFileTypes") } + $allowedFileTypes = $null + if($params.ContainsKey("AllowedFileTypes")) + { + $allowedFileTypes =$params.BlockedFileTypes + $params.Remove("AllowedFileTypes") + } $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { @@ -104,14 +112,22 @@ function Set-TargetResource $wa = New-SPWebApplication @params } - write-host "bla" - write-debug "bla" - if($blockedFileTypes -ne $null){ - $wa.BlockedFileExtensions.Clear(); - $blockedFileTypes| % {$wa.BlockedFileExtensions.Add($_) } + $blockedFileTypes| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } + } + $allowedFileTypes| % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } + } + if(($allowedFileTypes -ne $null) -or ($blockedFileTypes -ne $null)){ $wa.Update() } + + } } @@ -134,7 +150,8 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes + [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, + [parameter(Mandatory = $false)][string[]] $AllowedFileTypes ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index da434a758..56bb066da 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -14,5 +14,7 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Write] string BlockedFileTypes[]; + [Write] string AllowedFileTypes[]; + }; diff --git a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 index 747f3d304..f3e206d1e 100644 --- a/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPOutgoingEmailSettings.Tests.ps1 @@ -15,7 +15,7 @@ Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName Describe "xSPOutgoingEmailSettings" { InModuleScope $ModuleName { $testParams = @{ - WebAppUrl = "http://sp2013.australiasoutheast.cloudapp.azure.com" + WebAppUrl = "http://sharepoint.contoso.com" SMTPServer = "smtp.contoso.com" FromAddress = "from@email.com" ReplyToAddress = "reply@email.com" @@ -36,7 +36,7 @@ Describe "xSPOutgoingEmailSettings" { } It "returns null from the get method" { - Get-TargetResource @testParams | Should be $null + Get-TargetResource @testParams | Should BeNullOrEmpty } It "returns false from the test method" { @@ -48,7 +48,7 @@ Describe "xSPOutgoingEmailSettings" { Context " Properties match" { Mock Get-SPWebApplication { return @{ - Url= "http://sp2013.australiasoutheast.cloudapp.azure.com" + Url= "http://sharepoint.contoso.com" OutboundMailServiceInstance= "smtp.contoso.com" OutboundMailSenderAddress = "from@email.com" OutboundMailReplyToAddress= "reply@email.com" @@ -70,7 +70,7 @@ Describe "xSPOutgoingEmailSettings" { Context " Properties update tests " { Mock Get-SPWebApplication { $result = @{ - Url= "http://sp2013.australiasoutheast.cloudapp.azure.com" + Url= "http://sharepoint.contoso.com" OutboundMailServiceInstance= "smtp2.contoso.com" OutboundMailSenderAddress = "from@email.com" OutboundMailReplyToAddress= "reply@email.com" diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index d520bfb12..f78d25f2c 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -211,6 +211,7 @@ Describe "xSPWebApplication" { Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" BlockedFileTypes = @("java", "vbs") + AllowedFileTypes = @("exe", "vbs") } @@ -234,26 +235,32 @@ Describe "xSPWebApplication" { ) Url = $testParams.Url }) - $blockedFileTypes = new-object PSObject - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Remove { $Global:BlockedFilesClearCalled = $true; return $true; } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Contains { + param($extension) + if($extension -eq "exe"){ + return $true + } + return $false + } + $Global:BlockedFilesContainsCalled = $true; + return $true; + } -passThru $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { param( [string]$fileType) $Global:BlockedFilesAddCalled = $true; return $true; } -passThru - $result=$result| Add-Member ScriptMethod Update { $Global:SPWebApplicationUpdateCalled = $true; return $true; - } -PassThru - - $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru - - return $result + } -PassThru + $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru + return $result } It "calls the new cmdlet from the set method and does update blockedFileExtensions" { @@ -261,7 +268,7 @@ Describe "xSPWebApplication" { $Global:BlockedFilesClearCalled = $false; Set-TargetResource @testParams $Global:BlockedFilesAddCalled| Should be $true; - $Global:BlockedFilesClearCalled| Should be $true; + $Global:BlockedFilesContainsCalled| Should be $true; $Global:SPWebApplicationUpdateCalled| Should be $true; Assert-MockCalled Get-SPWebApplication From aacd2ad554493e56196cb4acee82896b6e906396 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Tue, 17 Nov 2015 01:05:34 +0000 Subject: [PATCH 105/147] Unit tests updated, integration tests done. --- .../MSFT_xSPWebApplication.psm1 | 20 +++++++++++-------- .../xSharePoint.xSPWebApplication.Tests.ps1 | 7 +++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index f20b2a8e1..29fca0a98 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -80,15 +80,15 @@ function Set-TargetResource $params = $args[0] $blockedFileTypes = $null + $allowedFileTypes = $null if($params.ContainsKey("BlockedFileTypes")) { $blockedFileTypes =$params.BlockedFileTypes $params.Remove("BlockedFileTypes") } - $allowedFileTypes = $null if($params.ContainsKey("AllowedFileTypes")) { - $allowedFileTypes =$params.BlockedFileTypes + $allowedFileTypes =$params.AllowedFileTypes $params.Remove("AllowedFileTypes") } @@ -112,14 +112,18 @@ function Set-TargetResource $wa = New-SPWebApplication @params } - $blockedFileTypes| % { - if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; + if($blockedFileTypes -ne $null){ + $blockedFileTypes| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } } } - $allowedFileTypes| % { - if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) + if($allowedFileTypes -ne $null){ + $allowedFileTypes| % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } } } if(($allowedFileTypes -ne $null) -or ($blockedFileTypes -ne $null)){ diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index f78d25f2c..f98961d86 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -240,15 +240,14 @@ Describe "xSPWebApplication" { $Global:BlockedFilesClearCalled = $true; return $true; } -passThru - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Contains { + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod ContainExtension { param($extension) + $Global:BlockedFilesContainsCalled = $true; if($extension -eq "exe"){ return $true } return $false - } - $Global:BlockedFilesContainsCalled = $true; - return $true; + } -passThru $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { param( [string]$fileType) From e8303b43fbdb502b880399afcc41ff91793bfe5f Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 17 Nov 2015 15:39:18 +1100 Subject: [PATCH 106/147] fixing formatting, again. --- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index f1b5295c6..b6f92db87 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -6,6 +6,6 @@ class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource [Write] string FromAddress; [Write] string ReplyToAddress; [Write] string CharacterSet; - [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; From 53fc82a68d016f4aa524907fb3682d217efc1f78 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 17 Nov 2015 15:42:59 +1100 Subject: [PATCH 107/147] trying formatting again (.mof files were not converting tabs to 4 spaces.) --- .../MSFT_xSPPasswordChangeSettings.schema.mof | 2 +- .../MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof index 294cd6b19..3ff4a1652 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof @@ -5,5 +5,5 @@ class MSFT_xSPPasswordChangeSettings : OMI_BaseResource [Write] Uint32 DaysBeforeExpiry; [Write] Uint32 PasswordChangeWaitTimeSeconds; [Write] Uint32 NumberOfRetries; - [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 56bb066da..2bf064823 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -14,7 +14,7 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Write] string BlockedFileTypes[]; - [Write] string AllowedFileTypes[]; + [Write] string AllowedFileTypes[]; }; From c046da71ed2dcafb8e6bd792704f4e4946e8b0b1 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sat, 21 Nov 2015 11:48:51 +0000 Subject: [PATCH 108/147] adding workflow, throttling, general settings. --- .../MSFT_xSPWebApplication.Set.ps1 | 188 ++++++++++++++++++ Modules/xSharePoint/xSharePoint.psd1 | 1 + .../xSharePoint.xSPWebApplication.Tests.ps1 | 151 ++++++++------ 3 files changed, 281 insertions(+), 59 deletions(-) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 new file mode 100644 index 000000000..c3af6e4d3 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 @@ -0,0 +1,188 @@ +function Set-BlockedFiles($blockedFiles, $wa) +{ + + if($blockedFiles -eq $null){return;} + if($blockedFiles.Blocked -ne $null ){ + $wa.BlockedFileExtensions.Clear(); + $blockedFiles.Blocked| % { + $wa.BlockedFileExtensions.Add($_) ; + + } + } + if($blockedFiles.EnsureBlocked -ne $null){ + $blockedFiles.EnsureBlocked| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } + } + } + if($blockedFiles.EnsureAllowed -ne $null){ + $blockedFiles.EnsureAllowed | % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } + } + } + +} +function Get-ValueOrDefault($input, $attribute, $defaultValue) +{ + try{ + if($input."$attribute" -ne $null) + { + return $input."$attribute" + }else { + return $defaultValue + } + }catch + { + return $defaultValue + } +} +function Set-GeneralSettings($generalSettings, $wa) +{ + if($generalSettings -eq $null){ return;} + + #TODO: Quota Template + $wa.DefaultTimeZone =Get-ValueOrDefault $generalSettings "TimeZone" $wa.DefaultTimeZone + $wa.AlertsEnabled = Get-ValueOrDefault $generalSettings "Alerts" $wa.AlertsEnabled + $wa.AlertsMaximum = Get-ValueOrDefault $generalSettings "AlertsLimit" $wa.AlertsMaximum + $wa.SyndicationEnabled = Get-ValueOrDefault $generalSettings "RSS" $wa.RSS + $wa.MetaWeblogEnabled = Get-ValueOrDefault $generalSettings "BlogAPI" $wa.BlogAPI + $wa.MetaWeblogAuthenticationEnabled = Get-ValueOrDefault $generalSettings "BlogAPIAuthenticated" $wa.BlogAPIAuthenticated + $wa.BrowserFileHandling = Get-ValueOrDefault $generalSettings "BrowserFileHandling" $wa.BrowserFileHandling + $wa.FormDigestSettings.Enabled = Get-ValueOrDefault $generalSettings "SecurityValidation" $wa.FormDigestSettings.Enabled + $wa.MaximumFileSize = Get-ValueOrDefault $generalSettings "MaximumUploadSize" $wa.MaximumUploadSize + $wa.RecycleBinEnabled = Get-ValueOrDefault $generalSettings "RecycleBinEnabled" $wa.RecycleBinEnabled + $wa.RecycleBinCleanupEnabled = Get-ValueOrDefault $generalSettings "RecycleBinCleanupEnabled" $wa.RecycleBinCleanupEnabled + $wa.RecycleBinRetentionPeriod = Get-ValueOrDefault $generalSettings "RecycleBinRetentionPeriod" $wa.RecycleBinRetentionPeriod + $wa.SecondStageRecycleBinQuota = Get-ValueOrDefault $generalSettings "SecondStageRecycleBinEnabled" $wa.SecondStageRecycleBinQuota + $wa.BrowserCEIPEnabled = Get-ValueOrDefault $generalSettings "CustomerExperienceProgram" $wa.BrowserCEIPEnabled + $wa.PresenceEnabled = Get-ValueOrDefault $generalSettings "Presence" $wa.BrowserCEIPEnabled + $wa.Update(); +} +function Set-WorkflowSettings ($workflowSettings, $wa) +{ + if($workflowSettings -eq $null ){ return;} + if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ + $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; + } + if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ + $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; + } + if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ + $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; + } + + $wa.UpdateWorkflowConfigurationSettings(); + $wa.Update(); +} + +function Set-ThrottlingSettings ($throttlingSettings, $wa) +{ + if($throttlingSettings -eq $null){ return;} + if($throttlingSettings.ListViewThreshold -ne $null ){ + $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold + } + if($throttlingSettings.AllowObjectModelOverride -ne $null){ + $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride + } + if($throttlingSettings.AdminThreshold -ne $null){ + $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold + } + if($throttlingSettings.ListViewLookupThreshold -ne $null){ + $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold + } + if($throttlingSettings.HappyHourEnabled -ne $null){ + $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled + } + if($throttlingSettings.HappyHour -ne $null){ + $happyHour =$throttlingSettings.HappyHour; + if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ + if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ + $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour + $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute + $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration + }else{ + throw "the valid range hour, minute and duration is 0-24"; + } + + }else { + throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; + } + } + if($throttlingSettings.UniquePermissionThreshold){ + $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold + } + if($throttlingSettings.EventHandlersEnabled){ + $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled + } + if($throttlingSettings.RequestThrottling){ + $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling + } + if($throttlingSettings.ChangeLogEnabled){ + $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled + } + if($throttlingSettings.ChangeLogExpiryDays){ + $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays + } + $wa.Update(); +} + +function GetAndRemove-Parameter($params, $name){ + $result =$null + if($params.ContainsKey($name)) + { + $result = $params.$name + $params.Remove( $name) + } + return $result; +} +function Sanitize-ComplexTypes{ + param( + [Parameter(Position = 0)] + + $params + ) + +$blocked =GetAndRemove-Parameter $params "BlockedFileTypes" + return @{ + GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" + WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" + Extensions = GetAndRemove-Parameter $params "Extensions" + ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" + BlockedFileTypes = $blocked + } +} + + +$params = $args[0] + +$settings = Sanitize-ComplexTypes $params + +$wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue +if ($null -eq $wa) { + if ($params.ContainsKey("AuthenticationMethod") -eq $true) { + if ($params.AuthenticationMethod -eq "NTLM") { + $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos + } else { + $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication + } + $params.Remove("AuthenticationMethod") + $params.Add("AuthenticationProvider", $ap) + } + + if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } + if ($params.ContainsKey("AllowAnonymous")) { + $params.Remove("AllowAnonymous") | Out-Null + $params.Add("AllowAnonymousAccess", $true) + } + + $wa = New-SPWebApplication @params +} + +Set-ThrottlingSettings $settings.ThrottlingSettings $wa +Set-WorkflowSettings $settings.WorkflowSettings $wa +Set-BlockedFiles $settings.BlockedFileTypes $wa +Set-GeneralSettings $settings.GeneralSettings $wa + \ No newline at end of file diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index 7d7cf4054..6258016ac 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -98,5 +98,6 @@ AliasesToExport = '*' # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # DefaultCommandPrefix = '' + } diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index f98961d86..3ce3df3e4 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -21,6 +21,7 @@ Describe "xSPWebApplication" { Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") Mock Invoke-xSharePointCommand { @@ -32,7 +33,6 @@ Describe "xSPWebApplication" { Mock New-SPAuthenticationProvider { } Mock New-SPWebApplication { } - Context "The web application that uses NTLM doesn't exist but should" { Mock Get-SPWebApplication { return $null } @@ -151,74 +151,69 @@ Describe "xSPWebApplication" { Test-TargetResource @testParams | Should Be $true } } + - Context "backwards compatibility: set target resorce works with null/missing BlockedFileTypes" { - Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } - Mock Get-SPWebApplication { - $result = @(@{ - DisplayName = $testParams.Name - ApplicationPool = @{ - Name = $testParams.ApplicationPool - Username = $testParams.ApplicationPoolAccount - } - ContentDatabases = @( - @{ - Name = "SP_Content_01" - Server = "sql.domain.local" - } - ) - IisSettings = @( - @{ Path = "C:\inetpub\wwwroot\something" } - ) - Url = $testParams.Url - }) - $blockedFileTypes= @(); - $blockedFileTypes= $blockedFileTypes | Add-Member ScriptMethod RemoveAll { - $Global:BlockedFilesRemoveAllCalled = $true; - return $true; - } -passThru - $blockedFileTypes= $blockedFileTypes | Add-Member ScriptMethod Add { - param( [string]$fileType) - $Global:BlockedFilesAddCalled = $true; - return $true; - } -passThru - $result= $result | Add-Member -MemberType MemberSet -value $blockedFileTypes -Name "BlockedFileExtensions" - $result = $result | Add-Member -MemberType ScriptMethod Update { - $Global:BlockedFilesClearCalled = $true; - return $true; - - } -PassThru - return $result; - } - - It "calls the new cmdlet from the set method and does not touch blockedFileExtensions" { - $Global:SPWebApplicationUpdateCalled = $false; - $Global:BlockedFilesAddCalled = $false; - $Global:BlockedFilesClearCalled = $false; - Set-TargetResource @testParams - $Global:BlockedFilesAddCalled| Should be $false; - $Global:BlockedFilesClearCalled| Should be $false; - $Global:SPWebApplicationUpdateCalled| Should be $false; - Assert-MockCalled New-SPWebApplication - } - - } $testParams = @{ - Name = "Managed Metadata Service App" - ApplicationPool = "SharePoint Web Apps" + Name = "Complex types Web App" + ApplicationPool = "SharePoint complex type Web App" ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = @("java", "vbs") - AllowedFileTypes = @("exe", "vbs") - } + BlockedFileTypes = @{ + Blocked = @("java", "vbs", "exe","xxx") + EnsureBlocked = @("java", "rar", "exe","xxx") + EnsureAllowed = @("exe", "vbs","zip") + } + WorkflowSettings = @{ + ExternalWorkflowParticipantsEnabled=$false + UserDefinedWorkflowsEnabled=$true + EmailToNoPermissionWorkflowParticipantsEnable=$false + } + ThrottlingSettings = @{ + ListViewThreshold = 10000 + AllowObjectModelOverride = $true + AdminThreshold=55000 + ListViewLookupThreshold=10 + HappyHourEnabled= $true + HappyHour = @{ + Hour = 20 + Minute = 5 + Duration = 2 + } + UniquePermissionThreshold = 133000 + RequestThrottling=$false + ChangeLogEnabled=$true + ChangeLogExpiryDays = 19 + EventHandlersEnabled=$true + } + GeneralSettings=@{ + TimeZone = 10 + DefaultQuotaTemplate = "" + Alerts = $true + AlertsLimit = 10 + RSS = $true + BlogAPI = $true + BlogAPIAuthenticated = $true + BrowserFileHandling = "Permissive" + SecurityValidation = $true + RecycleBinEnabled = $true + SecondStageRecycleBinEnabled = $true + RecycleBinCleanupEnabled = $true + RecycleBinRetentionPeriod = 10 + SecondStageRecycleBinQuota = 500 + MaximumUploadSize = 555 + CustomerExperienceProgram = $true + PresenceEnabled = $true + } + } - Context "set target resorce works with blockedFileTypes" { + Context "set target resorce works with complex types filled in" { Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } - Mock Get-SPWebApplication { $result= @(@{ + $mockedapp= { + $result= @(@{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool @@ -234,13 +229,44 @@ Describe "xSPWebApplication" { @{ Path = "C:\inetpub\wwwroot\something" } ) Url = $testParams.Url + MaxItemsPerThrottledOperation=5000 + AllowOMCodeOverrideThrottleSettings=$true + MaxItemsPerThrottledOperationOverride = 10000 + MaxQueryLookupFields = 8 + UnthrottledPrivilegedOperationWindowEnabled =$true + DailyStartUnthrottledPrivilegedOperationsHour = $null + DailyStartUnthrottledPrivilegedOperationsMinute = $null + DailyUnthrottledPrivilegedOperationsDuration = $null + + MaxUniquePermScopesPerList = 50000 + EventHandlersEnabled = $true + HttpThrottleSettings = @{ + PerformThrottle = $true + } + FormDigestSettings = @{ + Enabled =$true + } + ChangeLogExpirationEnabled = $true + ChangeLogRetentionPeriod = New-TimeSpan -Days 10 }) + + $result= $result | Add-Member ScriptMethod UpdateWorkflowConfigurationSettings { + $Global:UpdateWorkflowCalled = $true; + } -PassThru + $blockedFileTypes = new-object PSObject + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Remove { + $Global:BlockedFilesRemoveCalled = $true; + return $true; + } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { $Global:BlockedFilesClearCalled = $true; return $true; } -passThru + $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod ContainExtension { + param($extension) $Global:BlockedFilesContainsCalled = $true; if($extension -eq "exe"){ @@ -254,6 +280,7 @@ Describe "xSPWebApplication" { $Global:BlockedFilesAddCalled = $true; return $true; } -passThru + $result=$result| Add-Member ScriptMethod Update { $Global:SPWebApplicationUpdateCalled = $true; return $true; @@ -261,14 +288,20 @@ Describe "xSPWebApplication" { $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru return $result } + Mock Get-SPWebApplication $mockedapp + Mock New-SPWebApplication $mockedapp It "calls the new cmdlet from the set method and does update blockedFileExtensions" { $Global:BlockedFilesAddCalled = $false; $Global:BlockedFilesClearCalled = $false; + $Global:BlockedFilesRemoveCalled = $false; + $Global:BlockedFilesContainsCalled = $false; + $Global:SPWebApplicationUpdateCalled =$false ; Set-TargetResource @testParams $Global:BlockedFilesAddCalled| Should be $true; $Global:BlockedFilesContainsCalled| Should be $true; $Global:SPWebApplicationUpdateCalled| Should be $true; + $Global:BlockedFilesRemoveCalled| Should be $true; Assert-MockCalled Get-SPWebApplication } From 56c56d55b8510d69dbe43298739f386eed5c94ce Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sat, 21 Nov 2015 11:57:07 +0000 Subject: [PATCH 109/147] resynching. added Web Application Settings for Workflow, Throttling, General and Blocked Files --- .../MSFT_xSPWebApplication.psm1 | 222 +++++++++++++++--- .../MSFT_xSPWebApplication.schema.mof | Bin 683 -> 5844 bytes 2 files changed, 189 insertions(+), 33 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 29fca0a98..7490ef62a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -1,3 +1,26 @@ +function GetAndRemove-Parameter($params, $name){ + $result =$null + if($params.ContainsKey($name)) + { + $result = $params.$name + $params.Remove( $name) + } + return $result; +} +function Sanitize-ComplexTypes{ + param( + [Parameter(Position = 0)] + $params + ) + return @{ + GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" + WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" + Extensions = GetAndRemove-Parameter $params "Extensions" + ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" + BlockedFileTypes = GetAndRemove-Parameter $params "BlockedFileTypes" + } +} + function Get-TargetResource { [CmdletBinding()] @@ -16,8 +39,10 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, - [parameter(Mandatory = $false)][string[]] $AllowedFileTypes + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) Write-Verbose -Message "Getting web application '$Name'" @@ -46,7 +71,6 @@ function Get-TargetResource Port = (New-Object System.Uri $wa.Url).Port AuthenticationMethod = $localAuthMode InstallAccount = $params.InstallAccount - BlockedFileTypes = $wa.BlockedFileExtensions } } return $result @@ -70,28 +94,21 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, - [parameter(Mandatory = $false)][string[]] $AllowedFileTypes + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) Write-Verbose -Message "Creating web application '$Name'" - + $settings = Sanitize-ComplexTypes $PSBoundParameters + $PSBoundParameters.Add("Settings", $settings) + Write-Verbose -Message "Creating web application '$Name'" $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - - $blockedFileTypes = $null - $allowedFileTypes = $null - if($params.ContainsKey("BlockedFileTypes")) - { - $blockedFileTypes =$params.BlockedFileTypes - $params.Remove("BlockedFileTypes") - } - if($params.ContainsKey("AllowedFileTypes")) - { - $allowedFileTypes =$params.AllowedFileTypes - $params.Remove("AllowedFileTypes") - } + $settings =$params.Settings + $params.Remove("Settings") | Out-Null $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { if ($params.ContainsKey("AuthenticationMethod") -eq $true) { @@ -112,26 +129,163 @@ function Set-TargetResource $wa = New-SPWebApplication @params } - if($blockedFileTypes -ne $null){ - $blockedFileTypes| % { - if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; - } +#region throttling settings + + $throttlingSettings = $settings.ThrottlingSettings + + if($throttlingSettings -ne $null){ + if($throttlingSettings.ListViewThreshold -ne $null ){ + $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold } - } - if($allowedFileTypes -ne $null){ - $allowedFileTypes| % { - if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) + if($throttlingSettings.AllowObjectModelOverride -ne $null){ + $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride + } + if($throttlingSettings.AdminThreshold -ne $null){ + $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold + } + if($throttlingSettings.ListViewLookupThreshold -ne $null){ + $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold + } + if($throttlingSettings.HappyHourEnabled -ne $null){ + $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled + } + if($throttlingSettings.HappyHour -ne $null){ + $happyHour =$throttlingSettings.HappyHour; + if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ + if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ + $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour + $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute + $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration + }else{ + throw "the valid hour, minute and duration range is 0-24"; + } + + }else { + throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; } } + if($throttlingSettings.UniquePermissionThreshold){ + $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold + } + if($throttlingSettings.EventHandlersEnabled){ + $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled + } + if($throttlingSettings.RequestThrottling){ + $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling + } + if($throttlingSettings.ChangeLogEnabled){ + $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled + } + if($throttlingSettings.ChangeLogExpiryDays){ + $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays + } } - if(($allowedFileTypes -ne $null) -or ($blockedFileTypes -ne $null)){ - $wa.Update() +#endregion +#region WorkflowSettings + #Set-WorkflowSettings $settings.WorkflowSettings $wa + $workflowSettings = $settings.WorkflowSettings + if($workflowSettings -ne $null ){ + if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ + $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; + } + if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ + $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; + } + if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ + $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; + } + + $wa.UpdateWorkflowConfigurationSettings(); } +#endregion + Write-Verbose "applying extended settings" +#region blockedFiles + $blockedFiles= $settings.BlockedFileTypes + if($blockedFiles -ne $null){ + if($blockedFiles.Blocked -ne $null ){ + $wa.BlockedFileExtensions.Clear(); + $blockedFiles.Blocked| % { + $wa.BlockedFileExtensions.Add($_) ; + } + } + if($blockedFiles.EnsureBlocked -ne $null){ + $blockedFiles.EnsureBlocked| % { + if(!$wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Add($_) ; + } + } + } + if($blockedFiles.EnsureAllowed -ne $null){ + $blockedFiles.EnsureAllowed | % { + if($wa.BlockedFileExtensions.ContainExtension($_)){ + $wa.BlockedFileExtensions.Remove($_) + } + } + } + } +#endregion +#region General settings + + $generalSettings = $settings.GeneralSettings + if($generalSettings -ne $null){ + #TODO: Quota Template + if($generalSettings.TimeZone -ne $null){ + $wa.DefaultTimeZone =$generalSettings.TimeZone + } + if($generalSettings.Alerts -ne $null){ + $wa.AlertsEnabled = $generalSettings.Alerts + } + if($generalSettings.AlertsLimit -ne $null){ + $wa.AlertsMaximum = $generalSettings.AlertsLimit + } + if($generalSettings.RSS -ne $null){ + $wa.SyndicationEnabled = $generalSettings.RSS + } + if($generalSettings.AlertsLimit){ + $wa.MetaWeblogEnabled = $generalSettings.BlogAPI + } + if($generalSettings.BlogAPIAuthenticated){ + $wa.MetaWeblogAuthenticationEnabled = $generalSettings.BlogAPIAuthenticated + } + if($generalSettings.BrowserFileHandling){ + $wa.BrowserFileHandling = $generalSettings.BrowserFileHandling + } + if($generalSettings.SecurityValidation){ + $wa.FormDigestSettings.Enabled = $generalSettings.SecurityValidation + } + if($generalSettings.MaximumUploadSize){ + $wa.MaximumFileSize = $generalSettings.MaximumUploadSize + } + if($generalSettings.RecycleBinEnabled){ + $wa.RecycleBinEnabled = $generalSettings.RecycleBinEnabled + } + if($generalSettings.RecycleBinCleanupEnabled){ + $wa.RecycleBinCleanupEnabled = $generalSettings.RecycleBinCleanupEnabled + } + if($generalSettings.RecycleBinRetentionPeriod){ + $wa.RecycleBinRetentionPeriod = $generalSettings.RecycleBinRetentionPeriod + } + if($generalSettings.SecondStageRecycleBinEnabled){ + $wa.SecondStageRecycleBinQuota = $generalSettings.SecondStageRecycleBinEnabled + } + if($generalSettings.CustomerExperienceProgram){ + $wa.BrowserCEIPEnabled = $generalSettings.CustomerExperienceProgram + } + if($generalSettings.Presence -ne $null){ + $wa.PresenceEnabled = $generalSettings.Presence + } + } + if( ($settings.WorkflowSettings -ne $null) -or + ($settings.GeneralSettings -ne $null) -or + ($settings.ThrottlingSettings -ne $null) -or + ($settings.BlockedFileTypes -ne $null) + ){ + $wa.Update() + } +#endregion } } @@ -154,8 +308,10 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)][string[]] $BlockedFileTypes, - [parameter(Mandatory = $false)][string[]] $AllowedFileTypes + [parameter(Mandatory = $false)] $GeneralSettings, + [parameter(Mandatory = $false)] $WorkflowSettings, + [parameter(Mandatory = $false)] $ThrottlingSettings, + [parameter(Mandatory = $false)] $BlockedFileTypes ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 2bf0648237f415202e242dddf40f94c40a4aa806..0c937454310a0f0bb288498cc331bbf0369b1da5 100644 GIT binary patch literal 5844 zcmc&&T~8W86ur+)`X2~SZPGOTcx#^kv6_lf1x;#5v%rd5myZHgw@v?g+jC}Emzf=B z*+?`5S(m+M?mhRLe}B)VA+ZFq!0S{(nd38(sZ8XBROPL_mN)8Mm6y_!=kjdr`HHmU zM0TYk-{cloZCpn{3xUy*L}u!WGQX8%MfB@jZg5T{OMKsh+*18FkrBSHLw+g)xx#lt zImh=OHxEncE!-MT4f;@{8%v)*E4{YM-x*HnOAXA;aB2h|0EFgV~&k*sT5gF^3z>N{DK7RUmhEIj?;sn0P;_3(<|Bm|uV7Kth5ZAFB z$xnRF@ru+PAGWDy4bP92*UD*VqS)3RDE+VC)!73r&&M(IHUJA`C(q)U;()c{6?kjH zw!V6fJPl=E<@{2yI=~%PExRg}%PL*zDpp;}YrVNgy3jF_AK)%TjiguUA68tQ+2#CX zN76A6H8!Ku73V%pZL|iWnGreyDt$fz<38`KS8_9gTu8Two(T3QvV&6+Fi=LfrpgJ{ zGkRkJ?=xc9v3xo{UClWIe{*!Q3+TxXasq8xe^`@8(7LGp*uH6^%Q6q<$|JGZ_-(K< zSNH>*F;g5Z3)nGxv3+6}(mZbme=n5Y%sKm9KmYy{n9l)_V?^#$4)Jznh<)NFmg>lQ znr>6p(`M#$z{ePje+3&8eEM?4oSw9w0#uq9aqtD7?05mV4S~p+f*sk9XvY9M6=Q&r zfwv{WPw~mha!xAt#J3q9d)NT|V4z~H4$ddun(nVDT07>>P_YuI zZnoVsTxi^+^nAxD$?QoLZ#On`vTl3gvXiN|~2*Z?$dc z!M$kPcr{oyP&P95%cFN;M_#LJ7omN2ykpAz_ zd(Y`+EQm2H(1t77!*@5g<;DF03N#1FL@_6O=;5z8T0`n*nc$RI$Ho1`qh&1$<6yb{ zgQI)&98R|*VqgJA<(h(b@Q^#3859XJR&)7^O7-FCc>(V^*TBwLt6QX$_$SS$ROQlM zW54J|Xsx-01f@eH7>7JHSOy1e2H(29s0LXsWueEAgO0iJ@q61A;SFu6rXaeI6_>Se>wX|DEbC0-~yIK24<6V&Qay? Ki{>4Np7#wkM&;rF From 375abc7b7aa2c808c8d49faa424fe9d997a4410c Mon Sep 17 00:00:00 2001 From: camiloborges Date: Sun, 22 Nov 2015 09:04:42 +1100 Subject: [PATCH 110/147] fixing xSPWebApplication.schema encoding --- .../MSFT_xSPWebApplication.schema.mof | Bin 5844 -> 2838 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 0c937454310a0f0bb288498cc331bbf0369b1da5..a4907fe808bd39988432e9b9de995cd5a082d1ba 100644 GIT binary patch literal 2838 zcmbVOO;6iE5WVMDSUFJ%RkXd8QwX6!B;eu%q@oCI>>=5*-gWl_;v#-o5B*8~3!Qa# zV{b4hBFD_^+nKj-=K0^Bzc+nGl)3_`sNj3uPah9H9&|smQP$D2Kwxu*%3#uD^VaY$T}A2gZ~e4XvSLBP-~`PUoFPO_ow<&5)}5IS?QmOnj)b^3MSH5hdBf>| zlQ{!l-nD)I{b-QSAJbZW4?ajK!n9v-42p+23sRw%@hUxD{XflDkU}S58ed9fRAss%VgI`BRG^e`t zjW3g=^?%%Di(Y*CR;*|A5(Q%S(q?2To$W_ggc%r<;;CypNp*L>>nVPK?z2l!F1!`p z49}4ikNBc?F;^-?!K~|PZeUMA0;$1yE%9oaxpmgq;y&#X(lTXmM0p_SEg>P8;8~){ z0(Lu4XZ7taGlfHs0s`He)XA5iErWt1J5>0+6AWu>DU~AHpvPoIbCXXCCPOs|(_$$WlH>uT&yI0v+nfzyt;6qJbw4_>h#4!-Nsg-$jWyho)_7Cv z#~b4fggH=v*4$dc|G3xvb%^7$RsvD^%3^g(az1(QT z72()8CYsEVu?8#c2?=VBo}X|C&646~1KWYtbs!yqeD zWh^BBZJZa9^82*``wciq!hEDz`0j@8y}+Y1@V7(nyP)>+26X+Wzjs&g`U|!J=RQhp KtopcJ+t`2dfYP%7 literal 5844 zcmc&&T~8W86ur+)`X2~SZPGOTcx#^kv6_lf1x;#5v%rd5myZHgw@v?g+jC}Emzf=B z*+?`5S(m+M?mhRLe}B)VA+ZFq!0S{(nd38(sZ8XBROPL_mN)8Mm6y_!=kjdr`HHmU zM0TYk-{cloZCpn{3xUy*L}u!WGQX8%MfB@jZg5T{OMKsh+*18FkrBSHLw+g)xx#lt zImh=OHxEncE!-MT4f;@{8%v)*E4{YM-x*HnOAXA;aB2h|0EFgV~&k*sT5gF^3z>N{DK7RUmhEIj?;sn0P;_3(<|Bm|uV7Kth5ZAFB z$xnRF@ru+PAGWDy4bP92*UD*VqS)3RDE+VC)!73r&&M(IHUJA`C(q)U;()c{6?kjH zw!V6fJPl=E<@{2yI=~%PExRg}%PL*zDpp;}YrVNgy3jF_AK)%TjiguUA68tQ+2#CX zN76A6H8!Ku73V%pZL|iWnGreyDt$fz<38`KS8_9gTu8Two(T3QvV&6+Fi=LfrpgJ{ zGkRkJ?=xc9v3xo{UClWIe{*!Q3+TxXasq8xe^`@8(7LGp*uH6^%Q6q<$|JGZ_-(K< zSNH>*F;g5Z3)nGxv3+6}(mZbme=n5Y%sKm9KmYy{n9l)_V?^#$4)Jznh<)NFmg>lQ znr>6p(`M#$z{ePje+3&8eEM?4oSw9w0#uq9aqtD7?05mV4S~p+f*sk9XvY9M6=Q&r zfwv{WPw~mha!xAt#J3q9d)NT|V4z~H4$ddun(nVDT07>>P_YuI zZnoVsTxi^+^nAxD$?QoLZ#On`vTl3gvXiN|~2*Z?$dc z!M$kPcr{oyP&P95%cFN;M_#LJ7omN2yk Date: Sun, 22 Nov 2015 09:09:32 +1100 Subject: [PATCH 111/147] :( testing encoding to utf-8 again --- .../MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index a4907fe80..0e294dabd 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -17,7 +17,7 @@ Class MSFT_xSPWebApplicationHappyHour Class MSFT_xSPWebApplicationThrottling { [write]uint32 ListViewThreshold; - [write]boolean AllowObjectModelOverride; + [write]boolean AllowObjectModelOverride; [write]uint32 AdminThreshold; [write]uint32 ListViewLookupThreshold; [write]boolean HappyHourEnabled; From b132dc9e1d292f7756412d0dd175c66c9a5deb49 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 22 Nov 2015 09:35:23 +0000 Subject: [PATCH 112/147] updating files with same changes as https://github.com/BrianFarnhill/xSharePoint/commit/b63c94fa43ba44924aff4dee749feab37c93c3e5 --- .../MSFT_xSPWebApplication.psm1 | 6 +-- .../MSFT_xSPWebApplication.schema.mof | 13 ++--- .../xSharePoint/xSharePoint.Global.Tests.ps1 | 15 +++--- .../xSharePoint/xSharePoint.TestHelpers.psm1 | 47 ++++++++++++++----- 4 files changed, 54 insertions(+), 27 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 7490ef62a..4edb6efd1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -205,21 +205,21 @@ function Set-TargetResource if($blockedFiles.Blocked -ne $null ){ $wa.BlockedFileExtensions.Clear(); $blockedFiles.Blocked| % { - $wa.BlockedFileExtensions.Add($_) ; + $wa.BlockedFileExtensions.Add($_); } } if($blockedFiles.EnsureBlocked -ne $null){ $blockedFiles.EnsureBlocked| % { if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; + $wa.BlockedFileExtensions.Add($_); } } } if($blockedFiles.EnsureAllowed -ne $null){ $blockedFiles.EnsureAllowed | % { if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) + $wa.BlockedFileExtensions.Remove($_); } } } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 0e294dabd..629c937ab 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,11 +1,12 @@ -[ClassVersion("1.0.0")] +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationHappyHour")] Class MSFT_xSPFilesTypes { [write]String Blocked[]; [write]String EnsureBlocked[]; [write]String EnsureAllowed[]; }; -[ClassVersion("1.0.0")] + +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationHappyHour")] Class MSFT_xSPWebApplicationHappyHour { [write] uint32 Hour; @@ -13,7 +14,8 @@ Class MSFT_xSPWebApplicationHappyHour [write] uint32 Duration; }; -[ClassVersion("1.0.0")] + +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationThrottling")] Class MSFT_xSPWebApplicationThrottling { [write]uint32 ListViewThreshold; @@ -30,7 +32,7 @@ Class MSFT_xSPWebApplicationThrottling }; -[ClassVersion("1.0.0")] +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationWorkflowSettings")] Class MSFT_xSPWebApplicationWorkflowSettings { [write]boolean ExternalWorkflowParticipantsEnabled; @@ -38,7 +40,7 @@ Class MSFT_xSPWebApplicationWorkflowSettings [write]boolean EmailToNoPermissionWorkflowParticipantsEnable; }; -[ClassVersion("1.0.0")] +[ClassVersion("1.0.0"), FriendlyName("xSPWebApplicationSettings")] Class MSFT_xSPWebApplicationSettings { [write]uint32 TimeZone; @@ -49,7 +51,6 @@ Class MSFT_xSPWebApplicationSettings [write]boolean BlogAPI; [write]boolean BlogAPIAuthenticated; [write, ValueMap{"Strict","Permissive"}, Values{"Stric","Permissive"}] String BrowserFileHandling; - [write]boolean SecurityValidation; [write]boolean RecycleBinEnabled; [write]boolean SecondStageRecycleBinEnabled; diff --git a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 index cfe9684bf..c1f212a9e 100644 --- a/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.Global.Tests.ps1 @@ -2,7 +2,6 @@ param( [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) - $ErrorActionPreference = 'stop' Set-StrictMode -Version latest @@ -22,11 +21,13 @@ Describe 'xSharePoint whole of module tests' { $mofFiles | ForEach-Object { $fileHasInstallAccount = $false - $mofSchema = Get-MofSchemaObject $_.FullName - $installAccount = $mofSchema.Attributes | Where-Object { $_.Name -eq "InstallAccount" } - if (($null -ne $installAccount) -and ($installAccount.State -eq "Required")) { - $mofFilesWithNoInstallAccount += 1 - Write-Warning "File $($_.FullName) has InstallAccount listed as a required parameter. After v0.6 of xSharePoint this should be changed to 'write' instead of 'required'" + $mofSchemas = Get-MofSchemaObject $_.FullName + foreach($mofSchema in $mofSchemas) { + $installAccount = $mofSchema.Attributes | Where-Object { $_.Name -eq "InstallAccount" } + if (($null -ne $installAccount) -and ($installAccount.State -eq "Required")) { + $mofFilesWithNoInstallAccount += 1 + Write-Warning "File $($_.FullName) has InstallAccount listed as a required parameter. After v0.6 of xSharePoint this should be changed to 'write' instead of 'required'" + } } } $mofFilesWithNoInstallAccount | Should Be 0 @@ -92,4 +93,4 @@ Describe 'xSharePoint whole of module tests' { $errors.Count | Should Be 0 } } -} \ No newline at end of file +} diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 index 0d2001041..17b735acc 100644 --- a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 +++ b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 @@ -5,31 +5,55 @@ function Get-MofSchemaObject() { ) $contents = Get-Content $fileName - $results = @{ + $results = @() + + $currentResult = @{ ClassVersion = $null FriendlyName = $null ClassName = $null Attributes = @() + Documentation = $null } + $currentComment = "" + $currentlyInCommentBlock = $false foreach($textLine in $contents) { - if ($textLine.Contains("ClassVersion") -or $textLine.Contains("ClassVersion")) { + if ($textLine.StartsWith("/*")) { + $currentlyInCommentBlock = $true + } elseif($textLine.StartsWith("*/")) { + $currentlyInCommentBlock = $false + $currentResult.Documentation = $currentComment + } elseif($currentlyInCommentBlock -eq $true) { + $currentComment += $textLine + [Environment]::NewLine + } elseif ($textLine -match "ClassVersion" -or $textLine -match "FriendlyName") { if ($textLine -match "ClassVersion(`"*.`")") { $start = $textLine.IndexOf("ClassVersion(`"") + 14 $end = $textLine.IndexOf("`")", $start) - $results.ClassVersion = $textLine.Substring($start, $end - $start) + $currentResult.ClassVersion = $textLine.Substring($start, $end - $start) } if ($textLine -match "FriendlyName(`"*.`")") { $start = $textLine.IndexOf("FriendlyName(`"") + 14 $end = $textLine.IndexOf("`")", $start) - $results.FriendlyName = $textLine.Substring($start, $end - $start) + $currentResult.FriendlyName = $textLine.Substring($start, $end - $start) } - } elseif ($textLine.Contains("class ")) { - $start = $textLine.IndexOf("class ") + 6 + } elseif ($textLine -match "class ") { + $start = $textLine.ToLower().IndexOf("class ") + 6 $end = $textLine.IndexOf(" ", $start) - $results.ClassName = $textLine.Substring($start, $end - $start) - } elseif ($textLine.Trim() -eq "{" -or $textLine.Trim() -eq "};" -or [string]::IsNullOrEmpty($textLine)) { + if ($end -eq -1) { + $end = $textLine.Length + } + $currentResult.ClassName = $textLine.Substring($start, $end - $start) + } elseif ($textLine.Trim() -eq "{" -or [string]::IsNullOrEmpty($textLine.Trim())) { + } elseif ($textLine.Trim() -eq "};") { + $results += $currentResult + $currentResult = @{ + ClassVersion = $null + FriendlyName = $null + ClassName = $null + Attributes = @() + Documentation = $null + } } else { $attributeValue = @{ State = $null @@ -66,7 +90,7 @@ function Get-MofSchemaObject() { $attributeValue.DataType = $nonMetadataObjects[1] $attributeValue.Name = $nonMetadataObjects[2] - $results.Attributes += $attributeValue + $currentResult.Attributes += $attributeValue } } return $results @@ -78,7 +102,8 @@ function Assert-MofSchemaScriptParameters() { [string]$mofFileName ) $hasErrors = $false - $mofData = Get-MofSchemaObject -fileName $mofFileName + $mofSchemas = Get-MofSchemaObject -fileName $mofFileName + $mofData = $mofSchemas | Where-Object { $_.ClassName -eq $mofFileName.Replace(".schema.mof", "") } $psFile = $mofFileName.Replace(".schema.mof", ".psm1") $tokens = $null @@ -190,4 +215,4 @@ function Get-ParseErrors { return $errors } -Export-ModuleMember * \ No newline at end of file +Export-ModuleMember * From 472a13392bf32c5e107748802dbd4ac01ace0619 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Mon, 30 Nov 2015 23:30:33 +1100 Subject: [PATCH 113/147] updating util --- .../xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 29c153d39..196bc3c7e 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -186,7 +186,7 @@ function Test-xSharePointSpecificParameters() { } } } - } + } } return $returnValue } From 43fc642d94e5561d9f5839874a292d241a81f6b7 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Mon, 30 Nov 2015 23:42:25 +1100 Subject: [PATCH 114/147] :( --- Modules/xSharePoint/xSharePoint.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index 751449604..618134ceb 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -96,7 +96,7 @@ AliasesToExport = '*' # HelpInfo URI of this module # HelpInfoURI = '' -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -prefix. # DefaultCommandPrefix = '' From 8c06aed57064f8cced2e64d97ff3b196d6716c19 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 30 Nov 2015 13:09:32 +0000 Subject: [PATCH 115/147] all working locally --- ...PWebApplication.BlockedFileTypes.Tests.ps1 | 2 +- ...SPWebApplication.GeneralSettings.Tests.ps1 | 2 +- .../xSharePoint.xSPWebApplication.Tests.ps1 | 160 +----------------- ...int.xSPWebApplication.Throttling.Tests.ps1 | 2 +- ...Point.xSPWebApplication.Workflow.Tests.ps1 | 8 +- 5 files changed, 6 insertions(+), 168 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 index e9909f82a..1f74b924b 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index a2d8d8313..bbc174224 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 6505ab124..30f2705e4 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -151,163 +151,5 @@ Describe "xSPWebApplication" { Test-TargetResource @testParams | Should Be $true } } - - - - $testParams = @{ - Name = "Complex types Web App" - ApplicationPool = "SharePoint complex type Web App" - ApplicationPoolAccount = "DEMO\ServiceAccount" - Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = @{ - Blocked = @("java", "vbs", "exe","xxx") - EnsureBlocked = @("java", "rar", "exe","xxx") - EnsureAllowed = @("exe", "vbs","zip") - } - WorkflowSettings = @{ - ExternalWorkflowParticipantsEnabled=$false - UserDefinedWorkflowsEnabled=$true - EmailToNoPermissionWorkflowParticipantsEnable=$false - } - ThrottlingSettings = @{ - ListViewThreshold = 10000 - AllowObjectModelOverride = $true - AdminThreshold=55000 - ListViewLookupThreshold=10 - HappyHourEnabled= $true - HappyHour = @{ - Hour = 20 - Minute = 5 - Duration = 2 - } - UniquePermissionThreshold = 133000 - RequestThrottling=$false - ChangeLogEnabled=$true - ChangeLogExpiryDays = 19 - EventHandlersEnabled=$true - } - GeneralSettings=@{ - TimeZone = 10 - DefaultQuotaTemplate = "" - Alerts = $true - AlertsLimit = 10 - RSS = $true - BlogAPI = $true - BlogAPIAuthenticated = $true - BrowserFileHandling = "Permissive" - SecurityValidation = $true - RecycleBinEnabled = $true - SecondStageRecycleBinEnabled = $true - RecycleBinCleanupEnabled = $true - RecycleBinRetentionPeriod = 10 - SecondStageRecycleBinQuota = 500 - MaximumUploadSize = 555 - CustomerExperienceProgram = $true - PresenceEnabled = $true - } - - } - - Context "set target resorce works with complex types filled in" { - Mock Get-SPAuthenticationProvider { return @{ DisableKerberos = $false; AllowAnonymous = $false } } - - $mockedapp= { - $result= @(@{ - DisplayName = $testParams.Name - ApplicationPool = @{ - Name = $testParams.ApplicationPool - Username = $testParams.ApplicationPoolAccount - } - ContentDatabases = @( - @{ - Name = "SP_Content_01" - Server = "sql.domain.local" - } - ) - IisSettings = @( - @{ Path = "C:\inetpub\wwwroot\something" } - ) - Url = $testParams.Url - MaxItemsPerThrottledOperation=5000 - AllowOMCodeOverrideThrottleSettings=$true - MaxItemsPerThrottledOperationOverride = 10000 - MaxQueryLookupFields = 8 - UnthrottledPrivilegedOperationWindowEnabled =$true - DailyStartUnthrottledPrivilegedOperationsHour = $null - DailyStartUnthrottledPrivilegedOperationsMinute = $null - DailyUnthrottledPrivilegedOperationsDuration = $null - - MaxUniquePermScopesPerList = 50000 - EventHandlersEnabled = $true - HttpThrottleSettings = @{ - PerformThrottle = $true - } - FormDigestSettings = @{ - Enabled =$true - } - ChangeLogExpirationEnabled = $true - ChangeLogRetentionPeriod = New-TimeSpan -Days 10 - }) - - $result= $result | Add-Member ScriptMethod UpdateWorkflowConfigurationSettings { - $Global:UpdateWorkflowCalled = $true; - } -PassThru - - $blockedFileTypes = new-object PSObject - - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Remove { - $Global:BlockedFilesRemoveCalled = $true; - return $true; - } -passThru - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Clear { - $Global:BlockedFilesClearCalled = $true; - return $true; - } -passThru - - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod ContainExtension { - - param($extension) - $Global:BlockedFilesContainsCalled = $true; - if($extension -eq "exe"){ - return $true - } - return $false - - } -passThru - $blockedFileTypes = $blockedFileTypes | Add-Member ScriptMethod Add { - param( [string]$fileType) - $Global:BlockedFilesAddCalled = $true; - return $true; - } -passThru - - $result=$result| Add-Member ScriptMethod Update { - $Global:SPWebApplicationUpdateCalled = $true; - return $true; - } -PassThru - $result= $result | Add-Member NoteProperty -value $blockedFileTypes -Name "BlockedFileExtensions" -PassThru - return $result - } - Mock Get-SPWebApplication $mockedapp - Mock New-SPWebApplication $mockedapp - - It "calls the new cmdlet from the set method and does update blockedFileExtensions" { - $Global:BlockedFilesAddCalled = $false; - $Global:BlockedFilesClearCalled = $false; - $Global:BlockedFilesRemoveCalled = $false; - $Global:BlockedFilesContainsCalled = $false; - $Global:SPWebApplicationUpdateCalled =$false ; - Set-TargetResource @testParams - $Global:BlockedFilesAddCalled| Should be $true; - $Global:BlockedFilesContainsCalled| Should be $true; - $Global:SPWebApplicationUpdateCalled| Should be $true; - $Global:BlockedFilesRemoveCalled| Should be $true; - - Assert-MockCalled Get-SPWebApplication - } - - } - - } -} \ No newline at end of file +} diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index 512586772..0c05d8da9 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 index e80dd9148..0bffd6c64 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' @@ -92,9 +92,7 @@ Describe "xSPWebApplication (Workflow)" { EmailToNoPermissionWorkflowParticipantsEnabled = $false ExternalWorkflowParticipantsEnabled = $false } - $webApp = $webApp | Add-Member ScriptMethod Update { - $Global:xSPWebApplicationUpdateCalled = $true - } -PassThru | Add-Member ScriptMethod UpdateWorkflowConfigurationSettings { + $webApp = $webApp | Add-Member ScriptMethod UpdateWorkflowConfigurationSettings { $Global:xSPWebApplicationUpdateWorkflowCalled = $true } -PassThru return @($webApp) @@ -108,11 +106,9 @@ Describe "xSPWebApplication (Workflow)" { Test-TargetResource @testParams | Should Be $false } - $Global:xSPWebApplicationUpdateCalled = $false $Global:xSPWebApplicationUpdateWorkflowCalled = $false It "updates the workflow settings" { Set-TargetResource @testParams - $Global:xSPWebApplicationUpdateCalled | Should Be $true $Global:xSPWebApplicationUpdateWorkflowCalled | Should Be $true } } From e9b4898e398d16cae965419ac70f31f1bbced640 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 1 Dec 2015 00:16:58 +1100 Subject: [PATCH 116/147] testing appVeyour fix --- .../xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 | 2 +- .../xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 | 2 +- .../xSharePoint.xSPWebApplication.Throttling.Tests.ps1 | 2 +- .../xSharePoint.xSPWebApplication.Workflow.Tests.ps1 | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 index e9909f82a..1f74b924b 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index a2d8d8313..bbc174224 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index 512586772..0c05d8da9 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 index e80dd9148..16edb3961 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Workflow)" { InModuleScope $ModuleName { From 06b40a7f56b70ce80ccaff964fd6049aaa42ac77 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 1 Dec 2015 00:17:42 +1100 Subject: [PATCH 117/147] Revert "testing appVeyour fix" This reverts commit e9b4898e398d16cae965419ac70f31f1bbced640. --- .../xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 | 2 +- .../xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 | 2 +- .../xSharePoint.xSPWebApplication.Throttling.Tests.ps1 | 2 +- .../xSharePoint.xSPWebApplication.Workflow.Tests.ps1 | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 index 1f74b924b..e9909f82a 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index bbc174224..a2d8d8313 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index 0c05d8da9..512586772 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 index 16edb3961..e80dd9148 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' @@ -11,7 +11,6 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Workflow)" { InModuleScope $ModuleName { From 0b09e7f4650e1a7f4522dd9a31447af0164baba0 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 30 Nov 2015 13:19:38 +0000 Subject: [PATCH 118/147] testing fix to appVeyor --- .../xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 | 1 + .../xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 | 1 + .../xSharePoint.xSPWebApplication.Throttling.Tests.ps1 | 1 + .../xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 | 1 + 4 files changed, 4 insertions(+) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 index 1f74b924b..6cad1e10d 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Blocked file types)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index bbc174224..afa6c4a72 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (General Settings)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index 0c05d8da9..ba45f80fb 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Throttling)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 index 0bffd6c64..3bb079b15 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Workflow)" { InModuleScope $ModuleName { From 5fdf22ebc84994ca3537672623f3f4e2166cc899 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 1 Dec 2015 00:23:39 +1100 Subject: [PATCH 119/147] ... --- .../xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 | 1 + .../xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 | 1 + Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 | 1 + .../xSharePoint.xSPWebApplication.Throttling.Tests.ps1 | 1 + .../xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 | 1 + 5 files changed, 5 insertions(+) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 index e9909f82a..d5e3a3e06 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Blocked file types)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index a2d8d8313..7b65c3495 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (General Settings)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 6505ab124..2ea1fa41b 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index 512586772..91e4f75ab 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Throttling)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 index e80dd9148..6b0029fa1 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Workflow)" { InModuleScope $ModuleName { From d28190b1c440a4edf491b2c5e5bab0ebd3ac7b38 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 1 Dec 2015 00:27:16 +1100 Subject: [PATCH 120/147] Revert "..." This reverts commit 5fdf22ebc84994ca3537672623f3f4e2166cc899. --- .../xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 | 1 - .../xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 | 1 - Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 | 1 - .../xSharePoint.xSPWebApplication.Throttling.Tests.ps1 | 1 - .../xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 | 1 - 5 files changed, 5 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 index 6cad1e10d..1f74b924b 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -11,7 +11,6 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Blocked file types)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index afa6c4a72..bbc174224 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -11,7 +11,6 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (General Settings)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 40752361f..30f2705e4 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -11,7 +11,6 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index ba45f80fb..0c05d8da9 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -11,7 +11,6 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Throttling)" { InModuleScope $ModuleName { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 index 3bb079b15..0bffd6c64 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 @@ -11,7 +11,6 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication (Workflow)" { InModuleScope $ModuleName { From 9a20b22fbb169b1e4381b3d80c5f26442cf6e912 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 30 Nov 2015 13:28:09 +0000 Subject: [PATCH 121/147] .. --- Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 index 30f2705e4..40752361f 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Tests.ps1 @@ -11,6 +11,7 @@ $Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") Describe "xSPWebApplication" { InModuleScope $ModuleName { From 27570125c290d5f19138ddeb7a1b6c11d3918e94 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 30 Nov 2015 13:36:43 +0000 Subject: [PATCH 122/147] ... --- .../xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 | 1 + .../xSharePoint.xSPWebApplication.Throttling.Tests.ps1 | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index afa6c4a72..062799733 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -13,6 +13,7 @@ $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") + Describe "xSPWebApplication (General Settings)" { InModuleScope $ModuleName { $testParams = @{ diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index ba45f80fb..da13a19ba 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -13,6 +13,8 @@ $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\Modules\xSharePoint.Util\xSharePoint.Util.psm1") + + Describe "xSPWebApplication (Throttling)" { InModuleScope $ModuleName { $testParams = @{ From 09098db7e693d2e567152842c0eb3f4f15a3e757 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 30 Nov 2015 13:51:37 +0000 Subject: [PATCH 123/147] . --- .../xSPWebApplication.Throttling.psm1 | 2 +- .../xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 index e9f241ba8..96ad14dae 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -86,7 +86,7 @@ function Test-xSPWebApplicationThrottlingSettings { [parameter(Mandatory = $true)] $CurrentSettings, [parameter(Mandatory = $true)] $DesiredSettings ) - + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` -DesiredValues $DesiredSettings ` -ValuesToCheck @( diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index 062799733..a111d1b98 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -1,13 +1,13 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path -$Global:CurrentSharePointStubModule = $SharePointCmdletModule +$Global:CurrentSharePointStubModule = $SharePointCmdletModule $ModuleName = "MSFT_xSPWebApplication" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") From 258e8b06a9ab5b60e5e185f31bc7450fdd7e29bd Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 30 Nov 2015 13:55:27 +0000 Subject: [PATCH 124/147] util --- .../xSPWebApplication.GeneralSettings.psm1 | 2 ++ .../xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 index 96653a71f..7bd0c56ff 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 @@ -55,6 +55,8 @@ function Test-xSPWebApplicationGeneralSettings { [parameter(Mandatory = $true)] $CurrentSettings, [parameter(Mandatory = $true)] $DesiredSettings ) + + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` -DesiredValues $DesiredSettings return $testReturn diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 index ddd1ef759..2fe7df6c8 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 @@ -36,7 +36,7 @@ function Test-xSPWebApplicationWorkflowSettings { [parameter(Mandatory = $true)] $CurrentSettings, [parameter(Mandatory = $true)] $DesiredSettings ) - + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` -DesiredValues $DesiredSettings return $testReturn From 4da58d0630b63d7f4d250d9ccf0413b41d4a0ec8 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Tue, 1 Dec 2015 08:21:47 +1100 Subject: [PATCH 125/147] Changed to switch to CimInstance objects in xSPWebApplication --- .../MSFT_xSPWebApplication.psm1 | 56 ++++++---- .../xSharePoint.Util/xSharePoint.Util.psm1 | 51 ++++++++- .../xSPWebApplication.BlockedFileTypes.psm1 | 24 ++-- .../xSPWebApplication.GeneralSettings.psm1 | 51 ++++++--- .../xSPWebApplication.Throttling.psm1 | 104 ++++++++++-------- .../xSPWebApplication.Workflow.psm1 | 13 ++- Modules/xSharePoint/xSharePoint.psd1 | 4 +- ...PWebApplication.BlockedFileTypes.Tests.ps1 | 17 +-- ...SPWebApplication.GeneralSettings.Tests.ps1 | 6 +- ...int.xSPWebApplication.Throttling.Tests.ps1 | 42 +++---- ...Point.xSPWebApplication.Workflow.Tests.ps1 | 7 +- 11 files changed, 231 insertions(+), 144 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index 3e82c7d49..b7b829558 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -16,16 +16,17 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] $GeneralSettings, - [parameter(Mandatory = $false)] $WorkflowSettings, - [parameter(Mandatory = $false)] $ThrottlingSettings, - [parameter(Mandatory = $false)] $BlockedFileTypes + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes ) Write-Verbose -Message "Getting web application '$Name'" - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { $params = $args[0] + $ScriptRoot = $args[1] $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue @@ -34,10 +35,10 @@ function Get-TargetResource $authProvider = Get-SPAuthenticationProvider -WebApplication $wa.Url -Zone "Default" if ($authProvider.DisableKerberos -eq $true) { $localAuthMode = "NTLM" } else { $localAuthMode = "Kerberos" } - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) return @{ Name = $wa.DisplayName @@ -79,15 +80,16 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] $GeneralSettings, - [parameter(Mandatory = $false)] $WorkflowSettings, - [parameter(Mandatory = $false)] $ThrottlingSettings, - [parameter(Mandatory = $false)] $BlockedFileTypes + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes ) Write-Verbose -Message "Creating web application '$Name'" - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { $params = $args[0] + $ScriptRoot = $args[1] $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { @@ -119,19 +121,19 @@ function Set-TargetResource # Resource throttling settings if ($params.ContainsKey("ThrottlingSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) Set-xSPWebApplicationThrottlingSettings -WebApplication $wa -Settings $params.ThrottlingSettings } # Blocked file types if ($params.ContainsKey("BlockedFileTypes") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) Set-xSPWebApplicationBlockedFileTypes -WebApplication $wa -Settings $params.BlockedFileTypes } # General Settings if ($params.ContainsKey("GeneralSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) Set-xSPWebApplicationGeneralSettings -WebApplication $wa -Settings $params.GeneralSettings } @@ -143,11 +145,21 @@ function Set-TargetResource # Workflow settings if ($params.ContainsKey("WorkflowSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) # Workflow uses a seperate update method, to avoid update conflicts get a fresh web app object $wa2 = Get-SPWebApplication -Identity $params.Name Set-xSPWebApplicationWorkflowSettings -WebApplication $wa2 -Settings $params.WorkflowSettings } + + # Happy hour settings + if ($params.ContainsKey("ThrottlingSettings") -eq $true) { + if ((Test-xSharePointObjectHasProperty $params.ThrottlingSettings "HappyHour") -eq $true) { + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + # Happy hour settins use separate update method so use a fresh web app to update these + $wa3 = Get-SPWebApplication -Identity $params.Name + Set-xSPWebApplicationHappyHourSettings -WebApplication $wa3 -Settings $params.ThrottlingSettings.HappyHour + } + } } } @@ -170,10 +182,10 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] $GeneralSettings, - [parameter(Mandatory = $false)] $WorkflowSettings, - [parameter(Mandatory = $false)] $ThrottlingSettings, - [parameter(Mandatory = $false)] $BlockedFileTypes + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 29c153d39..029372282 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -141,17 +141,37 @@ function Remove-xSharePointUserToLocalAdmin() { ([ADSI]"WinNT://$($env:computername)/Administrators,group").Remove("WinNT://$domainName/$accountName") | Out-Null } +function Test-xSharePointObjectHasProperty() { + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true,Position=1)] [Object] $Object, + [parameter(Mandatory = $true,Position=2)] [String] $PropertyName + ) + return [bool]($Object.PSobject.Properties.name -contains $PropertyName) +} + function Test-xSharePointSpecificParameters() { [CmdletBinding()] param ( [parameter(Mandatory = $true,Position=1)] [HashTable] $CurrentValues, - [parameter(Mandatory = $true,Position=2)] [HashTable] $DesiredValues, + [parameter(Mandatory = $true,Position=2)] [Object] $DesiredValues, [parameter(Mandatory = $false,Position=3)] [Array] $ValuesToCheck ) $returnValue = $true + if (($DesiredValues.GetType().Name -ne "HashTable") ` + -and ($DesiredValues.GetType().Name -ne "CimInstance") ` + -and ($DesiredValues.GetType().Name -ne "PSBoundParametersDictionary")) { + throw "Property 'DesiredValues' in Test-xSharePointSpecificParameters must be either a Hashtable or CimInstance. Type detected was $($DesiredValues.GetType().Name)" + } + + if (($DesiredValues.GetType().Name -eq "CimInstance") -and ($null -eq $ValuesToCheck)) { + throw "If 'DesiredValues' is a Hashtable then property 'ValuesToCheck' must contain a value" + } + if (($ValuesToCheck -eq $null) -or ($ValuesToCheck.Count -lt 1)) { $KeyList = $DesiredValues.Keys } else { @@ -161,7 +181,13 @@ function Test-xSharePointSpecificParameters() { $KeyList | ForEach-Object { if (($_ -ne "Verbose") -and ($_ -ne "InstallAccount")) { if (($CurrentValues.ContainsKey($_) -eq $false) -or ($CurrentValues.$_ -ne $DesiredValues.$_)) { - if ($DesiredValues.ContainsKey($_)) { + if ($DesiredValues.GetType().Name -eq "HashTable" -or $DesiredValues.GetType().Name -eq "PSBoundParametersDictionary") { + $CheckDesiredValue = $DesiredValues.ContainsKey($_) + } else { + $CheckDesiredValue = Test-xSharePointObjectHasProperty $DesiredValues $_ + } + + if ($CheckDesiredValue) { $desiredType = $DesiredValues.$_.GetType() $fieldName = $_ switch ($desiredType.Name) { @@ -210,4 +236,25 @@ function Test-xSharePointUserIsLocalAdmin() { Where-Object { $_ -eq $accountName } } +function Set-xSharePointObjectPropertyIfValueExists() { + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true,Position=1)] [object] $ObjectToSet, + [parameter(Mandatory = $true,Position=1)] [string] $PropertyToSet, + [parameter(Mandatory = $true,Position=1)] [object] $ParamsValue, + [parameter(Mandatory = $true,Position=1)] [string] $ParamKey + ) + + if ($ParamsValue.GetType().Name -eq "Hashtable") { + if ($ParamsValue.ContainsKey($ParamKey) -eq $true) { + $ObjectToSet.$PropertyToSet = $ParamsValue.$ParamKey + } + } else { + if (((Test-xSharePointObjectHasProperty $ParamsValue $ParamKey) -eq $true) -and ($null -ne $ParamsValue.$ParamKey)) { + $ObjectToSet.$PropertyToSet = $ParamsValue.$ParamKey + } + } +} + Export-ModuleMember -Function * diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 index 1d7542ac5..2a3cbeb53 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -15,25 +15,25 @@ function Set-xSPWebApplicationBlockedFileTypes { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] $Settings + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings ) - if ($Settings.ContainsKey("Blocked") -eq $true -and (($Settings.ContainsKey("EnsureBlocked") -eq $true) -or ($Settings.ContainsKey("EnsureAllowed") -eq $true))) { + if ((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $true -and ((Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $true -or (Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $true)) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } - if ($Settings.ContainsKey("Blocked") -eq $false -and $Settings.ContainsKey("EnsureBlocked") -eq $false -and $Settings.ContainsKey("EnsureAllowed") -eq $false) { + if ((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $false -and (Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $false -and (Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $false) { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if($Settings.ContainsKey("Blocked") -eq $true) { + if((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $true) { $WebApplication.BlockedFileExtensions.Clear(); $Settings.Blocked | ForEach-Object { $WebApplication.BlockedFileExtensions.Add($_.ToLower()); } } - if($Settings.ContainsKey("EnsureBlocked") -eq $true) { + if((Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $true) { $Settings.EnsureBlocked | ForEach-Object { if(!$WebApplication.BlockedFileExtensions.Contains($_.ToLower())){ $WebApplication.BlockedFileExtensions.Add($_.ToLower()); @@ -41,7 +41,7 @@ function Set-xSPWebApplicationBlockedFileTypes { } } - if($Settings.ContainsKey("EnsureAllowed") -eq $true) { + if((Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $true) { $Settings.EnsureAllowed | ForEach-Object { if($WebApplication.BlockedFileExtensions.Contains($_.ToLower())){ $WebApplication.BlockedFileExtensions.Remove($_.ToLower()); @@ -55,28 +55,28 @@ function Test-xSPWebApplicationBlockedFileTypes { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] $DesiredSettings + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings ) - if ($DesiredSettings.ContainsKey("Blocked") -eq $true -and (($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) -or ($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true))) { + if ((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $true -and ((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $true -or (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $true)) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } - if ($DesiredSettings.ContainsKey("Blocked") -eq $false -and $DesiredSettings.ContainsKey("EnsureBlocked") -eq $false -and $DesiredSettings.ContainsKey("EnsureAllowed") -eq $false) { + if ((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $false -and (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $false -and (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $false) { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if ($DesiredSettings.ContainsKey("Blocked") -eq $true) { + if((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $true) { $compareResult = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.Blocked if ($compareResult -eq $null) { return $true } else { return $false } } - if($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) { + if((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $true) { $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked -ExcludeDifferent if ($itemsToRemove -ne $null) { return $false } } - if($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true) { + if((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $true) { $itemsToAdd = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureAllowed | Where-Object { $_.SideIndicator -eq "=>"} if ($itemsToAdd -ne $null) { $compareResult = Compare-Object -ReferenceObject $DesiredSettings.EnsureAllowed -DifferenceObject $itemsToAdd.InputObject diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 index 96653a71f..7ec85be23 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 @@ -28,24 +28,38 @@ function Set-xSPWebApplicationGeneralSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] $Settings + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings ) - if ($Settings.ContainsKey("TimeZone") -eq $true) { $WebApplication.DefaultTimeZone = $Settings.TimeZone } - if ($Settings.ContainsKey("Alerts") -eq $true) { $WebApplication.AlertsEnabled = $Settings.Alerts } - if ($Settings.ContainsKey("AlertsLimit") -eq $true) { $WebApplication.AlertsMaximum = $Settings.AlertsLimit } - if ($Settings.ContainsKey("RSS") -eq $true) { $WebApplication.SyndicationEnabled = $Settings.RSS } - if ($Settings.ContainsKey("AlertsLimit") -eq $true) { $WebApplication.MetaWeblogEnabled = $Settings.BlogAPI } - if ($Settings.ContainsKey("BlogAPIAuthenticated") -eq $true) { $WebApplication.MetaWeblogAuthenticationEnabled = $Settings.BlogAPIAuthenticated } - if ($Settings.ContainsKey("BrowserFileHandling") -eq $true) { $WebApplication.BrowserFileHandling = $Settings.BrowserFileHandling } - if ($Settings.ContainsKey("SecurityValidation") -eq $true) { $WebApplication.FormDigestSettings.Enabled = $Settings.SecurityValidation } - if ($Settings.ContainsKey("MaximumUploadSize") -eq $true) { $WebApplication.MaximumFileSize = $Settings.MaximumUploadSize } - if ($Settings.ContainsKey("RecycleBinEnabled") -eq $true) { $WebApplication.RecycleBinEnabled = $Settings.RecycleBinEnabled } - if ($Settings.ContainsKey("RecycleBinCleanupEnabled") -eq $true) { $WebApplication.RecycleBinCleanupEnabled = $Settings.RecycleBinCleanupEnabled } - if ($Settings.ContainsKey("RecycleBinRetentionPeriod") -eq $true) { $WebApplication.RecycleBinRetentionPeriod = $Settings.RecycleBinRetentionPeriod } - if ($Settings.ContainsKey("SecondStageRecycleBinQuota") -eq $true) { $WebApplication.SecondStageRecycleBinQuota = $Settings.SecondStageRecycleBinQuota } - if ($Settings.ContainsKey("CustomerExperienceProgram") -eq $true) { $WebApplication.BrowserCEIPEnabled = $Settings.CustomerExperienceProgram } - if ($Settings.ContainsKey("Presence") -eq $true) { $WebApplication.PresenceEnabled = $Settings.Presence } + # Format here is SPWebApplication property = Custom settings property + $mapping = @{ + DefaultTimeZone = "TimeZone" + AlertsEnabled = "Alerts" + AlertsMaximum = "AlertsLimit" + SyndicationEnabled = "RSS" + MetaWeblogEnabled = "BlogAPI" + MetaWeblogAuthenticationEnabled = "BlogAPIAuthenticated" + BrowserFileHandling = "BrowserFileHandling" + MaximumFileSize = "MaximumUploadSize" + RecycleBinEnabled = "RecycleBinEnabled" + RecycleBinCleanupEnabled = "RecycleBinCleanupEnabled" + RecycleBinRetentionPeriod = "RecycleBinRetentionPeriod" + SecondStageRecycleBinQuota = "SecondStageRecycleBinQuota" + BrowserCEIPEnabled = "CustomerExperienceProgram" + PresenceEnabled = "Presence" + } + $mapping.Keys | ForEach-Object { + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $WebApplication ` + -PropertyToSet $_ ` + -ParamsValue $settings ` + -ParamKey $mapping[$_] + } + + # Set form digest setting child property + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $WebApplication.FormDigestSettings ` + -PropertyToSet "Enabled" ` + -ParamsValue $settings ` + -ParamKey "SecurityValidation" } function Test-xSPWebApplicationGeneralSettings { @@ -53,10 +67,11 @@ function Test-xSPWebApplicationGeneralSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] $DesiredSettings + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings ) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` - -DesiredValues $DesiredSettings + -DesiredValues $DesiredSettings ` + -ValuesToCheck @("TimeZone", "Alerts", "AlertsLimit", "RSS", "BlogAPI", "BlogAPIAuthenticated", "BrowserFileHandling", "SecurityValidation", "RecycleBinEnabled", "RecycleBinCleanupEnabled", "RecycleBinRetentionPeriod", "SecondStageRecycleBinQuota", "MaximumUploadSize", "CustomerExperienceProgram", "PresenceEnabled") return $testReturn } diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 index e9f241ba8..2cf146ee2 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -27,55 +27,64 @@ function Set-xSPWebApplicationThrottlingSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] $Settings + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings ) - if($Settings.ContainsKey("ListViewThreshold") -eq $true) { - $WebApplication.MaxItemsPerThrottledOperation = $Settings.ListViewThreshold + # Format here is SPWebApplication property = Custom settings property + $mapping = @{ + MaxItemsPerThrottledOperation = "ListViewThreshold" + AllowOMCodeOverrideThrottleSettings = "AllowObjectModelOverride" + MaxItemsPerThrottledOperationOverride = "AdminThreshold" + MaxQueryLookupFields = "ListViewLookupThreshold" + UnthrottledPrivilegedOperationWindowEnabled = "HappyHourEnabled" + MaxUniquePermScopesPerList = "UniquePermissionThreshold" + EventHandlersEnabled = "EventHandlersEnabled" + ChangeLogExpirationEnabled = "ChangeLogEnabled" + } + $mapping.Keys | ForEach-Object { + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $WebApplication ` + -PropertyToSet $_ ` + -ParamsValue $settings ` + -ParamKey $mapping[$_] } - if($Settings.ContainsKey("AllowObjectModelOverride") -eq $true) { - $WebApplication.AllowOMCodeOverrideThrottleSettings = $Settings.AllowObjectModelOverride - } - if($Settings.ContainsKey("AdminThreshold") -eq $true) { - $WebApplication.MaxItemsPerThrottledOperationOverride = $Settings.AdminThreshold - } - if($Settings.ContainsKey("ListViewLookupThreshold") -eq $true) { - $WebApplication.MaxQueryLookupFields = $Settings.ListViewLookupThreshold - } - if($Settings.ContainsKey("HappyHourEnabled") -eq $true) { - $WebApplication.UnthrottledPrivilegedOperationWindowEnabled =$Settings.HappyHourEnabled + + # Set throttle settings child property seperately + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $WebApplication.HttpThrottleSettings ` + -PropertyToSet "PerformThrottle" ` + -ParamsValue $Settings ` + -ParamKey "RequestThrottling" + + # Create time span object separately + if (Test-xSharePointObjectHasProperty $Settings "ChangeLogExpiryDays") { + $WebApplication.ChangeLogRetentionPeriod = New-TimeSpan -Days $Settings.ChangeLogExpiryDays } - if($Settings.ContainsKey("HappyHour") -eq $true) { - $happyHour = $Settings.HappyHour; - if ($happyHour.ContainsKey("Hour") -eq $false -or $happyHour.ContainsKey("Minute") -eq $false -or $happyHour.ContainsKey("Duration") -eq $false) { - throw "Happy hour settings must include 'hour', 'minute' and 'duration'" - } else { - if ($happyHour.Hour -lt 0 -or $happyHour.Hour -gt 23) { - throw "Happy hour setting 'hour' must be between 0 and 23" - } - if ($happyHour.Minute -lt 0 -or $happyHour.Minute -gt 59) { - throw "Happy hour setting 'minute' must be between 0 and 59" - } - if ($happyHour.Duration -lt 0 -or $happyHour.Duration -gt 23) { - throw "Happy hour setting 'hour' must be between 0 and 23" - } - $WebApplication.SetDailyUnthrottledPrivilegedOperationWindow($happyHour.Hour, $happyHour.Minute, $happyHour.Duration) + + + + +} + + +function Set-xSPWebApplicationHappyHourSettings { + [CmdletBinding()] + param( + [parameter(Mandatory = $true)] $WebApplication, + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + ) + + if ((Test-xSharePointObjectHasProperty $Settings "Hour") -eq $false -or (Test-xSharePointObjectHasProperty $Settings "Minute") -eq $false -or (Test-xSharePointObjectHasProperty $Settings "Duration") -eq $false) { + throw "Happy hour settings must include 'hour', 'minute' and 'duration'" + } else { + if ($Settings.Hour -lt 0 -or $Settings.Hour -gt 23) { + throw "Happy hour setting 'hour' must be between 0 and 23" } - } - if($Settings.ContainsKey("UniquePermissionThreshold") -eq $true) { - $WebApplication.MaxUniquePermScopesPerList = $Settings.UniquePermissionThreshold - } - if($Settings.ContainsKey("EventHandlersEnabled") -eq $true) { - $WebApplication.EventHandlersEnabled = $Settings.EventHandlersEnabled - } - if($Settings.ContainsKey("RequestThrottling") -eq $true) { - $WebApplication.HttpThrottleSettings.PerformThrottle = $Settings.RequestThrottling - } - if($Settings.ContainsKey("ChangeLogEnabled") -eq $true) { - $WebApplication.ChangeLogExpirationEnabled = $Settings.ChangeLogEnabled - } - if($Settings.ContainsKey("ChangeLogExpiryDays") -eq $true) { - $WebApplication.ChangeLogRetentionPeriod = New-TimeSpan -Days $Settings.ChangeLogExpiryDays + if ($Settings.Minute -lt 0 -or $Settings.Minute -gt 59) { + throw "Happy hour setting 'minute' must be between 0 and 59" + } + if ($Settings.Duration -lt 0 -or $Settings.Duration -gt 23) { + throw "Happy hour setting 'hour' must be between 0 and 23" + } + $WebApplication.SetDailyUnthrottledPrivilegedOperationWindow($happyHour.Hour, $happyHour.Minute, $happyHour.Duration) } } @@ -84,7 +93,7 @@ function Test-xSPWebApplicationThrottlingSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] $DesiredSettings + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings ) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` @@ -102,9 +111,10 @@ function Test-xSPWebApplicationThrottlingSettings { "EventHandlersEnabled" ) if ($testReturn -eq $true) { - if ($DesiredSettings.ContainsKey("HappyHour") -eq $true) { + if ((Test-xSharePointObjectHasProperty $DesiredSettings "HappyHour") -eq $true) { $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings.HappyHour ` - -DesiredValues $DesiredSettings.HappyHour + -DesiredValues $DesiredSettings.HappyHour ` + -ValuesToCheck @("Hour", "Minute", "Duration") } } return $testReturn diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 index ddd1ef759..1ddb7d77b 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 @@ -15,15 +15,15 @@ function Set-xSPWebApplicationWorkflowSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] $Settings + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings ) - if($Settings.ContainsKey("UserDefinedWorkflowsEnabled") -eq $true) { + if((Test-xSharePointObjectHasProperty $Settings "UserDefinedWorkflowsEnabled") -eq $true) { $WebApplication.UserDefinedWorkflowsEnabled = $Settings.UserDefinedWorkflowsEnabled; } - if($Settings.ContainsKey("EmailToNoPermissionWorkflowParticipantsEnable") -eq $true) { + if((Test-xSharePointObjectHasProperty $Settings "EmailToNoPermissionWorkflowParticipantsEnable") -eq $true) { $WebApplication.EmailToNoPermissionWorkflowParticipantsEnabled = $Settings.EmailToNoPermissionWorkflowParticipantsEnable; } - if($Settings.ContainsKey("ExternalWorkflowParticipantsEnabled") -eq $true) { + if((Test-xSharePointObjectHasProperty $Settings "ExternalWorkflowParticipantsEnabled") -eq $true) { $WebApplication.ExternalWorkflowParticipantsEnabled = $Settings.ExternalWorkflowParticipantsEnabled; } $WebApplication.UpdateWorkflowConfigurationSettings(); @@ -34,11 +34,12 @@ function Test-xSPWebApplicationWorkflowSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] $DesiredSettings + [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings ) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` - -DesiredValues $DesiredSettings + -DesiredValues $DesiredSettings ` + -ValuesToCheck @("UserDefinedWorkflowsEnabled","EmailToNoPermissionWorkflowParticipantsEnable","ExternalWorkflowParticipantsEnabled") return $testReturn } diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index 751449604..dd78de2cd 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -75,8 +75,10 @@ CmdletsToExport = @("Invoke-xSharePointCommand", "Rename-xSharePointParamValue", "Add-xSharePointUserToLocalAdmin", "Remove-xSharePointUserToLocalAdmin", + "Test-xSharePointObjectHasProperty", "Test-xSharePointUserIsLocalAdmin", - "Test-xSharePointSpecificParameters") + "Test-xSharePointSpecificParameters", + "Set-xSharePointObjectPropertyIfValueExists") # Variables to export from this module VariablesToExport = '*' diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 index e9909f82a..ebe4eecb5 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' @@ -20,9 +20,9 @@ Describe "xSPWebApplication (Blocked file types)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = @{ + BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ Blocked = @("exe", "dll", "ps1") - } + } -ClientOnly) } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -121,10 +121,10 @@ Describe "xSPWebApplication (Blocked file types)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = @{ + BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ EnsureBlocked = @("exe") EnsureAllowed = @("pdf") - } + } -ClientOnly) } Context "The web appliation exists and a list of types to include and exclude both match" { @@ -238,11 +238,11 @@ Describe "xSPWebApplication (Blocked file types)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = @{ + BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ Blocked = @("exe", "dll", "ps1") EnsureBlocked = @("exe", "dll") EnsureAllowed = @("ps1") - } + } -ClientOnly) } It "throws an exception on the test method" { @@ -287,7 +287,8 @@ Describe "xSPWebApplication (Blocked file types)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = @{ } + BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ + } -ClientOnly) } It "throws an exception on the test method" { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 index a2d8d8313..2509122c7 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' @@ -20,7 +20,7 @@ Describe "xSPWebApplication (General Settings)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - GeneralSettings = @{ + GeneralSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationSettings -Property @{ TimeZone = 3081 Alerts = $true AlertsLimit = 10 @@ -36,7 +36,7 @@ Describe "xSPWebApplication (General Settings)" { MaximumUploadSize = 100 CustomerExperienceProgram = $true PresenceEnabled = $true - } + } -ClientOnly) } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 index 512586772..d11984155 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' @@ -20,23 +20,23 @@ Describe "xSPWebApplication (Throttling)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - ThrottlingSettings = @{ + ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ ListViewThreshold = 1000 AllowObjectModelOverride = $true AdminThreshold = 2000 ListViewLookupThreshold = 12 HappyHourEnabled = $true - HappyHour = @{ + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ Hour = 2 Minute = 0 Duration = 1 - } + } -ClientOnly) UniquePermissionThreshold = 100 RequestThrottling = $true ChangeLogEnabled = $true ChangeLogExpiryDays = 30 EventHandlersEnabled = $true - } + } -ClientOnly) } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -161,23 +161,23 @@ Describe "xSPWebApplication (Throttling)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - ThrottlingSettings = @{ + ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ ListViewThreshold = 1000 AllowObjectModelOverride = $true AdminThreshold = 2000 ListViewLookupThreshold = 12 HappyHourEnabled = $true - HappyHour = @{ + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ Hour = 5 Minute = 0 Duration = 1 - } + } -ClientOnly) UniquePermissionThreshold = 100 RequestThrottling = $true ChangeLogEnabled = $true ChangeLogExpiryDays = 30 EventHandlersEnabled = $true - } + } -ClientOnly) } $Global:xSPWebApplicationUpdateCalled = $false $Global:xSPWebApplicationUpdateHappyHourCalled = $false @@ -194,14 +194,14 @@ Describe "xSPWebApplication (Throttling)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - ThrottlingSettings = @{ + ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ HappyHourEnabled = $true - HappyHour = @{ + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ Hour = 100 Minute = 0 Duration = 1 - } - } + } -ClientOnly) + } -ClientOnly) } { Set-TargetResource @testParams } | Should throw @@ -211,14 +211,14 @@ Describe "xSPWebApplication (Throttling)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - ThrottlingSettings = @{ + ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ HappyHourEnabled = $true - HappyHour = @{ + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ Hour = 5 Minute = 100 Duration = 1 - } - } + } -ClientOnly) + } -ClientOnly) } { Set-TargetResource @testParams } | Should throw @@ -228,14 +228,14 @@ Describe "xSPWebApplication (Throttling)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - ThrottlingSettings = @{ + ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ HappyHourEnabled = $true - HappyHour = @{ + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ Hour = 5 Minute = 0 Duration = 100 - } - } + } -ClientOnly) + } -ClientOnly) } { Set-TargetResource @testParams } | Should throw } diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 index e80dd9148..9f346519d 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] param( - [string] $SharePointCmdletModule = (Join-Path "C:\users\brian\Documents\GitHubVisualStudio\xSharePoint\Tests\xSharePoint" "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) $ErrorActionPreference = 'stop' @@ -20,11 +20,11 @@ Describe "xSPWebApplication (Workflow)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - WorkflowSettings = @{ + WorkflowSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationWorkflowSettings -Property @{ ExternalWorkflowParticipantsEnabled = $true UserDefinedWorkflowsEnabled = $true EmailToNoPermissionWorkflowParticipantsEnable = $true - } + } -ClientOnly) } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -112,7 +112,6 @@ Describe "xSPWebApplication (Workflow)" { $Global:xSPWebApplicationUpdateWorkflowCalled = $false It "updates the workflow settings" { Set-TargetResource @testParams - $Global:xSPWebApplicationUpdateCalled | Should Be $true $Global:xSPWebApplicationUpdateWorkflowCalled | Should Be $true } } From 411a5596e2e16d8d976a81d1142b9f7bac70c1f6 Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 1 Dec 2015 12:08:02 +1100 Subject: [PATCH 126/147] damn github --- .../xSPWebApplication.GeneralSettings.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 index 6dc24ca6d..81c37ac6e 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 @@ -70,6 +70,7 @@ function Test-xSPWebApplicationGeneralSettings { [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings ) + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` -DesiredValues $DesiredSettings ` From 39bc28202534d15924ab0ae13bc2ea8f6db4901e Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 1 Dec 2015 12:08:48 +1100 Subject: [PATCH 127/147] re-updating modules --- .../xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 | 1 + .../xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 | 1 + 2 files changed, 2 insertions(+) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 index 8fbb24dcf..d6149ddd8 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -95,6 +95,7 @@ function Test-xSPWebApplicationThrottlingSettings { [parameter(Mandatory = $true)] $CurrentSettings, [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings ) + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` -DesiredValues $DesiredSettings ` diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 index 23c73c7f2..aa3a80634 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 @@ -36,6 +36,7 @@ function Test-xSPWebApplicationWorkflowSettings { [parameter(Mandatory = $true)] $CurrentSettings, [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings ) + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentSettings ` -DesiredValues $DesiredSettings ` From a3a42d67445f3c9b2974a6e14a9062aac834f0db Mon Sep 17 00:00:00 2001 From: camiloborges Date: Tue, 1 Dec 2015 12:12:04 +1100 Subject: [PATCH 128/147] updating blocked files to import util module --- .../xSPWebApplication.BlockedFileTypes.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 index 2a3cbeb53..137401e5b 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -57,7 +57,7 @@ function Test-xSPWebApplicationBlockedFileTypes { [parameter(Mandatory = $true)] $CurrentSettings, [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings ) - + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) if ((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $true -and ((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $true -or (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $true)) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } From 69ad0ad4ae746b8713cb9a4d5442afbf842169a3 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Tue, 1 Dec 2015 12:24:35 +1100 Subject: [PATCH 129/147] Commiting to merge with release candidate branch --- .../Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 7 ++++++- .../xSPWebApplication.Throttling.psm1 | 6 +----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 029372282..779801a5d 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -148,7 +148,12 @@ function Test-xSharePointObjectHasProperty() { [parameter(Mandatory = $true,Position=1)] [Object] $Object, [parameter(Mandatory = $true,Position=2)] [String] $PropertyName ) - return [bool]($Object.PSobject.Properties.name -contains $PropertyName) + if (([bool]($Object.PSobject.Properties.name -contains $PropertyName)) -eq $true) { + if ($Object.$PropertyName -ne $null) { + return $true + } + } + return $false } function Test-xSharePointSpecificParameters() { diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 index 2cf146ee2..7a1010640 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -55,13 +55,9 @@ function Set-xSPWebApplicationThrottlingSettings { -ParamKey "RequestThrottling" # Create time span object separately - if (Test-xSharePointObjectHasProperty $Settings "ChangeLogExpiryDays") { + if ((Test-xSharePointObjectHasProperty $Settings "ChangeLogExpiryDays") -eq $true) { $WebApplication.ChangeLogRetentionPeriod = New-TimeSpan -Days $Settings.ChangeLogExpiryDays } - - - - } From 50d3dd9a58f26847b35f68d9491bb22d16a95243 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Tue, 1 Dec 2015 21:01:44 +1100 Subject: [PATCH 130/147] Fixed issue with name of blocked file types CIM object --- .../MSFT_xSPWebApplication.schema.mof | 4 ++-- ...harePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index a407d5d93..1e236d6c9 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0")] -Class MSFT_xSPFilesTypes +Class MSFT_xSPBlockedFileTypes { [write] string Blocked[]; [write] string EnsureBlocked[]; @@ -99,6 +99,6 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write, EmbeddedInstance("MSFT_xSPWebApplicationSettings")] string GeneralSettings; [Write, EmbeddedInstance("MSFT_xSPWebApplicationWorkflowSettings")] string WorkflowSettings; [Write, EmbeddedInstance("MSFT_xSPWebApplicationThrottling")] string ThrottlingSettings; - [Write, EmbeddedInstance("MSFT_xSPFilesTypes")] string BlockedFileTypes; + [Write, EmbeddedInstance("MSFT_xSPBlockedFileTypes")] string BlockedFileTypes; }; diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 index ebe4eecb5..786582648 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 @@ -20,7 +20,7 @@ Describe "xSPWebApplication (Blocked file types)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ + BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPBlockedFileTypes -Property @{ Blocked = @("exe", "dll", "ps1") } -ClientOnly) } @@ -121,7 +121,7 @@ Describe "xSPWebApplication (Blocked file types)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ + BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPBlockedFileTypes -Property @{ EnsureBlocked = @("exe") EnsureAllowed = @("pdf") } -ClientOnly) @@ -238,7 +238,7 @@ Describe "xSPWebApplication (Blocked file types)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ + BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPBlockedFileTypes -Property @{ Blocked = @("exe", "dll", "ps1") EnsureBlocked = @("exe", "dll") EnsureAllowed = @("ps1") @@ -287,7 +287,7 @@ Describe "xSPWebApplication (Blocked file types)" { ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ + BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPBlockedFileTypes -Property @{ } -ClientOnly) } From 20f7893d14b507d3408590e6f50d64f9c0797602 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Wed, 2 Dec 2015 00:29:18 +1100 Subject: [PATCH 131/147] Removing unused module file --- .../MSFT_xSPWebApplication.Set.ps1 | 188 ------------------ 1 file changed, 188 deletions(-) delete mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 deleted file mode 100644 index c3af6e4d3..000000000 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 +++ /dev/null @@ -1,188 +0,0 @@ -function Set-BlockedFiles($blockedFiles, $wa) -{ - - if($blockedFiles -eq $null){return;} - if($blockedFiles.Blocked -ne $null ){ - $wa.BlockedFileExtensions.Clear(); - $blockedFiles.Blocked| % { - $wa.BlockedFileExtensions.Add($_) ; - - } - } - if($blockedFiles.EnsureBlocked -ne $null){ - $blockedFiles.EnsureBlocked| % { - if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; - } - } - } - if($blockedFiles.EnsureAllowed -ne $null){ - $blockedFiles.EnsureAllowed | % { - if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) - } - } - } - -} -function Get-ValueOrDefault($input, $attribute, $defaultValue) -{ - try{ - if($input."$attribute" -ne $null) - { - return $input."$attribute" - }else { - return $defaultValue - } - }catch - { - return $defaultValue - } -} -function Set-GeneralSettings($generalSettings, $wa) -{ - if($generalSettings -eq $null){ return;} - - #TODO: Quota Template - $wa.DefaultTimeZone =Get-ValueOrDefault $generalSettings "TimeZone" $wa.DefaultTimeZone - $wa.AlertsEnabled = Get-ValueOrDefault $generalSettings "Alerts" $wa.AlertsEnabled - $wa.AlertsMaximum = Get-ValueOrDefault $generalSettings "AlertsLimit" $wa.AlertsMaximum - $wa.SyndicationEnabled = Get-ValueOrDefault $generalSettings "RSS" $wa.RSS - $wa.MetaWeblogEnabled = Get-ValueOrDefault $generalSettings "BlogAPI" $wa.BlogAPI - $wa.MetaWeblogAuthenticationEnabled = Get-ValueOrDefault $generalSettings "BlogAPIAuthenticated" $wa.BlogAPIAuthenticated - $wa.BrowserFileHandling = Get-ValueOrDefault $generalSettings "BrowserFileHandling" $wa.BrowserFileHandling - $wa.FormDigestSettings.Enabled = Get-ValueOrDefault $generalSettings "SecurityValidation" $wa.FormDigestSettings.Enabled - $wa.MaximumFileSize = Get-ValueOrDefault $generalSettings "MaximumUploadSize" $wa.MaximumUploadSize - $wa.RecycleBinEnabled = Get-ValueOrDefault $generalSettings "RecycleBinEnabled" $wa.RecycleBinEnabled - $wa.RecycleBinCleanupEnabled = Get-ValueOrDefault $generalSettings "RecycleBinCleanupEnabled" $wa.RecycleBinCleanupEnabled - $wa.RecycleBinRetentionPeriod = Get-ValueOrDefault $generalSettings "RecycleBinRetentionPeriod" $wa.RecycleBinRetentionPeriod - $wa.SecondStageRecycleBinQuota = Get-ValueOrDefault $generalSettings "SecondStageRecycleBinEnabled" $wa.SecondStageRecycleBinQuota - $wa.BrowserCEIPEnabled = Get-ValueOrDefault $generalSettings "CustomerExperienceProgram" $wa.BrowserCEIPEnabled - $wa.PresenceEnabled = Get-ValueOrDefault $generalSettings "Presence" $wa.BrowserCEIPEnabled - $wa.Update(); -} -function Set-WorkflowSettings ($workflowSettings, $wa) -{ - if($workflowSettings -eq $null ){ return;} - if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ - $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; - } - if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ - $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; - } - if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ - $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; - } - - $wa.UpdateWorkflowConfigurationSettings(); - $wa.Update(); -} - -function Set-ThrottlingSettings ($throttlingSettings, $wa) -{ - if($throttlingSettings -eq $null){ return;} - if($throttlingSettings.ListViewThreshold -ne $null ){ - $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold - } - if($throttlingSettings.AllowObjectModelOverride -ne $null){ - $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride - } - if($throttlingSettings.AdminThreshold -ne $null){ - $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold - } - if($throttlingSettings.ListViewLookupThreshold -ne $null){ - $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold - } - if($throttlingSettings.HappyHourEnabled -ne $null){ - $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled - } - if($throttlingSettings.HappyHour -ne $null){ - $happyHour =$throttlingSettings.HappyHour; - if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ - if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ - $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour - $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute - $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration - }else{ - throw "the valid range hour, minute and duration is 0-24"; - } - - }else { - throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; - } - } - if($throttlingSettings.UniquePermissionThreshold){ - $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold - } - if($throttlingSettings.EventHandlersEnabled){ - $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled - } - if($throttlingSettings.RequestThrottling){ - $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling - } - if($throttlingSettings.ChangeLogEnabled){ - $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled - } - if($throttlingSettings.ChangeLogExpiryDays){ - $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays - } - $wa.Update(); -} - -function GetAndRemove-Parameter($params, $name){ - $result =$null - if($params.ContainsKey($name)) - { - $result = $params.$name - $params.Remove( $name) - } - return $result; -} -function Sanitize-ComplexTypes{ - param( - [Parameter(Position = 0)] - - $params - ) - -$blocked =GetAndRemove-Parameter $params "BlockedFileTypes" - return @{ - GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" - WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" - Extensions = GetAndRemove-Parameter $params "Extensions" - ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" - BlockedFileTypes = $blocked - } -} - - -$params = $args[0] - -$settings = Sanitize-ComplexTypes $params - -$wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue -if ($null -eq $wa) { - if ($params.ContainsKey("AuthenticationMethod") -eq $true) { - if ($params.AuthenticationMethod -eq "NTLM") { - $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos - } else { - $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication - } - $params.Remove("AuthenticationMethod") - $params.Add("AuthenticationProvider", $ap) - } - - if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } - if ($params.ContainsKey("AllowAnonymous")) { - $params.Remove("AllowAnonymous") | Out-Null - $params.Add("AllowAnonymousAccess", $true) - } - - $wa = New-SPWebApplication @params -} - -Set-ThrottlingSettings $settings.ThrottlingSettings $wa -Set-WorkflowSettings $settings.WorkflowSettings $wa -Set-BlockedFiles $settings.BlockedFileTypes $wa -Set-GeneralSettings $settings.GeneralSettings $wa - \ No newline at end of file From ca374247fa4d44eca3cd59d1afb6bf56d7e11dd0 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Wed, 2 Dec 2015 00:31:35 +1100 Subject: [PATCH 132/147] Updated MOF to match required properties in script --- .../MSFT_xSPOutgoingEmailSettings.schema.mof | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index ac95787f2..292799962 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -20,10 +20,10 @@ It is possible to set the outgoing server, from address, reply to address and th class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource { [key] string WebAppUrl; - [Write] string SMTPServer; - [Write] string FromAddress; - [Write] string ReplyToAddress; - [Write] string CharacterSet; + [Required] string SMTPServer; + [Required] string FromAddress; + [Required] string ReplyToAddress; + [Required] string CharacterSet; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; From 484ddf72e9d9145b013dc1e06d8d15a8c3cbb7d8 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 12:15:50 +1100 Subject: [PATCH 133/147] Split apart xSPWebApplication to workaround issue with DSC complex types --- .../MSFT_xSPWebAppBlockedFileTypes.psm1 | 88 +++++++++++++ .../MSFT_xSPWebAppBlockedFileTypes.schema.mof | 9 ++ .../MSFT_xSPWebAppGeneralSettings.psm1 | 124 ++++++++++++++++++ .../MSFT_xSPWebAppGeneralSettings.schema.mof | 21 +++ .../MSFT_xSPWebAppThrottlingSettings.psm1 | 118 +++++++++++++++++ ...SFT_xSPWebAppThrottlingSettings.schema.mof | 26 ++++ .../MSFT_xSPWebAppWorkflowSettings.psm1 | 87 ++++++++++++ .../MSFT_xSPWebAppWorkflowSettings.schema.mof | 9 ++ .../MSFT_xSPWebApplication.psm1 | 19 +-- .../MSFT_xSPWebApplication.schema.mof | 67 +--------- .../xSPWebApplication.BlockedFileTypes.psm1 | 25 ++-- .../xSPWebApplication.GeneralSettings.psm1 | 4 +- .../xSPWebApplication.Throttling.psm1 | 6 +- .../xSPWebApplication.Workflow.psm1 | 10 +- ...Point.xSPWebAppBlockedFileTypes.Tests.ps1} | 40 ++---- ...ePoint.xSPWebAppGeneralSettings.Tests.ps1} | 72 +++++----- ...int.xSPWebAppThrottlingSettings.Tests.ps1} | 122 ++++++++--------- ...Point.xSPWebAppWorkflowSettings.Tests.ps1} | 16 +-- 18 files changed, 609 insertions(+), 254 deletions(-) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof rename Tests/xSharePoint/{xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 => xSharePoint.xSPWebAppBlockedFileTypes.Tests.ps1} (86%) rename Tests/xSharePoint/{xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 => xSharePoint.xSPWebAppGeneralSettings.Tests.ps1} (67%) rename Tests/xSharePoint/{xSharePoint.xSPWebApplication.Throttling.Tests.ps1 => xSharePoint.xSPWebAppThrottlingSettings.Tests.ps1} (73%) rename Tests/xSharePoint/{xSharePoint.xSPWebApplication.Workflow.Tests.ps1 => xSharePoint.xSPWebAppWorkflowSettings.Tests.ps1} (88%) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.psm1 new file mode 100644 index 000000000..d18569e3b --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.psm1 @@ -0,0 +1,88 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.String[]] $Blocked, + [parameter(Mandatory = $false)] [System.String[]] $EnsureBlocked, + [parameter(Mandatory = $false)] [System.String[]] $EnsureAllowed, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting web application '$url' blocked file types" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { + $params = $args[0] + $ScriptRoot = $args[1] + + + $wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue + if ($null -eq $wa) { return $null } + + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) + + $result = Get-xSPWebApplicationBlockedFileTypes -WebApplication $wa + $result.Add("Url", $params.Url) + $result.Add("InstallAccount", $params.InstallAccount) + return $result + } + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.String[]] $Blocked, + [parameter(Mandatory = $false)] [System.String[]] $EnsureBlocked, + [parameter(Mandatory = $false)] [System.String[]] $EnsureAllowed, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting web application '$Url' blocked file types" + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { + $params = $args[0] + $ScriptRoot = $args[1] + + $wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue + if ($null -eq $wa) { + throw "Web application $($params.Url) was not found" + return + } + + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) + Set-xSPWebApplicationBlockedFileTypes -WebApplication $wa -Settings $params + $wa.Update() + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.String[]] $Blocked, + [parameter(Mandatory = $false)] [System.String[]] $EnsureBlocked, + [parameter(Mandatory = $false)] [System.String[]] $EnsureAllowed, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for web application '$Url' blocked file types" + if ($null -eq $CurrentValues) { return $false } + + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) + return Test-xSPWebApplicationBlockedFileTypes -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof new file mode 100644 index 000000000..993caed58 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof @@ -0,0 +1,9 @@ +[ClassVersion("1.0.0"), FriendlyName("xSPBlockedFileTypes")] +Class MSFT_xSPBlockedFileTypes +{ + [Key] string Url; + [write] string Blocked[]; + [write] string EnsureBlocked[]; + [write] string EnsureAllowed[]; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; +}; \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 new file mode 100644 index 000000000..167a00d21 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 @@ -0,0 +1,124 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $TimeZone, + [parameter(Mandatory = $false)] [System.Boolean] $Alerts, + [parameter(Mandatory = $false)] [System.UInt32] $AlertsLimit, + [parameter(Mandatory = $false)] [System.Boolean] $RSS, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPI, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPIAuthenticated, + [parameter(Mandatory = $false)] [ValidateSet("Stric","Permissive")] [System.String] $BrowserFileHandling, + [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $RecycleBinRetentionPeriod, + [parameter(Mandatory = $false)] [System.UInt32] $SecondStageRecycleBinQuota, + [parameter(Mandatory = $false)] [System.UInt32] $MaximumUploadSize, + [parameter(Mandatory = $false)] [System.Boolean] $CustomerExperienceProgram, + [parameter(Mandatory = $false)] [System.Boolean] $PresenceEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting web application '$url' general settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { + $params = $args[0] + $ScriptRoot = $args[1] + + + $wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue + if ($null -eq $wa) { return $null } + + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) + + $result = Get-xSPWebApplicationGeneralSettings -WebApplication $wa + $result.Add("Url", $params.Url) + $result.Add("InstallAccount", $params.InstallAccount) + return $result + } + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $TimeZone, + [parameter(Mandatory = $false)] [System.Boolean] $Alerts, + [parameter(Mandatory = $false)] [System.UInt32] $AlertsLimit, + [parameter(Mandatory = $false)] [System.Boolean] $RSS, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPI, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPIAuthenticated, + [parameter(Mandatory = $false)] [ValidateSet("Stric","Permissive")] [System.String] $BrowserFileHandling, + [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $RecycleBinRetentionPeriod, + [parameter(Mandatory = $false)] [System.UInt32] $SecondStageRecycleBinQuota, + [parameter(Mandatory = $false)] [System.UInt32] $MaximumUploadSize, + [parameter(Mandatory = $false)] [System.Boolean] $CustomerExperienceProgram, + [parameter(Mandatory = $false)] [System.Boolean] $PresenceEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Applying general settings '$Url'" + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { + $params = $args[0] + $ScriptRoot = $args[1] + + $wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue + if ($null -eq $wa) { + throw "Web application $($params.Url) was not found" + return + } + + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) + Set-xSPWebApplicationGeneralSettings -WebApplication $wa -Settings $params + $wa.Update() + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $TimeZone, + [parameter(Mandatory = $false)] [System.Boolean] $Alerts, + [parameter(Mandatory = $false)] [System.UInt32] $AlertsLimit, + [parameter(Mandatory = $false)] [System.Boolean] $RSS, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPI, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPIAuthenticated, + [parameter(Mandatory = $false)] [ValidateSet("Stric","Permissive")] [System.String] $BrowserFileHandling, + [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $RecycleBinRetentionPeriod, + [parameter(Mandatory = $false)] [System.UInt32] $SecondStageRecycleBinQuota, + [parameter(Mandatory = $false)] [System.UInt32] $MaximumUploadSize, + [parameter(Mandatory = $false)] [System.Boolean] $CustomerExperienceProgram, + [parameter(Mandatory = $false)] [System.Boolean] $PresenceEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for web application general settings '$Url'" + if ($null -eq $CurrentValues) { return $false } + + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) + return Test-xSPWebApplicationGeneralSettings -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof new file mode 100644 index 000000000..b31f2b26d --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof @@ -0,0 +1,21 @@ +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppGeneralSettings")] +Class MSFT_xSPWebAppGeneralSettings +{ + [Key] string Url; + [write] uint32 TimeZone; + [write] boolean Alerts; + [write] uint32 AlertsLimit; + [write] boolean RSS; + [write] boolean BlogAPI; + [write] boolean BlogAPIAuthenticated; + [write, ValueMap{"Strict","Permissive"}, Values{"Stric","Permissive"}] String BrowserFileHandling; + [write] boolean SecurityValidation; + [write] boolean RecycleBinEnabled; + [write] boolean RecycleBinCleanupEnabled; + [write] uint32 RecycleBinRetentionPeriod; + [write] uint32 SecondStageRecycleBinQuota; + [write] uint32 MaximumUploadSize; + [write] boolean CustomerExperienceProgram; + [write] boolean PresenceEnabled; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; +}; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.psm1 new file mode 100644 index 000000000..9484b4ecc --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.psm1 @@ -0,0 +1,118 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $AllowObjectModelOverride, + [parameter(Mandatory = $false)] [System.UInt32] $AdminThreshold, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewLookupThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $HappyHourEnabled, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $HappyHour, + [parameter(Mandatory = $false)] [System.UInt32] $UniquePermissionThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $RequestThrottling, + [parameter(Mandatory = $false)] [System.Boolean] $ChangeLogEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $ChangeLogExpiryDays, + [parameter(Mandatory = $false)] [System.Boolean] $EventHandlersEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting web application '$url' throttling settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { + $params = $args[0] + $ScriptRoot = $args[1] + + $wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue + if ($null -eq $wa) { return $null } + + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + + $result = Get-xSPWebApplicationThrottlingSettings -WebApplication $wa + $result.Add("Url", $params.Url) + $result.Add("InstallAccount", $params.InstallAccount) + return $result + } + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $AllowObjectModelOverride, + [parameter(Mandatory = $false)] [System.UInt32] $AdminThreshold, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewLookupThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $HappyHourEnabled, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $HappyHour, + [parameter(Mandatory = $false)] [System.UInt32] $UniquePermissionThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $RequestThrottling, + [parameter(Mandatory = $false)] [System.Boolean] $ChangeLogEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $ChangeLogExpiryDays, + [parameter(Mandatory = $false)] [System.Boolean] $EventHandlersEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting web application '$Url' throttling settings" + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { + $params = $args[0] + $ScriptRoot = $args[1] + + $wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue + if ($null -eq $wa) { + throw "Web application $($params.Url) was not found" + return + } + + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + Set-xSPWebApplicationThrottlingSettings -WebApplication $wa -Settings $params + $wa.Update() + + # Happy hour settings + if ($params.ContainsKey("HappyHour") -eq $true) { + # Happy hour settins use separate update method so use a fresh web app to update these + $wa2 = Get-SPWebApplication -Identity $params.Url + Set-xSPWebApplicationHappyHourSettings -WebApplication $wa2 -Settings $params.HappyHour + } + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $AllowObjectModelOverride, + [parameter(Mandatory = $false)] [System.UInt32] $AdminThreshold, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewLookupThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $HappyHourEnabled, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $HappyHour, + [parameter(Mandatory = $false)] [System.UInt32] $UniquePermissionThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $RequestThrottling, + [parameter(Mandatory = $false)] [System.Boolean] $ChangeLogEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $ChangeLogExpiryDays, + [parameter(Mandatory = $false)] [System.Boolean] $EventHandlersEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for web application '$Url' throttling settings" + if ($null -eq $CurrentValues) { return $false } + + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + return Test-xSPWebApplicationThrottlingSettings -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof new file mode 100644 index 000000000..eaa3ddb15 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof @@ -0,0 +1,26 @@ +[ClassVersion("1.0.0")] +Class MSFT_xSPWebApplicationHappyHour +{ + [write] uint32 Hour; + [write] uint32 Minute; + [write] uint32 Duration; + +}; + +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppThrottlingSettings")] +Class MSFT_xSPWebAppThrottlingSettings +{ + [Key] string Url; + [write] uint32 ListViewThreshold; + [write] boolean AllowObjectModelOverride; + [write] uint32 AdminThreshold; + [write] uint32 ListViewLookupThreshold; + [write] boolean HappyHourEnabled; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationHappyHour")] string HappyHour; + [write] uint32 UniquePermissionThreshold; + [write] boolean RequestThrottling; + [write] boolean ChangeLogEnabled; + [write] uint32 ChangeLogExpiryDays; + [write] boolean EventHandlersEnabled; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; +}; \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.psm1 new file mode 100644 index 000000000..c5841a5d6 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.psm1 @@ -0,0 +1,87 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.Boolean] $ExternalWorkflowParticipantsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $UserDefinedWorkflowsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $EmailToNoPermissionWorkflowParticipantsEnable, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting web application '$url' workflow settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { + $params = $args[0] + $ScriptRoot = $args[1] + + + $wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue + if ($null -eq $wa) { return $null } + + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + + $result = Get-xSPWebApplicationWorkflowSettings -WebApplication $wa + $result.Add("Url", $params.Url) + $result.Add("InstallAccount", $params.InstallAccount) + return $result + } + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.Boolean] $ExternalWorkflowParticipantsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $UserDefinedWorkflowsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $EmailToNoPermissionWorkflowParticipantsEnable, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting web application '$Url' workflow settings" + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { + $params = $args[0] + $ScriptRoot = $args[1] + + $wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue + if ($null -eq $wa) { + throw "Web application $($params.Url) was not found" + return + } + + Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + Set-xSPWebApplicationWorkflowSettings -WebApplication $wa -Settings $params + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.Boolean] $ExternalWorkflowParticipantsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $UserDefinedWorkflowsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $EmailToNoPermissionWorkflowParticipantsEnable, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for web application '$Url' workflow settings" + if ($null -eq $CurrentValues) { return $false } + + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + return Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof new file mode 100644 index 000000000..3cfcd9edd --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof @@ -0,0 +1,9 @@ +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppWorkflowSettings")] +Class MSFT_xSPWebAppWorkflowSettings +{ + [Key] string Url; + [write] boolean ExternalWorkflowParticipantsEnabled; + [write] boolean UserDefinedWorkflowsEnabled; + [write] boolean EmailToNoPermissionWorkflowParticipantsEnable; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; +}; \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index b7b829558..fd2359148 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -15,11 +15,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Getting web application '$Name'" @@ -28,7 +24,6 @@ function Get-TargetResource $params = $args[0] $ScriptRoot = $args[1] - $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { return $null } @@ -79,11 +74,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Creating web application '$Name'" @@ -181,11 +172,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index 1e236d6c9..fff10e1a3 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,65 +1,4 @@ -[ClassVersion("1.0.0")] -Class MSFT_xSPBlockedFileTypes -{ - [write] string Blocked[]; - [write] string EnsureBlocked[]; - [write] string EnsureAllowed[]; -}; - -[ClassVersion("1.0.0")] -Class MSFT_xSPWebApplicationHappyHour -{ - [write] uint32 Hour; - [write] uint32 Minute; - [write] uint32 Duration; - -}; - -[ClassVersion("1.0.0")] -Class MSFT_xSPWebApplicationThrottling -{ - [write] uint32 ListViewThreshold; - [write] boolean AllowObjectModelOverride; - [write] uint32 AdminThreshold; - [write] uint32 ListViewLookupThreshold; - [write] boolean HappyHourEnabled; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationHappyHour")] string HappyHour; - [write] uint32 UniquePermissionThreshold; - [write] boolean RequestThrottling; - [write] boolean ChangeLogEnabled; - [write] uint32 ChangeLogExpiryDays; - [write] boolean EventHandlersEnabled; -}; - -[ClassVersion("1.0.0")] -Class MSFT_xSPWebApplicationWorkflowSettings -{ - [write] boolean ExternalWorkflowParticipantsEnabled; - [write] boolean UserDefinedWorkflowsEnabled; - [write] boolean EmailToNoPermissionWorkflowParticipantsEnable; -}; - -[ClassVersion("1.0.0")] -Class MSFT_xSPWebApplicationSettings -{ - [write] uint32 TimeZone; - [write] boolean Alerts; - [write] uint32 AlertsLimit; - [write] boolean RSS; - [write] boolean BlogAPI; - [write] boolean BlogAPIAuthenticated; - [write, ValueMap{"Strict","Permissive"}, Values{"Stric","Permissive"}] String BrowserFileHandling; - [write] boolean SecurityValidation; - [write] boolean RecycleBinEnabled; - [write] boolean RecycleBinCleanupEnabled; - [write] uint32 RecycleBinRetentionPeriod; - [write] uint32 SecondStageRecycleBinQuota; - [write] uint32 MaximumUploadSize; - [write] boolean CustomerExperienceProgram; - [write] boolean PresenceEnabled; -}; - -/* +/* **Description** This resource is responsible for creating a web application within the local SharePoint farm. @@ -96,9 +35,5 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Path; [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationSettings")] string GeneralSettings; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationWorkflowSettings")] string WorkflowSettings; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationThrottling")] string ThrottlingSettings; - [Write, EmbeddedInstance("MSFT_xSPBlockedFileTypes")] string BlockedFileTypes; }; diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 index 137401e5b..2096f1a67 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -15,25 +15,25 @@ function Set-xSPWebApplicationBlockedFileTypes { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) - if ((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $true -and ((Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $true -or (Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $true)) { + if (($Settings.ContainsKey("Blocked") -eq $true) -and (($Settings.ContainsKey("EnsureBlocked") -eq $true) -or ($Settings.ContainsKey("EnsureAllowed") -eq $true))) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } - if ((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $false -and (Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $false -and (Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $false) { + if (($Settings.ContainsKey("Blocked") -eq $false) -and ($Settings.ContainsKey("EnsureBlocked") -eq $false) -and ($Settings.ContainsKey("EnsureAllowed") -eq $false)) { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $true) { + if($Settings.ContainsKey("Blocked") -eq $true) { $WebApplication.BlockedFileExtensions.Clear(); $Settings.Blocked | ForEach-Object { $WebApplication.BlockedFileExtensions.Add($_.ToLower()); } } - if((Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $true) { + if($Settings.ContainsKey("EnsureBlocked") -eq $true) { $Settings.EnsureBlocked | ForEach-Object { if(!$WebApplication.BlockedFileExtensions.Contains($_.ToLower())){ $WebApplication.BlockedFileExtensions.Add($_.ToLower()); @@ -41,7 +41,7 @@ function Set-xSPWebApplicationBlockedFileTypes { } } - if((Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $true) { + if($Settings.ContainsKey("EnsureAllowed") -eq $true) { $Settings.EnsureAllowed | ForEach-Object { if($WebApplication.BlockedFileExtensions.Contains($_.ToLower())){ $WebApplication.BlockedFileExtensions.Remove($_.ToLower()); @@ -55,28 +55,27 @@ function Test-xSPWebApplicationBlockedFileTypes { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings + [parameter(Mandatory = $true)] $DesiredSettings ) - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) - if ((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $true -and ((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $true -or (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $true)) { + if (($DesiredSettings.ContainsKey("Blocked") -eq $true) -and (($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) -or ($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true))) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } - if ((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $false -and (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $false -and (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $false) { + if (($DesiredSettings.ContainsKey("Blocked") -eq $false) -and ($DesiredSettings.ContainsKey("EnsureBlocked") -eq $false) -and ($DesiredSettings.ContainsKey("EnsureAllowed") -eq $false)) { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $true) { + if($DesiredSettings.ContainsKey("Blocked") -eq $true) { $compareResult = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.Blocked if ($compareResult -eq $null) { return $true } else { return $false } } - if((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $true) { + if($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) { $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked -ExcludeDifferent if ($itemsToRemove -ne $null) { return $false } } - if((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $true) { + if($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true) { $itemsToAdd = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureAllowed | Where-Object { $_.SideIndicator -eq "=>"} if ($itemsToAdd -ne $null) { $compareResult = Compare-Object -ReferenceObject $DesiredSettings.EnsureAllowed -DifferenceObject $itemsToAdd.InputObject diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 index 81c37ac6e..feb2197c3 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 @@ -28,7 +28,7 @@ function Set-xSPWebApplicationGeneralSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) # Format here is SPWebApplication property = Custom settings property @@ -67,7 +67,7 @@ function Test-xSPWebApplicationGeneralSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings + [parameter(Mandatory = $true)] $DesiredSettings ) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 index 2335d377c..cf6dff20f 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -27,7 +27,7 @@ function Set-xSPWebApplicationThrottlingSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) # Format here is SPWebApplication property = Custom settings property @@ -65,7 +65,7 @@ function Set-xSPWebApplicationHappyHourSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) if ((Test-xSharePointObjectHasProperty $Settings "Hour") -eq $false -or (Test-xSharePointObjectHasProperty $Settings "Minute") -eq $false -or (Test-xSharePointObjectHasProperty $Settings "Duration") -eq $false) { @@ -89,7 +89,7 @@ function Test-xSPWebApplicationThrottlingSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings + [parameter(Mandatory = $true)] $DesiredSettings ) Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 index aa3a80634..8a6485c3c 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 @@ -15,15 +15,15 @@ function Set-xSPWebApplicationWorkflowSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) - if((Test-xSharePointObjectHasProperty $Settings "UserDefinedWorkflowsEnabled") -eq $true) { + if($Settings.ContainsKey("UserDefinedWorkflowsEnabled") -eq $true) { $WebApplication.UserDefinedWorkflowsEnabled = $Settings.UserDefinedWorkflowsEnabled; } - if((Test-xSharePointObjectHasProperty $Settings "EmailToNoPermissionWorkflowParticipantsEnable") -eq $true) { + if($Settings.ContainsKey("EmailToNoPermissionWorkflowParticipantsEnable") -eq $true) { $WebApplication.EmailToNoPermissionWorkflowParticipantsEnabled = $Settings.EmailToNoPermissionWorkflowParticipantsEnable; } - if((Test-xSharePointObjectHasProperty $Settings "ExternalWorkflowParticipantsEnabled") -eq $true) { + if($Settings.ContainsKey("ExternalWorkflowParticipantsEnabled") -eq $true) { $WebApplication.ExternalWorkflowParticipantsEnabled = $Settings.ExternalWorkflowParticipantsEnabled; } $WebApplication.UpdateWorkflowConfigurationSettings(); @@ -34,7 +34,7 @@ function Test-xSPWebApplicationWorkflowSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings + [parameter(Mandatory = $true)] $DesiredSettings ) Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebAppBlockedFileTypes.Tests.ps1 similarity index 86% rename from Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 rename to Tests/xSharePoint/xSharePoint.xSPWebAppBlockedFileTypes.Tests.ps1 index 786582648..81d906782 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebAppBlockedFileTypes.Tests.ps1 @@ -9,20 +9,14 @@ Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path $Global:CurrentSharePointStubModule = $SharePointCmdletModule -$ModuleName = "MSFT_xSPWebApplication" +$ModuleName = "MSFT_xSPWebAppBlockedFileTypes" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Describe "xSPWebApplication (Blocked file types)" { +Describe "xSPWebAppBlockedFileTypes" { InModuleScope $ModuleName { $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPBlockedFileTypes -Property @{ - Blocked = @("exe", "dll", "ps1") - } -ClientOnly) + Blocked = @("exe", "dll", "ps1") } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -116,15 +110,9 @@ Describe "xSPWebApplication (Blocked file types)" { } $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPBlockedFileTypes -Property @{ - EnsureBlocked = @("exe") - EnsureAllowed = @("pdf") - } -ClientOnly) + EnsureBlocked = @("exe") + EnsureAllowed = @("pdf") } Context "The web appliation exists and a list of types to include and exclude both match" { @@ -233,16 +221,10 @@ Describe "xSPWebApplication (Blocked file types)" { } $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPBlockedFileTypes -Property @{ - Blocked = @("exe", "dll", "ps1") - EnsureBlocked = @("exe", "dll") - EnsureAllowed = @("ps1") - } -ClientOnly) + Blocked = @("exe", "dll", "ps1") + EnsureBlocked = @("exe", "dll") + EnsureAllowed = @("ps1") } It "throws an exception on the test method" { @@ -282,13 +264,7 @@ Describe "xSPWebApplication (Blocked file types)" { } $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPBlockedFileTypes -Property @{ - } -ClientOnly) } It "throws an exception on the test method" { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebAppGeneralSettings.Tests.ps1 similarity index 67% rename from Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 rename to Tests/xSharePoint/xSharePoint.xSPWebAppGeneralSettings.Tests.ps1 index 48063a362..154fc4bc2 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebAppGeneralSettings.Tests.ps1 @@ -9,35 +9,29 @@ Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path $Global:CurrentSharePointStubModule = $SharePointCmdletModule -$ModuleName = "MSFT_xSPWebApplication" +$ModuleName = "MSFT_xSPWebAppGeneralSettings" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Describe "xSPWebApplication (General Settings)" { +Describe "xSPWebAppGeneralSettings" { InModuleScope $ModuleName { $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - GeneralSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationSettings -Property @{ - TimeZone = 3081 - Alerts = $true - AlertsLimit = 10 - RSS = $true - BlogAPI = $true - BlogAPIAuthenticated = $true - BrowserFileHandling = "Permissive" - SecurityValidation = $true - RecycleBinEnabled = $true - RecycleBinCleanupEnabled = $true - RecycleBinRetentionPeriod = 30 - SecondStageRecycleBinQuota = 30 - MaximumUploadSize = 100 - CustomerExperienceProgram = $true - PresenceEnabled = $true - } -ClientOnly) + TimeZone = 3081 + Alerts = $true + AlertsLimit = 10 + RSS = $true + BlogAPI = $true + BlogAPIAuthenticated = $true + BrowserFileHandling = "Permissive" + SecurityValidation = $true + RecycleBinEnabled = $true + RecycleBinCleanupEnabled = $true + RecycleBinRetentionPeriod = 30 + SecondStageRecycleBinQuota = 30 + MaximumUploadSize = 100 + CustomerExperienceProgram = $true + PresenceEnabled = $true } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -70,23 +64,23 @@ Describe "xSPWebApplication (General Settings)" { @{ Path = "C:\inetpub\wwwroot\something" } ) Url = $testParams.Url - DefaultTimeZone = $testParams.GeneralSettings.TimeZone - AlertsEnabled = $testParams.GeneralSettings.Alerts - AlertsMaximum = $testParams.GeneralSettings.AlertsLimit - SyndicationEnabled = $testParams.GeneralSettings.RSS - MetaWeblogEnabled = $testParams.GeneralSettings.BlogAPI - MetaWeblogAuthenticationEnabled = $testParams.GeneralSettings.BlogAPIAuthenticated - BrowserFileHandling = $testParams.GeneralSettings.BrowserFileHandling + DefaultTimeZone = $testParams.TimeZone + AlertsEnabled = $testParams.Alerts + AlertsMaximum = $testParams.AlertsLimit + SyndicationEnabled = $testParams.RSS + MetaWeblogEnabled = $testParams.BlogAPI + MetaWeblogAuthenticationEnabled = $testParams.BlogAPIAuthenticated + BrowserFileHandling = $testParams.BrowserFileHandling FormDigestSettings = @{ - Enabled = $testParams.GeneralSettings.SecurityValidation + Enabled = $testParams.SecurityValidation } - RecycleBinEnabled = $testParams.GeneralSettings.RecycleBinEnabled - RecycleBinCleanupEnabled = $testParams.GeneralSettings.RecycleBinCleanupEnabled - RecycleBinRetentionPeriod = $testParams.GeneralSettings.RecycleBinRetentionPeriod - SecondStageRecycleBinQuota = $testParams.GeneralSettings.SecondStageRecycleBinQuota - MaximumFileSize = $testParams.GeneralSettings.MaximumUploadSize - BrowserCEIPEnabled = $testParams.GeneralSettings.CustomerExperienceProgram - PresenceEnabled = $testParams.GeneralSettings.PresenceEnabled + RecycleBinEnabled = $testParams.RecycleBinEnabled + RecycleBinCleanupEnabled = $testParams.RecycleBinCleanupEnabled + RecycleBinRetentionPeriod = $testParams.RecycleBinRetentionPeriod + SecondStageRecycleBinQuota = $testParams.SecondStageRecycleBinQuota + MaximumFileSize = $testParams.MaximumUploadSize + BrowserCEIPEnabled = $testParams.CustomerExperienceProgram + PresenceEnabled = $testParams.PresenceEnabled } $webApp = $webApp | Add-Member ScriptMethod Update { $Global:xSPWebApplicationUpdateCalled = $true @@ -154,7 +148,7 @@ Describe "xSPWebApplication (General Settings)" { } $Global:xSPWebApplicationUpdateCalled = $false - It "updates the workflow settings" { + It "updates the general settings" { Set-TargetResource @testParams $Global:xSPWebApplicationUpdateCalled | Should Be $true } diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebAppThrottlingSettings.Tests.ps1 similarity index 73% rename from Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 rename to Tests/xSharePoint/xSharePoint.xSPWebAppThrottlingSettings.Tests.ps1 index d11984155..22dff8dfd 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebAppThrottlingSettings.Tests.ps1 @@ -9,34 +9,28 @@ Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path $Global:CurrentSharePointStubModule = $SharePointCmdletModule -$ModuleName = "MSFT_xSPWebApplication" +$ModuleName = "MSFT_xSPWebAppThrottlingSettings" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Describe "xSPWebApplication (Throttling)" { +Describe "xSPWebAppThrottlingSettings" { InModuleScope $ModuleName { $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ - ListViewThreshold = 1000 - AllowObjectModelOverride = $true - AdminThreshold = 2000 - ListViewLookupThreshold = 12 - HappyHourEnabled = $true - HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ - Hour = 2 - Minute = 0 - Duration = 1 - } -ClientOnly) - UniquePermissionThreshold = 100 - RequestThrottling = $true - ChangeLogEnabled = $true - ChangeLogExpiryDays = 30 - EventHandlersEnabled = $true + ListViewThreshold = 1000 + AllowObjectModelOverride = $true + AdminThreshold = 2000 + ListViewLookupThreshold = 12 + HappyHourEnabled = $true + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ + Hour = 2 + Minute = 0 + Duration = 1 } -ClientOnly) + UniquePermissionThreshold = 100 + RequestThrottling = $true + ChangeLogEnabled = $true + ChangeLogExpiryDays = 30 + EventHandlersEnabled = $true } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -68,23 +62,23 @@ Describe "xSPWebApplication (Throttling)" { @{ Path = "C:\inetpub\wwwroot\something" } ) Url = $testParams.Url - MaxItemsPerThrottledOperation = $testParams.ThrottlingSettings.ListViewThreshold - AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride - MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold - MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold - UnthrottledPrivilegedOperationWindowEnabled = $testParams.ThrottlingSettings.HappyHourEnabled - DailyStartUnthrottledPrivilegedOperationsHour = $testParams.ThrottlingSettings.HappyHour.Hour - DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.ThrottlingSettings.HappyHour.Minute - DailyUnthrottledPrivilegedOperationsDuration = $testParams.ThrottlingSettings.HappyHour.Duration - MaxUniquePermScopesPerList = $testParams.ThrottlingSettings.UniquePermissionThreshold + MaxItemsPerThrottledOperation = $testParams.ListViewThreshold + AllowOMCodeOverrideThrottleSettings = $testParams.AllowObjectModelOverride + MaxItemsPerThrottledOperationOverride = $testParams.AdminThreshold + MaxQueryLookupFields = $testParams.ListViewLookupThreshold + UnthrottledPrivilegedOperationWindowEnabled = $testParams.HappyHourEnabled + DailyStartUnthrottledPrivilegedOperationsHour = $testParams.HappyHour.Hour + DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.HappyHour.Minute + DailyUnthrottledPrivilegedOperationsDuration = $testParams.HappyHour.Duration + MaxUniquePermScopesPerList = $testParams.UniquePermissionThreshold HttpThrottleSettings = @{ - PerformThrottle = $testParams.ThrottlingSettings.RequestThrottling + PerformThrottle = $testParams.RequestThrottling } - ChangeLogExpirationEnabled = $testParams.ThrottlingSettings.ChangeLogEnabled + ChangeLogExpirationEnabled = $testParams.ChangeLogEnabled ChangeLogRetentionPeriod = @{ - Days = $testParams.ThrottlingSettings.ChangeLogExpiryDays + Days = $testParams.ChangeLogExpiryDays } - EventHandlersEnabled = $testParams.ThrottlingSettings.EventHandlersEnabled + EventHandlersEnabled = $testParams.EventHandlersEnabled })} It "returns the current data from the get method" { @@ -115,22 +109,22 @@ Describe "xSPWebApplication (Throttling)" { ) Url = $testParams.Url MaxItemsPerThrottledOperation = 1 - AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride - MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold - MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold - UnthrottledPrivilegedOperationWindowEnabled = $testParams.ThrottlingSettings.HappyHourEnabled - DailyStartUnthrottledPrivilegedOperationsHour = $testParams.ThrottlingSettings.HappyHour.Hour - DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.ThrottlingSettings.HappyHour.Minute - DailyUnthrottledPrivilegedOperationsDuration = $testParams.ThrottlingSettings.HappyHour.Duration - MaxUniquePermScopesPerList = $testParams.ThrottlingSettings.UniquePermissionThreshold + AllowOMCodeOverrideThrottleSettings = $testParams.AllowObjectModelOverride + MaxItemsPerThrottledOperationOverride = $testParams.AdminThreshold + MaxQueryLookupFields = $testParams.ListViewLookupThreshold + UnthrottledPrivilegedOperationWindowEnabled = $testParams.HappyHourEnabled + DailyStartUnthrottledPrivilegedOperationsHour = $testParams.HappyHour.Hour + DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.HappyHour.Minute + DailyUnthrottledPrivilegedOperationsDuration = $testParams.HappyHour.Duration + MaxUniquePermScopesPerList = $testParams.UniquePermissionThreshold HttpThrottleSettings = @{ - PerformThrottle = $testParams.ThrottlingSettings.RequestThrottling + PerformThrottle = $testParams.RequestThrottling } - ChangeLogExpirationEnabled = $testParams.ThrottlingSettings.ChangeLogEnabled + ChangeLogExpirationEnabled = $testParams.ChangeLogEnabled ChangeLogRetentionPeriod = @{ - Days = $testParams.ThrottlingSettings.ChangeLogExpiryDays + Days = $testParams.ChangeLogExpiryDays } - EventHandlersEnabled = $testParams.ThrottlingSettings.EventHandlersEnabled + EventHandlersEnabled = $testParams.EventHandlersEnabled } $webApp = $webApp | Add-Member ScriptMethod Update { $Global:xSPWebApplicationUpdateCalled = $true @@ -156,28 +150,22 @@ Describe "xSPWebApplication (Throttling)" { } $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ - ListViewThreshold = 1000 - AllowObjectModelOverride = $true - AdminThreshold = 2000 - ListViewLookupThreshold = 12 - HappyHourEnabled = $true - HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ - Hour = 5 - Minute = 0 - Duration = 1 - } -ClientOnly) - UniquePermissionThreshold = 100 - RequestThrottling = $true - ChangeLogEnabled = $true - ChangeLogExpiryDays = 30 - EventHandlersEnabled = $true + ListViewThreshold = 1000 + AllowObjectModelOverride = $true + AdminThreshold = 2000 + ListViewLookupThreshold = 12 + HappyHourEnabled = $true + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ + Hour = 5 + Minute = 0 + Duration = 1 } -ClientOnly) + UniquePermissionThreshold = 100 + RequestThrottling = $true + ChangeLogEnabled = $true + ChangeLogExpiryDays = 30 + EventHandlersEnabled = $true } $Global:xSPWebApplicationUpdateCalled = $false $Global:xSPWebApplicationUpdateHappyHourCalled = $false diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebAppWorkflowSettings.Tests.ps1 similarity index 88% rename from Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 rename to Tests/xSharePoint/xSharePoint.xSPWebAppWorkflowSettings.Tests.ps1 index 9f346519d..78695e312 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebAppWorkflowSettings.Tests.ps1 @@ -9,22 +9,16 @@ Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path $Global:CurrentSharePointStubModule = $SharePointCmdletModule -$ModuleName = "MSFT_xSPWebApplication" +$ModuleName = "MSFT_xSPWebAppWorkflowSettings" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Describe "xSPWebApplication (Workflow)" { +Describe "xSPWebAppWorkflowSettings" { InModuleScope $ModuleName { $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - WorkflowSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationWorkflowSettings -Property @{ - ExternalWorkflowParticipantsEnabled = $true - UserDefinedWorkflowsEnabled = $true - EmailToNoPermissionWorkflowParticipantsEnable = $true - } -ClientOnly) + ExternalWorkflowParticipantsEnabled = $true + UserDefinedWorkflowsEnabled = $true + EmailToNoPermissionWorkflowParticipantsEnable = $true } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") From b5095c96c8a04f155e269643a10a0222f904a615 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 12:16:54 +1100 Subject: [PATCH 134/147] Fixed formatting --- .../MSFT_xSPWebAppBlockedFileTypes.schema.mof | 2 +- .../MSFT_xSPWebAppGeneralSettings.schema.mof | 2 +- .../MSFT_xSPWebAppThrottlingSettings.schema.mof | 2 +- .../MSFT_xSPWebAppWorkflowSettings.schema.mof | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof index 993caed58..51daffbcc 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof @@ -5,5 +5,5 @@ Class MSFT_xSPBlockedFileTypes [write] string Blocked[]; [write] string EnsureBlocked[]; [write] string EnsureAllowed[]; - [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; }; \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof index b31f2b26d..f902a80bb 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof @@ -17,5 +17,5 @@ Class MSFT_xSPWebAppGeneralSettings [write] uint32 MaximumUploadSize; [write] boolean CustomerExperienceProgram; [write] boolean PresenceEnabled; - [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof index eaa3ddb15..b81d155fd 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof @@ -22,5 +22,5 @@ Class MSFT_xSPWebAppThrottlingSettings [write] boolean ChangeLogEnabled; [write] uint32 ChangeLogExpiryDays; [write] boolean EventHandlersEnabled; - [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; }; \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof index 3cfcd9edd..d9cb8ee71 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof @@ -5,5 +5,5 @@ Class MSFT_xSPWebAppWorkflowSettings [write] boolean ExternalWorkflowParticipantsEnabled; [write] boolean UserDefinedWorkflowsEnabled; [write] boolean EmailToNoPermissionWorkflowParticipantsEnable; - [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; }; \ No newline at end of file From 860aa934e882b48845e915c34a88d1927b75cac1 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 12:47:04 +1100 Subject: [PATCH 135/147] Updated MOF documentation for new types, removed old functionality from xSPWebApplication --- .../MSFT_xSPWebAppBlockedFileTypes.schema.mof | 23 +++++- .../MSFT_xSPWebAppGeneralSettings.schema.mof | 20 ++++- ...SFT_xSPWebAppThrottlingSettings.schema.mof | 24 ++++++ .../MSFT_xSPWebAppWorkflowSettings.schema.mof | 19 ++++- .../MSFT_xSPWebApplication.psm1 | 82 ------------------- 5 files changed, 83 insertions(+), 85 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof index 51daffbcc..9772b383c 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof @@ -1,4 +1,25 @@ -[ClassVersion("1.0.0"), FriendlyName("xSPBlockedFileTypes")] +/* +**Description** + +This resource is responsible for controlling the blocked file type setting on a specific web application. +It has two modes of operation, the first is to use the 'blocked' property, where you are able to define a specific list of file types that will be blocked. +In this mode when it is detected that the list does not match the local farm, it is set to match this list exactly. +The second mode is to use the 'EnsureBlocked' and 'EnsureAllowed' properties. +EnsureBlocked will check to make sure that the specified file types are on the list, and if not they will be added. +EnsureAllowed checks to make sure that a file type is not on the list, and if it is it will be removed. +Both of these properties will only make changes to the file types in their list and will leave the full list as it is otherwise, whereas the blocked property resets the list in full. + +**Example** + + xSPBlockedFileTypes PrimaryWebAppBlockedFileTypes + { + Url = "Shttp://exmaple.contoso.local" + EnsureBlocked = @("exe", "dll", "msi") + EnsureAllowed = @("pdf", "docx", "xlsx") + PsDscRunAsCredential = $InstallAccount + } +*/ +[ClassVersion("1.0.0"), FriendlyName("xSPBlockedFileTypes")] Class MSFT_xSPBlockedFileTypes { [Key] string Url; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof index f902a80bb..2ab9efff9 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof @@ -1,4 +1,22 @@ -[ClassVersion("1.0.0"), FriendlyName("xSPWebAppGeneralSettings")] +/* +**Description** + +This resource is responsible for setting web application settings that are found under the "general settings" screen in central admin. +The web application is specified through the URL property, and then any combination of settings can be applied. +Any settings not included will be left as the default (or whatever they have been manually changed to within SharePoint). + +**Example** + + xSPWebAppGeneralSettings PrimaryWebAppGeneralSettings + { + Url = "Shttp://exmaple.contoso.local" + TimeZone = 76 + Alerts = $true + RSS = $false + PsDscRunAsCredential = $InstallAccount + } +*/ +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppGeneralSettings")] Class MSFT_xSPWebAppGeneralSettings { [Key] string Url; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof index b81d155fd..4284eba39 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof @@ -6,7 +6,31 @@ Class MSFT_xSPWebApplicationHappyHour [write] uint32 Duration; }; +/* +**Description** +This resource is responsible for setting web application settings that are found under the "resource throttling" screen in central admin. +The web application is specified through the URL property, and then any combination of settings can be applied. +Any settings not included will be left as the default (or whatever they have been manually changed to within SharePoint). +Happy hour is the setting used to control the window where threshold do not apply throughout the day. +You can specify the start time of this window as well as how many hours it will last. + +**Example** + + xSPWebAppThrottlingSettings PrimaryWebAppThrottlingSettings + { + Url = "Shttp://exmaple.contoso.local" + ListViewThreshold = 5000 + AllowObjectModelOverride = $false + HappyHourEnabled = $true + HappyHour = MSFT_xSPWebApplicationHappyHour { + Hour = 3 + Minute = 0 + Duration = 1 + } + PsDscRunAsCredential = $InstallAccount + } +*/ [ClassVersion("1.0.0"), FriendlyName("xSPWebAppThrottlingSettings")] Class MSFT_xSPWebAppThrottlingSettings { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof index d9cb8ee71..d91fdbfee 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof @@ -1,4 +1,21 @@ -[ClassVersion("1.0.0"), FriendlyName("xSPWebAppWorkflowSettings")] +/* +**Description** + +This resource is responsible for setting web application settings that are found under the "workflow settings" screen in central admin. +The web application is specified through the URL property, and then any combination of settings can be applied. +Any settings not included will be left as the default (or whatever they have been manually changed to within SharePoint). + +**Example** + + xSPWebAppWorkflowSettings PrimaryWebAppWorkflowSettings + { + Url = "Shttp://exmaple.contoso.local" + ExternalWorkflowParticipantsEnabled = $false + EmailToNoPermissionWorkflowParticipantsEnable = $false + PsDscRunAsCredential = $InstallAccount + } +*/ +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppWorkflowSettings")] Class MSFT_xSPWebAppWorkflowSettings { [Key] string Url; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index fd2359148..1aaffa8cc 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -30,11 +30,6 @@ function Get-TargetResource $authProvider = Get-SPAuthenticationProvider -WebApplication $wa.Url -Zone "Default" if ($authProvider.DisableKerberos -eq $true) { $localAuthMode = "NTLM" } else { $localAuthMode = "Kerberos" } - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) - return @{ Name = $wa.DisplayName ApplicationPool = $wa.ApplicationPool.Name @@ -48,10 +43,6 @@ function Get-TargetResource Port = (New-Object System.Uri $wa.Url).Port AuthenticationMethod = $localAuthMode InstallAccount = $params.InstallAccount - ThrottlingSettings = (Get-xSPWebApplicationThrottlingSettings -WebApplication $wa) - WorkflowSettings = (Get-xSPWebApplicationWorkflowSettings -WebApplication $wa) - BlockedFileTypes = (Get-xSPWebApplicationBlockedFileTypes -WebApplication $wa) - GeneralSettings = (Get-xSPWebApplicationGeneralSettings -WebApplication $wa) } } return $result @@ -109,48 +100,6 @@ function Set-TargetResource $wa = New-SPWebApplication @newWebAppParams } - - # Resource throttling settings - if ($params.ContainsKey("ThrottlingSettings") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - Set-xSPWebApplicationThrottlingSettings -WebApplication $wa -Settings $params.ThrottlingSettings - } - - # Blocked file types - if ($params.ContainsKey("BlockedFileTypes") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) - Set-xSPWebApplicationBlockedFileTypes -WebApplication $wa -Settings $params.BlockedFileTypes - } - - # General Settings - if ($params.ContainsKey("GeneralSettings") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) - Set-xSPWebApplicationGeneralSettings -WebApplication $wa -Settings $params.GeneralSettings - } - - if( ($params.GeneralSettings -ne $null) -or - ($params.ThrottlingSettings -ne $null) -or - ($params.BlockedFileTypes -ne $null) ) { - $wa.Update() - } - - # Workflow settings - if ($params.ContainsKey("WorkflowSettings") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - # Workflow uses a seperate update method, to avoid update conflicts get a fresh web app object - $wa2 = Get-SPWebApplication -Identity $params.Name - Set-xSPWebApplicationWorkflowSettings -WebApplication $wa2 -Settings $params.WorkflowSettings - } - - # Happy hour settings - if ($params.ContainsKey("ThrottlingSettings") -eq $true) { - if ((Test-xSharePointObjectHasProperty $params.ThrottlingSettings "HappyHour") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - # Happy hour settins use separate update method so use a fresh web app to update these - $wa3 = Get-SPWebApplication -Identity $params.Name - Set-xSPWebApplicationHappyHourSettings -WebApplication $wa3 -Settings $params.ThrottlingSettings.HappyHour - } - } } } @@ -182,37 +131,6 @@ function Test-TargetResource $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool") - - if ($testReturn -eq $false) { return $false } - - # Resource throttling settings - if ($PSBoundParameters.ContainsKey("ThrottlingSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationThrottlingSettings -CurrentSettings $CurrentValues.ThrottlingSettings -DesiredSettings $ThrottlingSettings - } - if ($testReturn -eq $false) { return $false } - - # Workflow settings - if ($PSBoundParameters.ContainsKey("WorkflowSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues.WorkflowSettings -DesiredSettings $WorkflowSettings - } - if ($testReturn -eq $false) { return $false } - - # Blocked file types - if ($PSBoundParameters.ContainsKey("BlockedFileTypes") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationBlockedFileTypes -CurrentSettings $CurrentValues.BlockedFileTypes -DesiredSettings $BlockedFileTypes - } - if ($testReturn -eq $false) { return $false } - - # General settings - if ($PSBoundParameters.ContainsKey("GeneralSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationGeneralSettings -CurrentSettings $CurrentValues.GeneralSettings -DesiredSettings $GeneralSettings - } - if ($testReturn -eq $false) { return $false } - return $testReturn } From 20021364ba12e6c2e966a98498e919f3eba9638e Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 12:49:17 +1100 Subject: [PATCH 136/147] formatting fixes (again) --- .../MSFT_xSPWebAppBlockedFileTypes.schema.mof | 2 +- .../MSFT_xSPWebAppGeneralSettings.schema.mof | 4 ++-- .../MSFT_xSPWebAppThrottlingSettings.schema.mof | 14 +++++++------- .../MSFT_xSPWebAppWorkflowSettings.schema.mof | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof index 9772b383c..3e5f65d98 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof @@ -15,7 +15,7 @@ Both of these properties will only make changes to the file types in their list { Url = "Shttp://exmaple.contoso.local" EnsureBlocked = @("exe", "dll", "msi") - EnsureAllowed = @("pdf", "docx", "xlsx") + EnsureAllowed = @("pdf", "docx", "xlsx") PsDscRunAsCredential = $InstallAccount } */ diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof index 2ab9efff9..afaa0cfae 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof @@ -11,8 +11,8 @@ Any settings not included will be left as the default (or whatever they have bee { Url = "Shttp://exmaple.contoso.local" TimeZone = 76 - Alerts = $true - RSS = $false + Alerts = $true + RSS = $false PsDscRunAsCredential = $InstallAccount } */ diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof index 4284eba39..a4a69f50d 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof @@ -21,13 +21,13 @@ You can specify the start time of this window as well as how many hours it will { Url = "Shttp://exmaple.contoso.local" ListViewThreshold = 5000 - AllowObjectModelOverride = $false - HappyHourEnabled = $true - HappyHour = MSFT_xSPWebApplicationHappyHour { - Hour = 3 - Minute = 0 - Duration = 1 - } + AllowObjectModelOverride = $false + HappyHourEnabled = $true + HappyHour = MSFT_xSPWebApplicationHappyHour { + Hour = 3 + Minute = 0 + Duration = 1 + } PsDscRunAsCredential = $InstallAccount } */ diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof index d91fdbfee..a20ff7d52 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof @@ -11,7 +11,7 @@ Any settings not included will be left as the default (or whatever they have bee { Url = "Shttp://exmaple.contoso.local" ExternalWorkflowParticipantsEnabled = $false - EmailToNoPermissionWorkflowParticipantsEnable = $false + EmailToNoPermissionWorkflowParticipantsEnable = $false PsDscRunAsCredential = $InstallAccount } */ From c550b23b058ccb51bbf6a3f4cbf510d45b6bf2f8 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 13:16:44 +1100 Subject: [PATCH 137/147] Saved project files with changes --- Modules/xSharePoint/xSharePoint.pssproj | 12 ++++++++++++ Tests/Tests.pssproj | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index d0d73181d..340a110cd 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -76,6 +76,10 @@ + + + + @@ -133,8 +137,12 @@ + + + + @@ -147,6 +155,10 @@ + + + + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 7d475469d..1ab144884 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -72,10 +72,10 @@ - - - - + + + + From fd61125e8b08269933b9177dd652a5228787670f Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 14:20:49 +1100 Subject: [PATCH 138/147] Fixed MOF files base object types --- .../MSFT_xSPWebAppBlockedFileTypes.schema.mof | 4 ++-- .../MSFT_xSPWebAppGeneralSettings.schema.mof | 2 +- .../MSFT_xSPWebAppThrottlingSettings.schema.mof | 2 +- .../MSFT_xSPWebAppWorkflowSettings.schema.mof | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof index 3e5f65d98..e70f46bbc 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof @@ -19,8 +19,8 @@ Both of these properties will only make changes to the file types in their list PsDscRunAsCredential = $InstallAccount } */ -[ClassVersion("1.0.0"), FriendlyName("xSPBlockedFileTypes")] -Class MSFT_xSPBlockedFileTypes +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppBlockedFileTypes")] +Class MSFT_xSPBlockedFileTypes : OMI_BaseResource { [Key] string Url; [write] string Blocked[]; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof index afaa0cfae..f6e535682 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof @@ -17,7 +17,7 @@ Any settings not included will be left as the default (or whatever they have bee } */ [ClassVersion("1.0.0"), FriendlyName("xSPWebAppGeneralSettings")] -Class MSFT_xSPWebAppGeneralSettings +Class MSFT_xSPWebAppGeneralSettings : OMI_BaseResource { [Key] string Url; [write] uint32 TimeZone; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof index a4a69f50d..e7673af15 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof @@ -32,7 +32,7 @@ You can specify the start time of this window as well as how many hours it will } */ [ClassVersion("1.0.0"), FriendlyName("xSPWebAppThrottlingSettings")] -Class MSFT_xSPWebAppThrottlingSettings +Class MSFT_xSPWebAppThrottlingSettings : OMI_BaseResource { [Key] string Url; [write] uint32 ListViewThreshold; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof index a20ff7d52..4dfa86c7f 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof @@ -16,7 +16,7 @@ Any settings not included will be left as the default (or whatever they have bee } */ [ClassVersion("1.0.0"), FriendlyName("xSPWebAppWorkflowSettings")] -Class MSFT_xSPWebAppWorkflowSettings +Class MSFT_xSPWebAppWorkflowSettings : OMI_BaseResource { [Key] string Url; [write] boolean ExternalWorkflowParticipantsEnabled; From 0ee8ea17d1a008586aaa1f01960e6cf56a99f93c Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 14:58:25 +1100 Subject: [PATCH 139/147] Updated readme and build for release of v0.8 --- README.md | 15 ++++++++++++++- appveyor.yml | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7c6199a20..1c4eeeeee 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,13 @@ Please read the installation instructions that are present on both the download Below is a list of DSC resource types that are currently provided by xSharePoint: + - xSPAntivirusSettings - xBCSServiceApp - xSPCacheAccounts - - xSPClearRemoteSessions - xSPCreateFarm - xSPDiagnosticLoggingSettings - xSPDistributedCacheService + - xSPFarmAdministrators - xSPFeature - xSPInstall - xSPInstallPreReqs @@ -45,6 +46,8 @@ Below is a list of DSC resource types that are currently provided by xSharePoint - xSPManagedAccount - xSPManagedMetadataServiceApp - xSPManagedPath + - xSPOutgoingEmailSettings + - xSPPasswordChangeSettings - xSPSearchServiceApp - xSPSecureStoreServiceApp - xSPServiceAppPool @@ -54,7 +57,11 @@ Below is a list of DSC resource types that are currently provided by xSharePoint - xSPUsageApplication - xSPUserProfileServiceApp - xSPUserProfileSyncService + - xSPWebAppBlockedFileTypes + - xSPWebAppGeneralSettings - xSPWebApplication + - xSPWebAppThrottlingSettings + - xSPWebAppWorkflowSettings ## Preview status @@ -68,6 +75,12 @@ Additional detailed documentation is included on the wiki on GitHub. ## Version History +### 0.8.0.0 + * Added xSPAntivirusSettings, xSPFarmAdministrators, xSPOutgoingEmailSettings, xSPPasswordChangeSettings, xSPWebAppBlockedFileTypes, xSPWebAppGeneralSettings, xSPWebAppThrottlingSettings and xSPWebAppWorkflowSettings + * Fixed issue with xSPInstallPrereqs using wrong parameters in offline install mode + * Fixed issue with xSPInstallPrereqs where it would not validate that installer paths exist + * Fixed xSPSecureStoreServiceApp and xSPUsageApplication to use PSCredentials instead of plain text username/password for database credentials + ### 0.7.0.0 * Support for MinRole options in SharePoint 2016 diff --git a/appveyor.yml b/appveyor.yml index 689433c22..d8879089c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.7.{build}.0 +version: 0.8.{build}.0 install: - cinst -y pester @@ -27,7 +27,7 @@ after_test: Remove-Item (Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.pssproj") $manifest = Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.psd1" - (Get-Content $manifest -Raw).Replace("0.7.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest + (Get-Content $manifest -Raw).Replace("0.8.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest Add-Type -assemblyname System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::CreateFromDirectory("$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint", "$env:APPVEYOR_BUILD_FOLDER\xSharePoint.zip") Get-ChildItem "$env:APPVEYOR_BUILD_FOLDER\xSharePoint.zip" | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } From 3ea3c80db3c24ac556354d1b1788224c9013732d Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 15:04:40 +1100 Subject: [PATCH 140/147] Fixed incorrect name of MOF type --- .../MSFT_xSPWebAppBlockedFileTypes.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof index e70f46bbc..123a88276 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof @@ -20,7 +20,7 @@ Both of these properties will only make changes to the file types in their list } */ [ClassVersion("1.0.0"), FriendlyName("xSPWebAppBlockedFileTypes")] -Class MSFT_xSPBlockedFileTypes : OMI_BaseResource +Class MSFT_xSPWebAppBlockedFileTypes : OMI_BaseResource { [Key] string Url; [write] string Blocked[]; From 3a69969ba2a5ca39a050d6c1dc2cd833bbaf7001 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Thu, 3 Dec 2015 15:05:41 +1100 Subject: [PATCH 141/147] Added note about new help to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1c4eeeeee..2b80689fc 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ Additional detailed documentation is included on the wiki on GitHub. * Fixed issue with xSPInstallPrereqs using wrong parameters in offline install mode * Fixed issue with xSPInstallPrereqs where it would not validate that installer paths exist * Fixed xSPSecureStoreServiceApp and xSPUsageApplication to use PSCredentials instead of plain text username/password for database credentials + * Added built in PowerShell help (for calling "Get-Help about_[resource]", such as "Get-Help about_xSPCreateFarm") ### 0.7.0.0 From 57a34e86d00213ad29bb995881cb3241822f2c94 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 5 Dec 2015 18:19:08 +1100 Subject: [PATCH 142/147] Removed reboot after success to prevent reboot looping --- .../MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 index 088d1b7ad..9d27cd391 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 @@ -145,8 +145,7 @@ function Set-TargetResource switch ($process.ExitCode) { 0 { - Write-Verbose -Message "Prerequisite installer completed successfully. Rebooting to finalise installations" - $global:DSCMachineStatus = 1 + Write-Verbose -Message "Prerequisite installer completed successfully." } 1 { throw "Another instance of the prerequisite installer is already running" From 15e48e2643525065c20ad2cb39ce8a8350cb76e7 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 5 Dec 2015 21:50:21 +1100 Subject: [PATCH 143/147] Fixed prereq list for 2016 and updated windows feature list --- .../MSFT_xSPInstallPrereqs.psm1 | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 index 9d27cd391..46fcce03f 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 @@ -37,10 +37,10 @@ function Get-TargetResource Write-Verbose -Message "Getting installed windows features" if ($majorVersion -eq 15) { - $WindowsFeatures = Get-WindowsFeature -Name Net-Framework-Features,Web-Server,Web-WebServer,Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Http-Tracing,Web-Security,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Digest-Auth,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server,AS-Web-Support,AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation,AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation,Server-Media-Foundation,Xps-Viewer + $WindowsFeatures = Get-WindowsFeature -Name Application-Server, AS-NET-Framework, AS-TCP-Port-Sharing, AS-Web-Support, AS-WAS-Support, AS-HTTP-Activation, AS-Named-Pipes, AS-TCP-Activation, Web-Server, Web-WebServer, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing, Web-Http-Errors, Web-Static-Content, Web-Http-Redirect, Web-Health, Web-Http-Logging, Web-Log-Libraries, Web-Request-Monitor, Web-Http-Tracing, Web-Performance, Web-Stat-Compression, Web-Dyn-Compression, Web-Security, Web-Filtering, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Cert-Auth, Web-IP-Security, Web-Url-Auth, Web-Windows-Auth, Web-App-Dev, Web-Net-Ext, Web-Net-Ext45, Web-Asp-Net, Web-Asp-Net45, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Mgmt-Tools, Web-Mgmt-Console, Web-Mgmt-Compat, Web-Metabase, Web-Lgcy-Scripting, Web-WMI, Web-Scripting-Tools, NET-Framework-Features, NET-Framework-Core, NET-Framework-45-ASPNET, NET-WCF-HTTP-Activation45, NET-WCF-Pipe-Activation45, NET-WCF-TCP-Activation45, Server-Media-Foundation, Windows-Identity-Foundation, PowerShell-V2, WAS, WAS-Process-Model, WAS-NET-Environment, WAS-Config-APIs, XPS-Viewer } if ($majorVersion -eq 16) { - $WindowsFeatures = Get-WindowsFeature -Name Application-Server,AS-NET-Framework,AS-Web-Support,Web-Server,Web-WebServer,Web-Common-Http,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Static-Content,Web-Http-Redirect,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Security,Web-Filtering,Web-Basic-Auth,Web-Client-Auth,Web-Digest-Auth,Web-Cert-Auth,Web-IP-Security,Web-Url-Auth,Web-Windows-Auth,Web-App-Dev,Web-Net-Ext,Web-Net-Ext45,Web-Asp-Net45,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Web-Lgcy-Mgmt-Console,Web-Lgcy-Scripting,Web-WMI,Web-Scripting-Tools,NET-Framework-Features,NET-Framework-Core,NET-HTTP-Activation,NET-Non-HTTP-Activ,NET-Framework-45-ASPNET,NET-WCF-HTTP-Activation45,Windows-Identity-Foundation,PowerShell-V2,WAS,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs + $WindowsFeatures = Get-WindowsFeature -Name Application-Server, AS-NET-Framework, AS-Web-Support, Web-Server, Web-WebServer, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing, Web-Http-Errors, Web-Static-Content, Web-Http-Redirect, Web-Health, Web-Http-Logging, Web-Log-Libraries, Web-Request-Monitor, Web-Performance, Web-Stat-Compression, Web-Dyn-Compression, Web-Security, Web-Filtering, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Cert-Auth, Web-IP-Security, Web-Url-Auth, Web-Windows-Auth, Web-App-Dev, Web-Net-Ext, Web-Net-Ext45, Web-Asp-Net45, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Mgmt-Tools, Web-Mgmt-Console, Web-Mgmt-Compat, Web-Metabase, Web-Lgcy-Mgmt-Console, Web-Lgcy-Scripting, Web-WMI, Web-Scripting-Tools, NET-Framework-Features, NET-Framework-Core, NET-HTTP-Activation, NET-Non-HTTP-Activ, NET-Framework-45-ASPNET, NET-WCF-HTTP-Activation45, Windows-Identity-Foundation, PowerShell-V2, WAS, WAS-Process-Model, WAS-NET-Environment, WAS-Config-APIs } foreach ($feature in $WindowsFeatures) { @@ -51,26 +51,28 @@ function Get-TargetResource $installedItems = Get-CimInstance -ClassName Win32_Product #Common prereqs - $returnValue.Add("Microsoft Identity Extensions", (@(Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ -Recurse | ? {$_.GetValue("DisplayName") -eq "Microsoft Identity Extensions" }).Count -gt 0)) + $returnValue.Add("AppFabric 1.1 for Windows Server", (($installedItems | ? {$_.Name -eq "AppFabric 1.1 for Windows Server"}) -ne $null)) $returnValue.Add("Microsoft CCR and DSS Runtime 2008 R3", (($installedItems | ? {$_.Name -eq "Microsoft CCR and DSS Runtime 2008 R3"}) -ne $null)) + $returnValue.Add("Microsoft Identity Extensions", (@(Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ -Recurse | ? {$_.GetValue("DisplayName") -eq "Microsoft Identity Extensions" }).Count -gt 0)) $returnValue.Add("Microsoft Sync Framework Runtime v1.0 SP1 (x64)", (($installedItems | ? {$_.Name -eq "Microsoft Sync Framework Runtime v1.0 SP1 (x64)"}) -ne $null)) - $returnValue.Add("AppFabric 1.1 for Windows Server", (($installedItems | ? {$_.Name -eq "AppFabric 1.1 for Windows Server"}) -ne $null)) $returnValue.Add("WCF Data Services 5.6.0 Runtime", (($installedItems | ? {$_.Name -eq "WCF Data Services 5.6.0 Runtime"}) -ne $null)) #SP2013 prereqs if ($majorVersion -eq 15) { - $returnValue.Add("WCF Data Services 5.0 (for OData v3) Primary Components", (($installedItems | ? {$_.Name -eq "WCF Data Services 5.0 (for OData v3) Primary Components"}) -ne $null)) - $returnValue.Add("Microsoft SQL Server 2008 R2 Native Client", (($installedItems | ? {$_.Name -eq "Microsoft SQL Server 2008 R2 Native Client"}) -ne $null)) $returnValue.Add("Active Directory Rights Management Services Client 2.0", (($installedItems | ? {$_.Name -eq "Active Directory Rights Management Services Client 2.0"}) -ne $null)) + $returnValue.Add("Microsoft SQL Server 2008 R2 Native Client", (($installedItems | ? {$_.Name -eq "Microsoft SQL Server 2008 R2 Native Client"}) -ne $null)) + $returnValue.Add("WCF Data Services 5.0 (for OData v3) Primary Components", (($installedItems | ? {$_.Name -eq "WCF Data Services 5.0 (for OData v3) Primary Components"}) -ne $null)) } #SP2016 prereqs if ($majorVersion -eq 16) { - $returnValue.Add("Microsoft ODBC Driver 11 for SQL Server", (($installedItems | ? {$_.Name -eq "Microsoft ODBC Driver 11 for SQL Server"}) -ne $null)) - $returnValue.Add("Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005"}) -ne $null)) - $returnValue.Add("Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005"}) -ne $null)) - $returnValue.Add("Microsoft SQL Server 2012 Native Client", (($installedItems | ? {$_.Name -ne $null -and $_.Name.Trim() -eq "Microsoft SQL Server 2012 Native Client"}) -ne $null)) $returnValue.Add("Active Directory Rights Management Services Client 2.1", (($installedItems | ? {$_.Name -eq "Active Directory Rights Management Services Client 2.1"}) -ne $null)) + $returnValue.Add("Microsoft SQL Server 2012 Native Client", (($installedItems | ? {$_.Name -ne $null -and $_.Name.Trim() -eq "Microsoft SQL Server 2012 Native Client"}) -ne $null)) + $returnValue.Add("Microsoft ODBC Driver 11 for SQL Server", (($installedItems | ? {$_.Name -eq "Microsoft ODBC Driver 11 for SQL Server"}) -ne $null)) + $returnValue.Add("Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030"}) -ne $null)) + $returnValue.Add("Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030"}) -ne $null)) + $returnValue.Add("Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026"}) -ne $null)) + $returnValue.Add("Microsoft Visual C++ 2015 x64 Additional Runtime - 14.0.23026", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2015 x64 Additional Runtime - 14.0.23026"}) -ne $null)) } $results = $PSBoundParameters From 9882937ae774e43846c252d46044f1b5eeea2993 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 5 Dec 2015 21:55:30 +1100 Subject: [PATCH 144/147] Updated tests for prereqs --- Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 index 2a63a77fc..4c1aeb030 100644 --- a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 @@ -117,8 +117,10 @@ Describe "xSPInstallPrereqs" { @{ Name = "AppFabric 1.1 for Windows Server"} @{ Name = "WCF Data Services 5.6.0 Runtime"} @{ Name = "Microsoft ODBC Driver 11 for SQL Server"} - @{ Name = "Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005"} - @{ Name = "Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005"} + @{ Name = "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030"} + @{ Name = "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030"} + @{ Name = "Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026"} + @{ Name = "Microsoft Visual C++ 2015 x64 Additional Runtime - 14.0.23026"} @{ Name = "Microsoft SQL Server 2012 Native Client"} @{ Name = "Active Directory Rights Management Services Client 2.1"} )} From 45c523b64b0976e3c746ba6041bdd43389893248 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 7 Dec 2015 08:02:19 +1100 Subject: [PATCH 145/147] Fixed detection of objects in test if value exists method --- .../xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 8de5b004d..c858f01d0 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -250,8 +250,7 @@ function Set-xSharePointObjectPropertyIfValueExists() { [parameter(Mandatory = $true,Position=1)] [object] $ParamsValue, [parameter(Mandatory = $true,Position=1)] [string] $ParamKey ) - - if ($ParamsValue.GetType().Name -eq "Hashtable") { + if ($ParamsValue.PSobject.Methods.name -contains "ContainsKey") { if ($ParamsValue.ContainsKey($ParamKey) -eq $true) { $ObjectToSet.$PropertyToSet = $ParamsValue.$ParamKey } From f8d918edbf4d5e48e8b379ab003614a6a8895e98 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 7 Dec 2015 11:56:23 +1100 Subject: [PATCH 146/147] Fixed bug in blocked file types test logic --- .../xSPWebApplication.BlockedFileTypes.psm1 | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 index 2096f1a67..3adb153eb 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -71,18 +71,13 @@ function Test-xSPWebApplicationBlockedFileTypes { } if($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) { - $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked -ExcludeDifferent - if ($itemsToRemove -ne $null) { return $false } + $itemsToAdd = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked | Where-Object { $_.SideIndicator -eq "=>"} + if ($itemsToAdd -ne $null) { return $false } } if($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true) { - $itemsToAdd = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureAllowed | Where-Object { $_.SideIndicator -eq "=>"} - if ($itemsToAdd -ne $null) { - $compareResult = Compare-Object -ReferenceObject $DesiredSettings.EnsureAllowed -DifferenceObject $itemsToAdd.InputObject - if ($compareResult -ne $null) { return $false } - } else { - return $false - } + $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureAllowed -ExcludeDifferent -IncludeEqual + if ($itemsToRemove -ne $null) { return $false } } return $true From 36641b569e260b56b8aeb20f250929b9ee97a772 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Mon, 7 Dec 2015 11:58:57 +1100 Subject: [PATCH 147/147] Updated build number --- Modules/xSharePoint/xSharePoint.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index ad0476b0d..ed8503211 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -12,7 +12,7 @@ # RootModule = '' # Version number of this module. -ModuleVersion = '0.7.0.0' +ModuleVersion = '0.8.0.0' # ID used to uniquely identify this module GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90'