Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCopyright("Copyright © 2016-2021 BornToBeRoot")]
[assembly: AssemblyCopyright("Copyright © 2016-2022 BornToBeRoot")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("2022.8.18.0")]
[assembly: AssemblyFileVersion("2022.8.18.0")]
[assembly: AssemblyVersion("2022.10.24.0")]
[assembly: AssemblyFileVersion("2022.10.24.0")]
8 changes: 8 additions & 0 deletions Source/NETworkManager.Models/PowerShell/PowerShell.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace NETworkManager.Models.PowerShell
{
public static partial class PowerShell
{

public static readonly List<string> GetDefaultIntallationPaths = new()
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "PowerShell", "7", "pwsh.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "PowerShell", "7", "pwsh.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"System32\WindowsPowerShell\v1.0\powershell.exe")
};

/// <summary>
/// Default SZ registry keys for the global PowerShell profile.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager.Models/PuTTY/PuTTY.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class PuTTY
public static readonly List<string> GetDefaultInstallationPaths = new()
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), _puttyFolder, _puttyFile),
Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.ProgramFilesX86), _puttyFolder, _puttyFile)
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), _puttyFolder, _puttyFile)
};

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Source/NETworkManager.Settings/GlobalStaticConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public static class GlobalStaticConfiguration
public static NetworkConnectionType RemoteDesktop_NetworkConnectionType => NetworkConnectionType.DetectAutomatically;

// Application: PowerShell
public static string PowerShell_ApplicationFileLocationPowerShell => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"System32\WindowsPowerShell\v1.0\powershell.exe");
public static string PowerShell_Command => "Set-Location ~";
public static PowerShell.ExecutionPolicy PowerShell_ExecutionPolicy => PowerShell.ExecutionPolicy.RemoteSigned;

Expand All @@ -136,7 +135,6 @@ public static class GlobalStaticConfiguration
public static int PuTTY_Raw => 0;

// Application: AWSSessionManager
public static string AWSSessionManager_ApplicationFileLocationPowerShell => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"System32\WindowsPowerShell\v1.0\powershell.exe");
public static bool AWSSessionManager_EnableSyncInstanceIDsFromAWS => false;
public static bool AWSSessionManager_SyncOnlyRunningInstancesFromAWS => true;

Expand Down
4 changes: 2 additions & 2 deletions Source/NETworkManager.Settings/SettingsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,7 @@ public ObservableCollection<string> PowerShell_HostHistory
}
}

private string _powerShell_ApplicationFilePath = GlobalStaticConfiguration.PowerShell_ApplicationFileLocationPowerShell;
private string _powerShell_ApplicationFilePath;
public string PowerShell_ApplicationFilePath
{
get => _powerShell_ApplicationFilePath;
Expand Down Expand Up @@ -2921,7 +2921,7 @@ public string AWSSessionManager_DefaultRegion
}
}

private string _awsSessionManager_ApplicationFilePath = GlobalStaticConfiguration.AWSSessionManager_ApplicationFileLocationPowerShell;
private string _awsSessionManager_ApplicationFilePath;
public string AWSSessionManager_ApplicationFilePath
{
get => _awsSessionManager_ApplicationFilePath;
Expand Down
14 changes: 14 additions & 0 deletions Source/NETworkManager.Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using log4net;
using NETworkManager.Models;
using NETworkManager.Models.PowerShell;
using System;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -216,6 +217,19 @@ public static void Upgrade(Version fromVersion, Version toVersion)

_log.Info($"Add AWS Session Manager to application list...");
Current.General_ApplicationList.Add(ApplicationManager.GetList().First(x => x.Name == ApplicationName.AWSSessionManager));

var powerShellPath = "";
foreach(var file in PowerShell.GetDefaultIntallationPaths)
{
if(File.Exists(file))
{
powerShellPath = file;
break;
}
}

_log.Info($"Set AWS Session Manager application file path to \"{powerShellPath}\"...");
Current.AWSSessionManager_ApplicationFilePath = powerShellPath;
}

// Set to latest version and save
Expand Down
11 changes: 11 additions & 0 deletions Source/NETworkManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,17 @@ protected override async void OnContentRendered(EventArgs e)
SettingsManager.Current.DNSLookup_DNSServers = new ObservableCollection<DNSServerInfo>(DNSServer.GetDefaultList());
SettingsManager.Current.AWSSessionManager_AWSProfiles = new ObservableCollection<AWSProfileInfo>(AWSProfile.GetDefaultList());

// Check if PowerShell is installed
foreach(var file in Models.PowerShell.PowerShell.GetDefaultIntallationPaths)
{
if(File.Exists(file))
{
SettingsManager.Current.PowerShell_ApplicationFilePath = file;
SettingsManager.Current.AWSSessionManager_ApplicationFilePath = file;
break;
}
}

// Check if PuTTY is installed
foreach (var file in Models.PuTTY.PuTTY.GetDefaultInstallationPaths)
{
Expand Down
2 changes: 2 additions & 0 deletions docs/Changelog/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ permalink: /Changelog/next-release
- Generate default lists at first run [#1544](https://github.com/BornToBeRoot/NETworkManager/pull/1544){:target="\_blank"}
- Port Scanner
- Add more port profiles (LDAP, HTTP proxy, Filetransfer) [#1526](https://github.com/BornToBeRoot/NETworkManager/pull/1526){:target="\_blank"}
- PowerShell
- Change default path on new installations to `pwsh.exe` (Windows PowerShell is used as fallback if `pwsh.exe` is not available) [#1663](https://github.com/BornToBeRoot/NETworkManager/pull/1663){:target="\_blank"}
- PuTTY
- Detect if PuTTY is installed at first run [#1542](https://github.com/BornToBeRoot/NETworkManager/pull/1542){:target="\_blank"}
- Discovery Protocol
Expand Down
2 changes: 1 addition & 1 deletion docs/Documentation/01_Application/12_AWSSessionManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ Path to the PowerShell console where the AWS CLI is available and which should b

**Type:** `String`

**Default:** `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`
**Default:** `C:\Program Files\PowerShell\7\pwsh.exe`, `C:\Program Files (x86)\PowerShell\7\pwsh.exe` or `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`

**Possible values:**

Expand Down