/// <summary> /// Performs execution of the command /// </summary> protected override void DoProcessRecord() { const string cmd = "_GetConnectionString -Version $args[0]"; const string localTemplate = "{0}"; // const string remoteTemplate = "Invoke-Command -ScriptBlock {{ {0} }} -ArgumentList $args[0] "; // const string remoteComputerTemplate = remoteTemplate + " -Computer $args[1] -Credential $args[2]"; // const string remoteSessionTemplate = remoteTemplate + " -Session $args[1]"; var funcCode = File.ReadAllText(Path.Combine( MyInvocation.MyCommand.Module.ModuleBase, "Private/Admin.ps1" )); object session = null; object credential = null; string invokeCmd; if (Session != null) { throw new NotImplementedException("Remote sessions are currently not supported"); // invokeCmd = string.Format(remoteSessionTemplate, cmd); // session = Session; } else if (!ComputerName.Equals("localhost", StringComparison.OrdinalIgnoreCase)) { throw new NotImplementedException("Remote computers are currently not supported"); // invokeCmd = string.Format(remoteComputerTemplate, cmd); // session = ComputerName; // credential = Credential; } else { invokeCmd = string.Format(localTemplate, cmd); } string version; if (Version == 0) { version = null; } else { version = $"{TfsVersionTable.GetMajorVersion(Version)}.0"; } var result = this.InvokeCommand.InvokeScript(funcCode + invokeCmd, true, PipelineResultTypes.None, null, version, session, credential); WriteObject(result); }