diff --git a/CHANGELOG.md b/CHANGELOG.md index a524f2a6c..7840b84d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `-IsVivaConnectionsDefaultStartForCompanyPortalSiteEnabled` parameter to `Get-PnPHomeSite` which returns information on whether Viva Connections landing experience is set to the SharePoint home site. [#2779](https://github.com/pnp/powershell/pull/2779) - Added `-VivaConnectionsDefaultStart` parameter to `Set-PnPHomeSite` which sets the home site to the provided site collection url and keeps the Viva Connections landing experience to the SharePoint home site. [#2779](https://github.com/pnp/powershell/pull/2779) - Added `-LargeList` parameter to `Remove-PnPList` cmdlet which improves the list recycling experience for Lists containing huge number of items. [#2778](https://github.com/pnp/powershell/pull/2778) +- Added `-CheckinType` parameter to `Add-PnPFile` cmdlet which provides the option to specify the checkin type for a file. The default value is set to `MinorCheckIn`. [#2806](https://github.com/pnp/powershell/pull/2806) - Added `-ApplicationId` as alias for `-ClientId` in `Connect-PnPOnline` and `Request-PnPAccessToken` cmdlets. ### Changed @@ -53,6 +54,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Properties of `Get-PnPAzureADServicePrincipal` are now all typed instead of some of them returning unparsed JSON fragments. [#2717](https://github.com/pnp/powershell/pull/2717) - Marked `Get-PnPSubscribeSharePointNewsDigest` and `Set-PnPSubscribeSharePointNewsDigest` as obsolete as the implementation behind these features has been changed in SharePoint Online causing them no longer to work. At present, there's no alternative for this that we can call into thus we will have to remove these in a future version. [#2720](https://github.com/pnp/powershell/pull/2720) - Changed `Add-PnPTeamsChannel` to no longer require an `-OwnerUPN` to be provided when specifying `-ChannelType Standard` [#2786](https://github.com/pnp/powershell/pull/2786) +- Changed `Add-PnPFile` by default to upload a file as a draft with a minor version now instead of publishing it as a major version. `-CheckinType MajorCheckIn` can be used to still upload the file as a major published version [#2806](https://github.com/pnp/powershell/pull/2806) ### Removed diff --git a/documentation/Add-PnPFile.md b/documentation/Add-PnPFile.md index 19d9b20ee..c6af74948 100644 --- a/documentation/Add-PnPFile.md +++ b/documentation/Add-PnPFile.md @@ -16,21 +16,21 @@ Uploads a file to Web ### Upload file ```powershell -Add-PnPFile -Path -Folder [-NewFileName ] [-Checkout] [-CheckInComment ] +Add-PnPFile -Path -Folder [-NewFileName ] [-Checkout] [-CheckInComment ] [-CheckinType ] [-Approve] [-ApproveComment ] [-Publish] [-PublishComment ] [-UseWebDav] [-Values ] [-ContentType ] [-Connection ] [] ``` ### Upload file from stream ```powershell -Add-PnPFile -Folder -FileName -Stream [-Checkout] [-CheckInComment ] +Add-PnPFile -Folder -FileName -Stream [-Checkout] [-CheckInComment ] [-CheckinType ] [-Approve] [-ApproveComment ] [-Publish] [-PublishComment ] [-UseWebDav] [-Values ] [-ContentType ] [-Connection ] [] ``` ### Create or update file from text ```powershell -Add-PnPFile -Folder -FileName -Content [-Checkout] [-CheckInComment ] +Add-PnPFile -Folder -FileName -Content [-Checkout] [-CheckInComment ] [-CheckinType ] [-Approve] [-ApproveComment ] [-Publish] [-PublishComment ] [-UseWebDav] [-Values ] [-ContentType ] [-Connection ] [] ``` @@ -140,6 +140,20 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -CheckinType +Specifies the type of check-in for a file. + +```yaml +Type: Enum (Microsoft.SharePoint.Client.CheckinType) +Parameter Sets: (All) + +Required: False +Position: Named +Default value: MinorCheckIn +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Checkout If versioning is enabled, this will check out the file first if it exists, upload the file, then check it in again diff --git a/src/Commands/Files/AddFile.cs b/src/Commands/Files/AddFile.cs index 54c393ae4..061aa662c 100644 --- a/src/Commands/Files/AddFile.cs +++ b/src/Commands/Files/AddFile.cs @@ -45,6 +45,9 @@ public class AddFile : PnPWebCmdlet [Parameter(Mandatory = false)] public string CheckInComment = string.Empty; + [Parameter(Mandatory = false)] + public CheckinType CheckinType = CheckinType.MinorCheckIn; + [Parameter(Mandatory = false)] public SwitchParameter Approve; @@ -117,7 +120,7 @@ protected override void ExecuteCmdlet() { // Swallow exception, file does not exist } } - + Microsoft.SharePoint.Client.File file; switch (ParameterSetName) { @@ -161,9 +164,10 @@ protected override void ExecuteCmdlet() { item.UpdateOverwriteVersion(); } + if (Checkout) { - CurrentWeb.CheckInFile(fileUrl, CheckinType.MajorCheckIn, CheckInComment); + CurrentWeb.CheckInFile(fileUrl, CheckinType, CheckInComment); } if (Publish) @@ -197,7 +201,7 @@ protected override void ExecuteCmdlet() private Folder EnsureFolder() { // First try to get the folder if it exists already. This avoids an Access Denied exception if the current user doesn't have Full Control access at Web level - CurrentWeb.EnsureProperty(w => w.ServerRelativeUrl); + CurrentWeb.EnsureProperty(w => w.ServerRelativeUrl); Folder folder = null; try