# Define variables $localFolder = "./src/." $remoteUser = "debian" $remoteHost = "robe.vincent-bouquet.fr" $remotePath = "/var/www/html/public/reap" $port = 22 # Change this if your SSH server uses a different port # Build the SCP commands $sshCommand = "ssh -p ${port} ${remoteUser}@${remoteHost} 'mkdir -p `"${remotePath}`" && sudo rm -rf `"${remotePath}/*`"'" $scpCommand = "scp -r -P ${port} `"${localFolder}`" ${remoteUser}@${remoteHost}:`"${remotePath}`"" # Execute SSH command to clean remote directory Write-Host "Cleaning remote directory: $remotePath" Invoke-Expression $sshCommand # Execute the command Write-Host "Executing: $scpCommand" Invoke-Expression $scpCommand