Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Added additional arguments to Set-PnPWeb #2633

Merged
merged 4 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [3.21.2005.0] (not yet released)

### Added
- Added following arguments to `Set-PnPWeb` allowing them to be set: `CommentsOnSitePagesDisabled`, `DisablePowerAutomate`, `MegaMenuEnabled`, `MembersCanShare`, `NavAudienceTargetingEnabled`, `QuickLaunchEnabled` and `NoCrawl` [PR #2633](https://github.com/pnp/PnP-PowerShell/pull/2633)

### Changed

### Contributors
- Koen Zomers [koenzomers]

## [3.20.2004.0]

Expand Down
5 changes: 2 additions & 3 deletions Commands/Web/GetWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq.Expressions;
using System.Management.Automation;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using SharePointPnP.PowerShell.Commands.Extensions;

namespace SharePointPnP.PowerShell.Commands
Expand All @@ -13,7 +12,8 @@ namespace SharePointPnP.PowerShell.Commands
[CmdletHelp("Returns the current web object",
Category = CmdletHelpCategory.Webs,
OutputType = typeof(Web),
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.web.aspx")]
OutputTypeLink = "https://docs.microsoft.com/previous-versions/office/sharepoint-server/ee537040(v=office.15)",
SupportedPlatform = CmdletSupportedPlatform.All)]
[CmdletExample(
Code = @"PS:> Get-PnPWeb",
Remarks = "This will return the current web",
Expand Down Expand Up @@ -47,6 +47,5 @@ protected override void ExecuteCmdlet()
}
}
}

}
}
84 changes: 76 additions & 8 deletions Commands/Web/SetWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,69 @@
namespace SharePointPnP.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Set, "PnPWeb")]
[CmdletHelp("Sets properties on a web", DetailedDescription = "Sets properties on a web",
Category = CmdletHelpCategory.Webs)]
[CmdletHelp("Sets properties on a web",
DetailedDescription = "Allows setting various properties on a web",
Category = CmdletHelpCategory.Webs,
SupportedPlatform = CmdletSupportedPlatform.All)]
[CmdletExample(
Code = @"PS:> Set-PnPWeb -CommentsOnSitePagesDisabled:$true",
Remarks = "Disables the page comments to be shown below each page in the current web by default",
SortOrder = 1)]
[CmdletExample(
Code = @"PS:> Set-PnPWeb -QuickLaunchEnabled:$false",
Remarks = "Hides the quick launch from being shown in the current web",
SortOrder = 2)]
[CmdletExample(
Code = @"PS:> Set-PnPWeb -NoCrawl:$true",
Remarks = "Prevents the current web from being returned in search results",
SortOrder = 3)]
public class SetWeb : PnPWebCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "Sets the logo of the web to the current url. If you want to set the logo to a modern team site, use Set-PnPSite -LogoFilePath.")]
public string SiteLogoUrl;

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "Sets the AlternateCssUrl of the web. Only works for classic pages.")]
public string AlternateCssUrl;

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "Sets the title of the web")]
public string Title;

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "Sets the description of the web")]
public string Description;

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "Sets the MasterUrl of the web. Only works for classic pages.")]
public string MasterUrl;

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "Sets the CustomMasterUrl of the web. Only works for classic pages.")]
public string CustomMasterUrl;

[Parameter(Mandatory = false, HelpMessage = "Defines if the quick launch menu on the left side of modern Team Sites should be shown ($true) or hidden ($false)")]
public SwitchParameter QuickLaunchEnabled;

[Parameter(Mandatory = false, HelpMessage = "Indicates if members of this site can share the site and individual sites with others ($true) or only owners can do this ($false)")]
public SwitchParameter MembersCanShare;

[Parameter(Mandatory = false, HelpMessage = "Indicates if this site should not be returned in search results ($true) or if it should be ($false)")]
public SwitchParameter NoCrawl;

#if !ONPREMISES
[Parameter(Mandatory = false)]
public HeaderLayoutType HeaderLayout = HeaderLayoutType.Standard;

[Parameter(Mandatory = false)]
public SPVariantThemeType HeaderEmphasis = SPVariantThemeType.None;

[Parameter(Mandatory = false, HelpMessage = "Defines if the navigation menu on a modern site should be enabled for modern audience targeting ($true) or not ($false)")]
public SwitchParameter NavAudienceTargetingEnabled;

[Parameter(Mandatory = false, HelpMessage = "Defines if the navigation menu should be shown as the mega menu ($true) or the smaller sized menu ($false)")]
public SwitchParameter MegaMenuEnabled;

[Parameter(Mandatory = false, HelpMessage = "Defines if Power Automate should be available on lists and document libraries ($false) or if the option should be hidden ($true)")]
public SwitchParameter DisablePowerAutomate;

[Parameter(Mandatory = false, HelpMessage = "Defines if comments on modern site pages should be enabled by default ($false) or they should be hidden ($true)")]
public SwitchParameter CommentsOnSitePagesDisabled;
#endif

protected override void ExecuteCmdlet()
Expand Down Expand Up @@ -73,6 +107,21 @@ protected override void ExecuteCmdlet()
SelectedWeb.CustomMasterUrl = CustomMasterUrl;
dirty = true;
break;

case nameof(QuickLaunchEnabled):
SelectedWeb.QuickLaunchEnabled = QuickLaunchEnabled.ToBool();
dirty = true;
break;

case nameof(MembersCanShare):
SelectedWeb.MembersCanShare = MembersCanShare.ToBool();
dirty = true;
break;

case nameof(NoCrawl):
SelectedWeb.NoCrawl = NoCrawl.ToBool();
dirty = true;
break;
#if !ONPREMISES
case nameof(HeaderLayout):
SelectedWeb.HeaderLayout = HeaderLayout;
Expand All @@ -83,6 +132,26 @@ protected override void ExecuteCmdlet()
SelectedWeb.HeaderEmphasis = HeaderEmphasis;
dirty = true;
break;

case nameof(NavAudienceTargetingEnabled):
SelectedWeb.NavAudienceTargetingEnabled = NavAudienceTargetingEnabled.ToBool();
dirty = true;
break;

case nameof(MegaMenuEnabled):
SelectedWeb.MegaMenuEnabled = MegaMenuEnabled.ToBool();
dirty = true;
break;

case nameof(DisablePowerAutomate):
SelectedWeb.DisableFlows = DisablePowerAutomate.ToBool();
dirty = true;
break;

case nameof(CommentsOnSitePagesDisabled):
SelectedWeb.CommentsOnSitePagesDisabled = CommentsOnSitePagesDisabled.ToBool();
dirty = true;
break;
#endif
}
}
Expand All @@ -94,5 +163,4 @@ protected override void ExecuteCmdlet()
}
}
}

}