Skip to content

Commit c415d0e

Browse files
authored
Merge pull request Azure#169 from dingmeng-xue/telemetry
Remove Az version fetching logic due to solution has flaw.
2 parents f6ed260 + 461abbf commit c415d0e

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

src/Common/AzurePSCmdlet.cs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2121
using System;
2222
using System.Collections.Concurrent;
23-
using System.Collections.ObjectModel;
2423
using System.Diagnostics;
2524
using System.IO;
2625
using System.Linq;
2726
using System.Management.Automation;
28-
using System.Management.Automation.Runspaces;
2927
using System.Text;
3028

3129
namespace Microsoft.WindowsAzure.Commands.Utilities.Common
@@ -870,40 +868,7 @@ public virtual bool IsTerminatingError(Exception ex)
870868

871869
protected string LoadAzVersion()
872870
{
873-
Version latestAz = new Version("0.0.0");
874-
string latestSuffix = "";
875-
using (var powershell = System.Management.Automation.PowerShell.Create())
876-
{
877-
powershell.Runspace = RunspaceFactory.CreateRunspace(this.Host);
878-
powershell.AddCommand("Get-Module");
879-
powershell.AddParameter("Name", "Az");
880-
powershell.AddParameter("ListAvailable", true);
881-
powershell.Runspace.Open();
882-
Collection<PSObject> outputs = powershell.Invoke();
883-
foreach (PSObject obj in outputs)
884-
{
885-
string psVersion = obj.Properties["Version"].Value.ToString();
886-
int pos = psVersion.IndexOf('-');
887-
string currentSuffix = (pos == -1 || pos == psVersion.Length - 1) ? "" : psVersion.Substring(pos + 1);
888-
Version currentAz = (pos == -1) ? new Version(psVersion) : new Version(psVersion.Substring(0, pos));
889-
if (currentAz > latestAz)
890-
{
891-
latestAz = currentAz;
892-
latestSuffix = currentSuffix;
893-
}
894-
else if (currentAz == latestAz)
895-
{
896-
latestSuffix = String.Compare(latestSuffix, currentSuffix) > 0 ? latestSuffix : currentSuffix;
897-
}
898-
}
899-
}
900-
string ret = latestAz.ToString();
901-
if (!String.IsNullOrEmpty(latestSuffix))
902-
{
903-
ret += "-" + latestSuffix;
904-
}
905-
WriteDebug(string.Format("Sought all Az modules and got latest version {0}", ret));
906-
return ret;
871+
return "1.0.0";
907872
}
908873
}
909874
}

0 commit comments

Comments
 (0)