diff --git a/src/readme.graph.md b/src/readme.graph.md index 413b58a76f1..bee31d90e98 100644 --- a/src/readme.graph.md +++ b/src/readme.graph.md @@ -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 $; } diff --git a/tools/Custom/ListCmdlet.cs b/tools/Custom/ListCmdlet.cs index 6f23b15201b..13660faf15f 100644 --- a/tools/Custom/ListCmdlet.cs +++ b/tools/Custom/ListCmdlet.cs @@ -172,6 +172,27 @@ public bool ShouldIteratePages(global::System.Collections.Generic.Dictionary + /// Adds quotation mark around $search values if none exists. + /// This is needed to support KQL e.g. "prop:value". + /// + /// The bound parameters of the calling cmdlet. + /// The $search value. + /// A formated search value. + internal string FormatSearchValue(global::System.Collections.Generic.Dictionary 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 boundParameters, global::System.Collections.Generic.IDictionary additionalProperties) { // Get odata.count from the response.