Skip to content
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
4 changes: 4 additions & 0 deletions src/readme.graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ directive:
// Call OnBeforeWriteObject to deserialize '@odata.count' from the response object.
let writeObjectRegex = /^(\s*)(WriteObject\(result\.Value,true\);)$/gm
$ = $.replace(writeObjectRegex,'\n$1OnBeforeWriteObject(this.InvocationInformation.BoundParameters, result?.AdditionalProperties);\n$1$2');

// Format all Search values by adding quotes around them.
let searchQueryRegex = /this\.InvocationInformation\.BoundParameters\.ContainsKey\("Search"\)\s*\?\s*Search\s*:\s*null/gm
$ = $.replace(searchQueryRegex, 'this.FormatSearchValue(this.InvocationInformation.BoundParameters, Search)');
}
return $;
}
Expand Down
21 changes: 21 additions & 0 deletions tools/Custom/ListCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,27 @@ public bool ShouldIteratePages(global::System.Collections.Generic.Dictionary<str
return nextLinkUri.Uri;
}

/// <summary>
/// Adds quotation mark around $search values if none exists.
/// This is needed to support KQL e.g. "prop:value".
/// </summary>
/// <param name="boundParameters">The bound parameters of the calling cmdlet.</param>
/// <param name="search">The $search value.</param>
/// <returns>A formated search value.</returns>
internal string FormatSearchValue(global::System.Collections.Generic.Dictionary<string, object> boundParameters, string search)
{
if (!boundParameters.ContainsKey("Search"))
{
return null;
}
else if (!string.IsNullOrWhiteSpace(search) && !search.StartsWith("\""))
{
search = $"\"{search}\"";
}

return search;
}

internal void OnBeforeWriteObject(global::System.Collections.Generic.Dictionary<string, object> boundParameters, global::System.Collections.Generic.IDictionary<string, object> additionalProperties)
{
// Get odata.count from the response.
Expand Down