Skip to content

Instantly share code, notes, and snippets.

@jborean93
Last active December 6, 2021 05:21
Show Gist options
  • Save jborean93/118a83694a2f3f29c8a6c55dffbfd87f to your computer and use it in GitHub Desktop.
Save jborean93/118a83694a2f3f29c8a6c55dffbfd87f to your computer and use it in GitHub Desktop.
Override executable used for SSH PSRemoting
$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