diff --git a/src/ResourceManager/Version2016_09_01/ArgumentCompleters/PSArgumentCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/PSArgumentCompleter.cs index 6f8822a01e..19d91b9864 100644 --- a/src/ResourceManager/Version2016_09_01/ArgumentCompleters/PSArgumentCompleter.cs +++ b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/PSArgumentCompleter.cs @@ -13,6 +13,7 @@ // ---------------------------------------------------------------------------------- using System; +using System.Collections.Generic; using System.Management.Automation; namespace Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters @@ -25,10 +26,22 @@ public PSArgumentCompleterAttribute(params string[] argumentList) : base(CreateS public static ScriptBlock CreateScriptBlock(string[] resourceTypes) { - string scriptResourceTypeList = "'" + String.Join("' , '", resourceTypes) + "'"; + List outputResourceTypes = new List(); + foreach (string resourceType in resourceTypes) + { + if (resourceType.Contains(" ")) + { + outputResourceTypes.Add("\'\'" + resourceType + "\'\'"); + } + else + { + outputResourceTypes.Add(resourceType); + } + } + string scriptResourceTypeList = "'" + String.Join("' , '", outputResourceTypes) + "'"; string script = "param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\n" + String.Format("$values = {0}\n", scriptResourceTypeList) + - "$values | Where-Object { $_ -Like \"$wordToComplete*\" } | Sort-Object | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }"; + "$values | Where-Object { $_ -Like \"$wordToComplete*\" -or $_ -Like \"'$wordToComplete*\" } | Sort-Object | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }"; ScriptBlock scriptBlock = ScriptBlock.Create(script); return scriptBlock; }