Skip to content

Commit

Permalink
Merge pull request #382 from MVKozlov/RemotePathTransformation
Browse files Browse the repository at this point in the history
RemotePathTransformation for [GS]et-SCPItem
  • Loading branch information
darkoperator authored Mar 29, 2021
2 parents abe1ec6 + 82e3e17 commit 63a9860
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Source/PoshSSH/PoshSSH/GetScpItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ public SwitchParameter NoProgress
set { _noProgress = value; }
}

private string _pathTransformation;
[Parameter(Mandatory = false,
ValueFromPipelineByPropertyName = false,
HelpMessage = "Remote Path transormation to use.")]
[ValidateSet("ShellQuote", "None", "DoubleQuote", IgnoreCase = true)]
public string PathTransformation
{
get { return _pathTransformation; }
set { _pathTransformation = value; }
}

protected override void ProcessRecord()
{
foreach (var computer in ComputerName)
Expand All @@ -89,6 +100,18 @@ protected override void ProcessRecord()
{
if (client != default && client.IsConnected)
{
switch (PathTransformation.ToLower())
{
case "shellquote":
client.RemotePathTransformation = RemotePathTransformation.ShellQuote;
break;
case "none":
client.RemotePathTransformation = RemotePathTransformation.None;
break;
case "doublequote":
client.RemotePathTransformation = RemotePathTransformation.DoubleQuote;
break;
}
var _progresspreference = (ActionPreference)this.SessionState.PSVariable.GetValue("ProgressPreference");
if (_noProgress == false)
{
Expand Down
23 changes: 23 additions & 0 deletions Source/PoshSSH/PoshSSH/SetScpItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ public SwitchParameter NoProgress
set { _noProgress = value; }
}

private string _pathTransformation;
[Parameter(Mandatory = false,
ValueFromPipelineByPropertyName = false,
HelpMessage = "Remote Path transormation to use.")]
[ValidateSet("ShellQuote", "None", "DoubleQuote", IgnoreCase = true)]
public string PathTransformation
{
get { return _pathTransformation; }
set { _pathTransformation = value; }
}

protected override void ProcessRecord()
{
foreach (var computer in ComputerName)
Expand All @@ -80,6 +91,18 @@ protected override void ProcessRecord()
{
if (client != default && client.IsConnected)
{
switch (PathTransformation.ToLower())
{
case "shellquote":
client.RemotePathTransformation = RemotePathTransformation.ShellQuote;
break;
case "none":
client.RemotePathTransformation = RemotePathTransformation.None;
break;
case "doublequote":
client.RemotePathTransformation = RemotePathTransformation.DoubleQuote;
break;
}
var _progresspreference = (ActionPreference)this.SessionState.PSVariable.GetValue("ProgressPreference");
if (_noProgress == false)
{
Expand Down

0 comments on commit 63a9860

Please sign in to comment.