private void SetSiteProperties(Func <TenantOperationMessage, bool> timeoutFunction) { var props = GetSiteProperties(Identity.Url); var updateRequired = false; if (ParameterSpecified(nameof(Title))) { props.Title = Title; updateRequired = true; } if (ParameterSpecified(nameof(DenyAddAndCustomizePages))) { props.DenyAddAndCustomizePages = DenyAddAndCustomizePages ? DenyAddAndCustomizePagesStatus.Enabled : DenyAddAndCustomizePagesStatus.Disabled; updateRequired = true; } if (ParameterSpecified(nameof(LocaleId))) { props.Lcid = LocaleId; updateRequired = true; } if (ParameterSpecified(nameof(AllowSelfServiceUpgrade))) { props.AllowSelfServiceUpgrade = AllowSelfServiceUpgrade; updateRequired = true; } if (ParameterSpecified(nameof(SharingAllowedDomainList))) { props.SharingAllowedDomainList = SharingAllowedDomainList; updateRequired = true; } if (ParameterSpecified(nameof(SharingBlockedDomainList))) { props.SharingBlockedDomainList = SharingBlockedDomainList; updateRequired = true; } if (ParameterSpecified(nameof(SharingDomainRestrictionMode))) { props.SharingDomainRestrictionMode = SharingDomainRestrictionMode; updateRequired = true; } if (ParameterSpecified(nameof(StorageQuota))) { props.StorageMaximumLevel = StorageQuota; updateRequired = true; } if (ParameterSpecified(nameof(StorageQuotaWarningLevel))) { props.StorageWarningLevel = StorageQuotaWarningLevel; updateRequired = true; } if (ParameterSpecified(nameof(StorageQuotaReset))) { props.StorageMaximumLevel = 0; updateRequired = true; } if (ParameterSpecified(nameof(ResourceQuota))) { props.UserCodeMaximumLevel = ResourceQuota; updateRequired = true; } if (ParameterSpecified(nameof(ResourceQuotaWarningLevel))) { props.UserCodeWarningLevel = ResourceQuotaWarningLevel; updateRequired = true; } if (ParameterSpecified(nameof(SharingCapability))) { props.SharingCapability = SharingCapability; updateRequired = true; } if (ParameterSpecified(nameof(DefaultLinkPermission))) { props.DefaultLinkPermission = DefaultLinkPermission; updateRequired = true; } if (ParameterSpecified(nameof(ShowPeoplePickerSuggestionsForGuestUsers))) { Tenant.EnsureProperty(t => t.ShowPeoplePickerSuggestionsForGuestUsers); if (!Tenant.ShowPeoplePickerSuggestionsForGuestUsers) { WriteWarning("ShowPeoplePickerSuggestionsForGuests users has been disabled for this tenant. See Set-PnPTenant"); } props.ShowPeoplePickerSuggestionsForGuestUsers = ShowPeoplePickerSuggestionsForGuestUsers; updateRequired = true; } if (ParameterSpecified(nameof(DefaultSharingLinkType))) { props.DefaultSharingLinkType = DefaultSharingLinkType; updateRequired = true; } if (ParameterSpecified(nameof(DefaultLinkToExistingAccess))) { props.DefaultLinkToExistingAccess = DefaultLinkToExistingAccess.Value; updateRequired = true; } if (ParameterSpecified(nameof(DefaultLinkToExistingAccessReset))) { props.DefaultLinkToExistingAccessReset = true; updateRequired = true; } #pragma warning disable CS0618 if (ParameterSpecified(nameof(BlockDownloadOfNonViewableFiles)) || ParameterSpecified(nameof(AllowDownloadingNonWebViewableFiles))) { var value = ParameterSpecified(nameof(BlockDownloadLinksFileTypes)) ? !BlockDownloadOfNonViewableFiles : AllowDownloadingNonWebViewableFiles; if (ConditionalAccessPolicy == SPOConditionalAccessPolicyType.AllowLimitedAccess) { props.AllowDownloadingNonWebViewableFiles = value; updateRequired = true; if (!value) { WriteWarning("Users will not be able to download files that cannot be viewed on the web. To allow download of files that cannot be viewed on the web run the cmdlet again and set AllowDownloadingNonWebViewableFiles to true."); } } else { if (ShouldContinue("To set AllowDownloadingNonWebViewableFiles parameter you need to set the -ConditionalAccessPolicy parameter to AllowLimitedAccess. We can set the Conditional Access Policy of this site to AllowLimitedAccess. Would you like to continue?", string.Empty)) { ConditionalAccessPolicy = SPOConditionalAccessPolicyType.AllowLimitedAccess; props.ConditionalAccessPolicy = SPOConditionalAccessPolicyType.AllowLimitedAccess; props.AllowDownloadingNonWebViewableFiles = value; if (!value) { WriteWarning("Users will not be able to download files that cannot be viewed on the web. To allow download of files that cannot be viewed on the web run the cmdlet again and set AllowDownloadingNonWebViewableFiles to true."); } } } } #pragma warning restore CS0618 if (ParameterSpecified(nameof(CommentsOnSitePagesDisabled))) { props.CommentsOnSitePagesDisabled = CommentsOnSitePagesDisabled; updateRequired = true; } if (ParameterSpecified(nameof(DisableAppViews))) { props.DisableAppViews = DisableAppViews; updateRequired = true; } if (ParameterSpecified(nameof(DisableCompanyWideSharingLinks))) { props.DisableCompanyWideSharingLinks = DisableCompanyWideSharingLinks; updateRequired = true; } if (ParameterSpecified(nameof(DisableFlows))) { props.DisableFlows = DisableFlows; updateRequired = true; } if (ParameterSpecified(nameof(EnablePWA))) { props.PWAEnabled = EnablePWA ? PWAEnabledStatus.Enabled : PWAEnabledStatus.Disabled; updateRequired = true; } if (ParameterSpecified(nameof(OverrideTenantAnonymousLinkExpirationPolicy))) { props.OverrideTenantAnonymousLinkExpirationPolicy = OverrideTenantAnonymousLinkExpirationPolicy.ToBool(); updateRequired = true; } if (ParameterSpecified(nameof(AnonymousLinkExpirationInDays)) && AnonymousLinkExpirationInDays.HasValue) { props.AnonymousLinkExpirationInDays = AnonymousLinkExpirationInDays.Value; updateRequired = true; } if (ParameterSpecified(nameof(DisableSharingForNonOwners))) { var office365Tenant = new Office365Tenant(ClientContext); ClientContext.Load(office365Tenant); ClientContext.ExecuteQueryRetry(); office365Tenant.DisableSharingForNonOwnersOfSite(Identity.Url); } if (ParameterSpecified(nameof(ConditionalAccessPolicy)) && ConditionalAccessPolicy == SPOConditionalAccessPolicyType.ProtectionLevel) { if (IsRootSite(Identity.Url)) { throw new PSInvalidOperationException("You cannot set the conditional access policy 'ProtectionLevel' on the root site."); } if (string.IsNullOrEmpty(ProtectionLevelName)) { props.AuthContextStrength = null; } else { props.AuthContextStrength = ProtectionLevelName; } updateRequired = true; } else { if (ParameterSpecified(nameof(ProtectionLevelName))) { throw new PSArgumentException("ConditionalAccessPolicy has to be set too when using this parameter."); } if (ParameterSpecified(nameof(ConditionalAccessPolicy))) { props.AuthContextStrength = null; updateRequired = true; } } if (ClientContext.ServerVersion >= new Version(16, 0, 8715, 1200)) // ServerSupportsIpLabelId2 { if (ParameterSpecified(nameof(SensitivityLabel))) { props.SensitivityLabel2 = SensitivityLabel; updateRequired = true; } if (ParameterSpecified(nameof(RemoveLabel))) { props.SensitivityLabel2 = null; updateRequired = true; } } else { WriteWarning("Server does not support setting sensitity label"); } if (ParameterSpecified(nameof(LimitedAccessFileType))) { if (ConditionalAccessPolicy == SPOConditionalAccessPolicyType.AllowLimitedAccess) { props.LimitedAccessFileType = LimitedAccessFileType; updateRequired = true; } else if (ShouldContinue("To set LimitedAccessFileType you need to set the -ConditionalAccessPolicy parameter to AllowLimitedAccess. We can set the Conditional Access Policy of this site to AllowLimitedAccess. Would you like to continue?", string.Empty)) { ConditionalAccessPolicy = SPOConditionalAccessPolicyType.AllowLimitedAccess; props.ConditionalAccessPolicy = SPOConditionalAccessPolicyType.AllowLimitedAccess; props.LimitedAccessFileType = LimitedAccessFileType; updateRequired = true; } } if (ParameterSpecified(nameof(AllowEditing))) { if (ConditionalAccessPolicy == SPOConditionalAccessPolicyType.AllowLimitedAccess) { props.AllowEditing = AllowEditing; } else if (ShouldContinue("To set AllowEditing you need to set the -ConditionalAccessPolicy parameter to AllowLimitedAccess. We can set the Conditional Access Policy of this site to AllowLimitedAccess. Would you like to continue?", string.Empty)) { ConditionalAccessPolicy = SPOConditionalAccessPolicyType.AllowLimitedAccess; props.ConditionalAccessPolicy = SPOConditionalAccessPolicyType.AllowLimitedAccess; props.AllowEditing = AllowEditing; } } if (ParameterSpecified(nameof(RestrictedToGeo))) { props.RestrictedToRegion = RestrictedToGeo; updateRequired = true; } if (ParameterSpecified(nameof(ExternalUserExpirationInDays))) { props.ExternalUserExpirationInDays = ExternalUserExpirationInDays; updateRequired = true; } if (ParameterSpecified(nameof(OverrideTenantExternalUserExpirationPolicy))) { props.OverrideTenantExternalUserExpirationPolicy = OverrideTenantExternalUserExpirationPolicy; updateRequired = true; } if (ParameterSpecified(nameof(AddInformationSegment)) && AddInformationSegment.Length > 0) { props.IBSegmentsToAdd = AddInformationSegment; updateRequired = true; } if (ParameterSpecified(nameof(RemoveInformationSegment)) && RemoveInformationSegment.Length > 0) { props.IBSegmentsToRemove = RemoveInformationSegment; updateRequired = true; } if (ParameterSpecified(nameof(BlockDownloadLinksFileType))) { props.BlockDownloadLinksFileType = BlockDownloadLinksFileType; updateRequired = true; } if (ParameterSpecified(nameof(OverrideBlockUserInfoVisibility))) { props.OverrideBlockUserInfoVisibility = OverrideBlockUserInfoVisibility; updateRequired = true; } if (ParameterSpecified(nameof(HubSiteId))) { var hubsiteProperties = Tenant.GetHubSitePropertiesById(HubSiteId); ClientContext.Load(hubsiteProperties); ClientContext.ExecuteQueryRetry(); if (hubsiteProperties == null || string.IsNullOrEmpty(hubsiteProperties.SiteUrl)) { throw new PSArgumentException("Hubsite not found with the ID specified"); } if (hubsiteProperties.ID != Guid.Empty) { Tenant.ConnectSiteToHubSiteById(Identity.Url, hubsiteProperties.ID); } else { Tenant.ConnectSiteToHubSite(Identity.Url, hubsiteProperties.SiteUrl); } ClientContext.ExecuteQueryRetry(); } if (updateRequired) { var op = props.Update(); ClientContext.Load(op, i => i.IsComplete, i => i.PollingInterval); ClientContext.ExecuteQueryRetry(); if (Wait) { WaitForIsComplete(ClientContext, op, timeoutFunction, TenantOperationMessage.SettingSiteProperties); } } if (Owners != null && Owners.Count > 0) { var admins = new List <UserEntity>(); foreach (var owner in Owners) { var userEntity = new UserEntity { LoginName = owner }; admins.Add(userEntity); } Tenant.AddAdministrators(admins, new Uri(Identity.Url)); } }