I am attempting to create a script that will allow me to SSH into our DataPower VM, create an error report, and download that error report locally. To date, I am attempting to SSH into DataPower and issue the 'save error-report' command. Here is the script:
```
# Import the SSH module
Import-Module Posh-SSH
# Define variables
$hostname = "myDataPowerVM"
$username = "me"
$password = "PasswordHere"
# Create an SSH session
$session = New-SSHSession -ComputerName $hostname -Credential (New-Object -TypeName PSCredential -ArgumentList $username, (ConvertTo-SecureString -String $password -AsPlainText -Force))
# Check if the session was created successfully
if ($session.Connected) {
# Run the command to create the error report
$command = "sw myDomain; co; save error-report;"
$output = Invoke-SSHCommand -SessionId $session.SessionId -Command $command
# Clean up the SSH session
Remove-SSHSession -SessionId $session.SessionId
} else {
Write-Host "Failed to create SSH session. Please check your credentials and network connectivity."
}
```
The above returns the following error: Exception calling "EndExecute" with "1" argument(s): "Command 'sw myDomain; co; save error-report;' has timed out."
Has anyone created a script (PowerShell, Bash, etc.) that creates and then downloads an error-report.txt file?
------------------------------
EIS Developer
------------------------------