Skip to content

Instantly share code, notes, and snippets.

@amard33p
Last active January 8, 2022 14:09
Show Gist options
  • Save amard33p/d98b1c1f9579a7ee9e23327b9d5a6d40 to your computer and use it in GitHub Desktop.
Save amard33p/d98b1c1f9579a7ee9e23327b9d5a6d40 to your computer and use it in GitHub Desktop.
Install sshfs-win on a remote Windows 10 host using Powershell
# Ensure following script in executed on remote host first
# https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1
# Get the URL of the latest binaries from here
# https://github.com/billziss-gh/sshfs-win/releases
# https://github.com/billziss-gh/winfsp/releases
$winfsp_url = "https://github.com/billziss-gh/winfsp/releases/download/v1.7B2/winfsp-1.7.20123.msi"
$winfsp_msi = "winfsp-1.7.20123.msi"
$sshfs_url = "https://github.com/billziss-gh/sshfs-win/releases/download/v3.5.20024/sshfs-win-3.5.20024-x64.msi"
$sshfs_msi = "sshfs-win-3.5.20024-x64.msi"
Write-Host "Downloading Softwares"
Invoke-WebRequest -Uri $winfsp_url -OutFile $Env:temp\$winfsp_msi
Invoke-WebRequest -Uri $sshfs_url -OutFile $Env:temp\$sshfs_msi
$computerName = $Env:REMOTE_IP
$username = "Administrator"
$password = ConvertTo-SecureString $Env:ADMIN_PASSWORD -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$so = New-PsSessionOption -SkipCACheck -SkipCNCheck
$session = New-PSSession -ComputerName $computerName -credential $cred -UseSSL -SessionOption $so
Copy-Item -Path $Env:temp\$winfsp_msi -ToSession $session -Destination C:\Windows\Temp\
Copy-Item -Path $Env:temp\$sshfs_msi -ToSession $session -Destination C:\Windows\Temp\
Invoke-Command -Session $session -ScriptBlock {
Write-Host "Installing Softwares"
Start-Process -FilePath $Using:winfsp_msi -ArgumentList '/q' -WorkingDirectory "C:\Windows\Temp\" -Wait
Start-Process -FilePath $Using:sshfs_msi -ArgumentList '/q' -WorkingDirectory "C:\Windows\Temp\" -Wait
}
Remove-PSSession $session
Remove-Item $Env:temp\$winfsp_msi, $Env:temp\$sshfs_msi -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment