Skip to content

Commit

Permalink
Minor improvements (#4292)
Browse files Browse the repository at this point in the history
Co-authored-by: Gautam Sheth <[email protected]>
  • Loading branch information
gautamdsheth and Gautam Sheth authored Sep 15, 2024
1 parent efa1090 commit 9c9dd73
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ private PnPConnection ConnectManagedIdentity()
private PnPConnection ConnectWebLogin()
{
WriteVerbose("Connecting using WebLogin");
WriteWarning("Consider using -Interactive instead, which provides better functionality. See the documentation at https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html#interactive-for-multi-factor-authentication");
WriteWarning("Consider using -Interactive or -OSLogin instead, which provides better functionality. This will be removed in a future release. See the documentation at https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html#interactive-for-multi-factor-authentication");

if (Utilities.OperatingSystem.IsWindows())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Base/PipeBinds/ListPipeBind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ internal PnPCore.IList GetList(PnP.Core.Services.PnPContext context, params Syst
if (returnList == null)
{
var url = _name;
context.Web.EnsurePropertiesAsync(w => w.ServerRelativeUrl).GetAwaiter().GetResult();
context.Web.EnsureProperties(w => w.ServerRelativeUrl);
if (!_name.ToLower().StartsWith(context.Web.ServerRelativeUrl.ToLower()))
{
url = $"{context.Web.ServerRelativeUrl}/{url.TrimStart('/')}";
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/Base/PnPConnectedCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ protected override void ProcessRecord()
case Model.Graph.GraphException gex:
errorMessage = $"{gex.HttpResponse.ReasonPhrase} ({(int)gex.HttpResponse.StatusCode}): {(gex.Error != null ? gex.Error.Message : gex.HttpResponse.Content.ReadAsStringAsync().Result)}";
break;

case Core.CsomServiceException cex:
errorMessage = (cex.Error as Core.CsomError).Message;
break;
case Core.SharePointRestServiceException rex:
errorMessage = (rex.Error as Core.SharePointRestError).Message;
break;

case System.Reflection.TargetInvocationException tex:
Exception innermostException = tex;
while (innermostException.InnerException != null) innermostException = innermostException.InnerException;
Expand All @@ -89,7 +90,6 @@ protected override void ProcessRecord()
case Core.MicrosoftGraphServiceException pgex:
errorMessage = (pgex.Error as Core.MicrosoftGraphError).Message;
break;

default:
errorMessage = ex.Message;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Files/GetFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected override void ExecuteCmdlet()
case URLTOPATH:

// Get a reference to the file to download
IFile fileToDownload = PnPContext.Web.GetFileByServerRelativeUrlAsync(serverRelativeUrl).GetAwaiter().GetResult();
IFile fileToDownload = PnPContext.Web.GetFileByServerRelativeUrl(serverRelativeUrl);
string fileToDownloadName = !string.IsNullOrEmpty(Filename) ? Filename : fileToDownload.Name;
string fileOut = System.IO.Path.Combine(Path, fileToDownloadName);

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Files/GetFolderStorageMetric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected override void ExecuteCmdlet()
}
}

IFolder folderWithStorageMetrics = PnPContext.Web.GetFolderByServerRelativeUrlAsync(targetFolder.ServerRelativeUrl, f => f.StorageMetrics).GetAwaiter().GetResult();
IFolder folderWithStorageMetrics = PnPContext.Web.GetFolderByServerRelativeUrl(targetFolder.ServerRelativeUrl, f => f.StorageMetrics);
var storageMetrics = folderWithStorageMetrics.StorageMetrics;

WriteObject(new Model.SharePoint.FolderStorageMetric
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Model/PnPBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public List<BatchResult> Execute(bool throwOnError)
{
if (Batch != null)
{
var results = Context.ExecuteAsync(Batch, throwOnError).GetAwaiter().GetResult();
var results = Context.Execute(Batch, throwOnError);

ClearCache();
if (!RetainAfterExecute)
Expand Down
2 changes: 0 additions & 2 deletions src/Commands/Utilities/CredentialManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,6 @@ private static PSCredential GetVaultCredential(string vaultName, string name)

private static string GetVaultAppId(string vaultName, string name)
{
PSCredential creds = null;

InitialSessionState iss = InitialSessionState.CreateDefault();

using (Runspace myRunSpace = RunspaceFactory.CreateRunspace(iss))
Expand Down

0 comments on commit 9c9dd73

Please sign in to comment.