Last active
December 6, 2021 05:21
-
-
Save jborean93/118a83694a2f3f29c8a6c55dffbfd87f to your computer and use it in GitHub Desktop.
Override executable used for SSH PSRemoting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$script = Set-Content ./hvc_ssh.bat -Value 'hvc.exe ssh %*' | |
$ExecutionContext.InvokeCommand.PostCommandLookupAction = { | |
param ($Command, $EA) | |
if ($Command -eq ($IsWindows ? 'ssh.exe' : 'ssh')) { # This is just ssh | |
$EA.Command = Get-Command './hvc_ssh.bat' | |
} | |
} | |
try { | |
Invoke-Command -HostName server2019.domain.test -UserName vagrant -ScriptBlock { $env:USERPROFILE } | |
} | |
finally { | |
$ExecutionContext.InvokeCommand.PostCommandLookupAction = $null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment