Skip to content

Commit 449069c

Browse files
gautamdshethGautam Sheth
andauthored
Refactor navigation node and sharing links commands to remove obsolete parameters and improve code clarity (#4561)
Co-authored-by: Gautam Sheth <[email protected]>
1 parent 3780f38 commit 449069c

File tree

5 files changed

+12
-63
lines changed

5 files changed

+12
-63
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
8585
- Removed `Get-PnPPowerPlatformConnector` alias. You need to use `Get-PnPPowerPlatformCustomConnector`. [#4387](https://github.com/pnp/powershell/pull/4387)
8686
- Removed `-IsFavoriteByDefault` parameter from `Add-PnPTeamsChannel` cmdlet. It was obsolete and not supported by Graph API. [#4387](https://github.com/pnp/powershell/pull/4387)
8787
- Removed `Get-PnPAppAuthAccessToken` , `Remove-PnPGraphAccessToken` and `Request-PnPAccessToken` cmdlets. Use `Get-PnPAccessToken` instead. [#4398](https://github.com/pnp/powershell/pull/4398)
88-
- Removed support for sending mail via SMTP. It's usage is not recommended by .NET due to its lack of support for modern protocols.
88+
- Removed support for sending mail via SMTP in `Send-PnPMail`. It's usage is not recommended by .NET due to its lack of support for modern protocols.
89+
- Removed `-Title` and `-Header` parameters from `Remove-PnPNavigationNode`. They were marked obsolete.
90+
- Removed `-FileUrl` parameter from `Get-PnPSharingLink`. It was marked obsolete.
8991

9092
### Contributors
9193

MIGRATE-2.0-to-3.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Recommend referring to these 2 links:
5757
| Send-PnPMail | It now throws a warning about the [retirement of SharePoint SendEmail API](https://devblogs.microsoft.com/microsoft365dev/retirement-of-the-sharepoint-sendemail-api/), if you are sending mails via SharePoint. To ignore the warning, use `-ErrorAction SilentlyContinue` along side the cmdlet. Recommendation is to use `Send-PnPMail` with [Microsoft Graph](https://pnp.github.io/powershell/cmdlets/Send-PnPMail.html#send-through-microsoft-graph) |
5858
| Send-PnPMail | The support for sending mails via SMTP servers is now removed. It is the recommendation of .NET as SMTP doesn't support modern protocols. So, the parameters `-EnableSSL` , `-UserName`, `-Password`, `-Server ` and `-ServerPort` are now removed. Use `Send-PnPMail` with [Microsoft Graph](https://pnp.github.io/powershell/cmdlets/Send-PnPMail.html#send-through-microsoft-graph) |
5959
| Invoke-PnPTransformation | It has been removed. Was never supported. |
60+
| Get-PnPSharingLink | The parameter `-FileUrl` has been removed. It was marked obsolete. Use `-Identity` instead. |
61+
| Remove-PnPNavigationNode | The parameters `-Title` and `-Header` have been removed. They were marked obsolete. Use `-Identity` instead. |
6062

6163

6264
## Other notable changes

src/Commands/Navigation/RemoveNavigationNode.cs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
using System;
2-
using System.Management.Automation;
3-
using Microsoft.SharePoint.Client;
1+
using Microsoft.SharePoint.Client;
42
using PnP.Framework.Enums;
5-
63
using PnP.PowerShell.Commands.Base.PipeBinds;
4+
using System.Management.Automation;
75
using Resources = PnP.PowerShell.Commands.Properties.Resources;
86

97
namespace PnP.PowerShell.Commands.Branding
@@ -19,18 +17,9 @@ public class RemoveNavigationNode : PnPWebCmdlet
1917
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = ParameterSet_BYID)]
2018
public NavigationNodePipeBind Identity;
2119

22-
[Obsolete("Use -Identity with an Id instead.")]
2320
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ParameterSet_BYNAME)]
2421
public NavigationType Location;
2522

26-
[Obsolete("Use -Identity with an Id instead.")]
27-
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_BYNAME)]
28-
public string Title;
29-
30-
[Obsolete("Use -Identity with an Id instead.")]
31-
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_BYNAME)]
32-
public string Header;
33-
3423
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_REMOVEALLNODES)]
3524
public SwitchParameter All;
3625

@@ -41,12 +30,10 @@ protected override void ExecuteCmdlet()
4130
{
4231
if (ParameterSetName == ParameterSet_REMOVEALLNODES)
4332
{
44-
#pragma warning disable CS0618 // Type or member is obsolete
4533
if (Force || ShouldContinue(string.Format(Resources.RemoveNavigationNodeInLocation, Location), Resources.Confirm))
4634
{
4735
CurrentWeb.DeleteAllNavigationNodes(Location);
4836
}
49-
#pragma warning restore CS0618 // Type or member is obsolete
5037
}
5138
else
5239
{
@@ -58,12 +45,6 @@ protected override void ExecuteCmdlet()
5845
node.DeleteObject();
5946
ClientContext.ExecuteQueryRetry();
6047
}
61-
else
62-
{
63-
#pragma warning disable CS0618 // Type or member is obsolete
64-
CurrentWeb.DeleteNavigationNode(Title, Header, Location);
65-
#pragma warning restore CS0618 // Type or member is obsolete
66-
}
6748
}
6849
}
6950
}

src/Commands/Security/GetFileSharingLink.cs

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,20 @@
11
using PnP.Core.Model.Security;
22
using PnP.Core.Model.SharePoint;
3-
using PnP.Framework.Utilities;
4-
using System;
5-
using System.Management.Automation;
63
using PnP.PowerShell.Commands.Base.PipeBinds;
4+
using System.Management.Automation;
75

86
namespace PnP.PowerShell.Commands.Security
97
{
108
[Cmdlet(VerbsCommon.Get, "PnPFileSharingLink")]
119
[OutputType(typeof(IGraphPermissionCollection))]
1210
public class GetFileSharingLink : PnPWebCmdlet
1311
{
14-
private const string ParameterSet_BYFILEURL = "By file url";
15-
private const string ParameterSet_BYIDENTITY = "By identity";
16-
17-
[Obsolete("Use Identity parameter instead")]
18-
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_BYFILEURL)]
19-
public string FileUrl;
20-
21-
[Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet_BYIDENTITY)]
12+
[Parameter(Mandatory = true, ValueFromPipeline = true)]
2213
public FilePipeBind Identity;
2314

2415
protected override void ExecuteCmdlet()
2516
{
26-
IFile file;
27-
28-
if (ParameterSpecified(nameof(Identity)))
29-
{
30-
file = Identity.GetCoreFile(Connection.PnPContext, this);
31-
}
32-
else
33-
{
34-
var serverRelativeUrl = string.Empty;
35-
var ctx = Connection.PnPContext;
36-
37-
ctx.Web.EnsureProperties(w => w.ServerRelativeUrl);
38-
39-
#pragma warning disable CS0618
40-
if (!FileUrl.ToLower().StartsWith(ctx.Web.ServerRelativeUrl.ToLower()))
41-
{
42-
serverRelativeUrl = UrlUtility.Combine(ctx.Web.ServerRelativeUrl, FileUrl);
43-
}
44-
else
45-
{
46-
serverRelativeUrl = FileUrl;
47-
}
48-
#pragma warning restore CS0618
49-
file = ctx.Web.GetFileByServerRelativeUrl(serverRelativeUrl);
50-
}
17+
IFile file = Identity.GetCoreFile(Connection.PnPContext, this);
5118

5219
WriteVerbose("Retrieving file sharing details from Microsoft Graph");
5320
var sharingLinks = file?.GetShareLinks();

src/Commands/Teams/AddTeamsChannel.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using PnP.PowerShell.Commands.Enums;
55
using PnP.PowerShell.Commands.Model.Graph;
66
using PnP.PowerShell.Commands.Utilities;
7-
using System;
87
using System.Management.Automation;
98

109
namespace PnP.PowerShell.Commands.Teams
@@ -30,7 +29,7 @@ public class AddTeamsChannel : PnPGraphCmdlet
3029
[Parameter(Mandatory = false, ParameterSetName = ParameterSET_STANDARD)]
3130
[Parameter(Mandatory = false, ParameterSetName = ParameterSET_PRIVATE)]
3231
[Parameter(Mandatory = false, ParameterSetName = ParameterSET_SPECIFIC)]
33-
public string Description;
32+
public string Description;
3433

3534
[Parameter(Mandatory = false, ParameterSetName = ParameterSET_STANDARD)]
3635
[Parameter(Mandatory = true, ParameterSetName = ParameterSET_SPECIFIC)]
@@ -48,16 +47,14 @@ protected override void ExecuteCmdlet()
4847
throw new PSArgumentException("Group not found");
4948
}
5049

51-
if(ChannelType != TeamsChannelType.Standard && !ParameterSpecified(nameof(OwnerUPN)))
50+
if (ChannelType != TeamsChannelType.Standard && !ParameterSpecified(nameof(OwnerUPN)))
5251
{
5352
throw new PSArgumentException("OwnerUPN is required when using the non standard channel type", nameof(OwnerUPN));
5453
}
5554

5655
try
5756
{
58-
#pragma warning disable CS0618 // Type or member is obsolete
5957
var channel = TeamsUtility.AddChannel(this, AccessToken, Connection, groupId, DisplayName, Description, ChannelType, OwnerUPN, false);
60-
#pragma warning restore CS0618 // Type or member is obsolete
6158
WriteObject(channel);
6259
}
6360
catch (GraphException ex)

0 commit comments

Comments
 (0)