Skip to content

Commit

Permalink
Merge pull request #2138 from fowl2/fixGetSiteSearchQueryResults
Browse files Browse the repository at this point in the history
GetSiteSearchQueryResults: fix 'Value cannot be null' exception
  • Loading branch information
KoenZomers authored Jul 13, 2022
2 parents 773cf8f + b09dd30 commit 707db2c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed
- Fixed issue where passing in `-Connection` to `Disconnect-PnPOnline` would throw an exception [#2093](https://github.com/pnp/powershell/pull/2093)
- Fixed `Get-PnPSiteSearchQueryResults` throwing `Value cannot be null` exception [#2138](https://github.com/pnp/powershell/pull/2138)

### Contributors

- James May [fowl2]
- Jimmy Hang [JimmyHang]
- Marcus Blennegård [mblennegard]
- Arleta Wanat [PowerShellScripts]
Expand Down
17 changes: 9 additions & 8 deletions src/Commands/Search/GetSiteSearchQueryResults.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Management.Automation;

using System.Collections.Generic;

namespace PnP.PowerShell.Commands.Search
Expand All @@ -22,16 +21,18 @@ public class GetSiteSearchQueryResults : PnPWebCmdlet

protected override void ExecuteCmdlet()
{
var queryCmdLet = new SubmitSearchQuery();

queryCmdLet.StartRow = StartRow;
queryCmdLet.MaxResults = MaxResults;
queryCmdLet.All = All;
var queryCmdLet = new SubmitSearchQuery
{
Connection = Connection,
StartRow = StartRow,
MaxResults = MaxResults,
All = All
};

var query = "contentclass:STS_Site";
if (!string.IsNullOrEmpty(Query))
{
query = query + " AND " + Query;
query = $"{query} AND {Query}";
}
queryCmdLet.Query = query;

Expand Down Expand Up @@ -61,4 +62,4 @@ protected override void ExecuteCmdlet()
WriteObject(dynamicList, true);
}
}
}
}
4 changes: 1 addition & 3 deletions src/Commands/Search/SubmitSearchQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Search.Query;

using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -303,5 +302,4 @@ private KeywordQuery CreateKeywordQuery(string clientFunction)
return keywordQuery;
}
}
}

}

0 comments on commit 707db2c

Please sign in to comment.