-
Notifications
You must be signed in to change notification settings - Fork 5
/
scpsync.ps1
28 lines (22 loc) · 866 Bytes
/
scpsync.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
param(
$target = '',
$destDir = '',
[Switch]$PrepTarget
)
$ErrorActionPreference = 'Stop'
# choco install openssh -y -params '"/SSHServerFeature"'
$thisDir = Get-Location
if ($destDir -eq '') { $destDir = $thisDir }
if ($PrepTarget) {
Write-Host "Preparing Target machine..."
Invoke-Command -ComputerName $target -Credential (Get-Credential 'Administrator') -ArgumentList @($destDir) -ScriptBlock {
param($destDir)
if (-Not (Test-Path -Path $destDir)) {
Write-Host "Creating destination dir..."
New-Item $destDir -ItemType Directory | Out-Null
}
& choco install openssh -y -params '"/SSHServerFeature"'
}
}
Write-Host "Connecting to $target ..."
& "C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script=C:\Source\dev-tools\scpsync.script /parameter $target ($thisDir -replace '\\','/') ($destDir -replace '\\','/')