Skip to content

Commit

Permalink
Merge pull request AzureRT#38 from maddieclayton/release-2018-08-24
Browse files Browse the repository at this point in the history
fix alias
  • Loading branch information
markcowl authored Aug 24, 2018
2 parents b69e167 + 1df60d2 commit 5f1dcd5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,22 @@ public static string GetProfilePath(string Scope, SessionState sessionState)
var userprofile = "";
if (Scope != null && Scope.Equals("CurrentUser"))
{
var editionType = sessionState.PSVariable.GetValue("PSEdition") as string;
var psFolder = string.Equals(editionType, "Desktop", StringComparison.OrdinalIgnoreCase) ? "WindowsPowerShell" : "PowerShell";
userprofile = Path.Combine(sessionState.PSVariable.GetValue("env:USERPROFILE").ToString(), "Documents", psFolder, "profile.ps1");
var powershellProfile = sessionState.PSVariable.GetValue("PROFILE") as PSObject;
if (powershellProfile == null || !powershellProfile.Members.ToList().Any(a => a.Name.Equals("CurrentUserAllHosts")))
{
throw new PSInvalidOperationException(string.Format(Properties.Resources.ProfilePathNull, "PROFILE.CurrentUserAllHosts"));
}
userprofile = powershellProfile.Members.ToList().Where(a => a.Name.Equals("CurrentUserAllHosts")).First().Value.ToString();
}

else if (Scope != null && Scope.Equals("LocalMachine"))
{
userprofile = Path.Combine(sessionState.PSVariable.GetValue("PSHOME").ToString(), "profile.ps1");
var powershellProfile = sessionState.PSVariable.GetValue("PROFILE") as PSObject;
if (powershellProfile == null || !powershellProfile.Members.ToList().Any(a => a.Name.Equals("AllUsersAllHosts")))
{
throw new PSInvalidOperationException(string.Format(Properties.Resources.ProfilePathNull, "PROFILE.AllUsersAllHosts"));
}
userprofile = powershellProfile.Members.ToList().Where(a => a.Name.Equals("AllUsersAllHosts")).First().Value.ToString();
}

return userprofile;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,7 @@
<data name="AliasImportFailure" xml:space="preserve">
<value>LocalMachine scope can only be set in PowerShell administrative mode.</value>
</data>
<data name="ProfilePathNull" xml:space="preserve">
<value>Unable to set profile because environment variable '${0}' is null.</value>
</data>
</root>

0 comments on commit 5f1dcd5

Please sign in to comment.