- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
01-28-2025 09:20 AM - edited 01-28-2025 09:21 AM
Hi All!
I am putting together a PowerShell script to see what IPs are listed in the DoS Block Table. The command (debug dataplane show dos block-table) keeps timing out with the error
"Error executing command 'show config running'. Error: Exception calling "EndExecute" with "1" argument(s): "Command 'show config ru
nning' has timed out."
Below is the script. Any help would be much appreciated
.
Script:
# Import the Posh-SSH module
Import-Module Posh-SSH
clear
# Define connection details
$PaloAltoIP = "<ip address>" # Replace with your Palo Alto's IP address
$Username = "<userid>" # Replace with your username
$Password = "<password>" # Replace with your password
# Commands to execute
$Commands = @(
#"show config running
"debug dataplane show dos block-table" # Example command to show system information
)
# Establish an SSH session
try {
Write-Host "Establishing SSH connection to $PaloAltoIP..." -ForegroundColor Green
$SSHSession = New-SSHSession -ComputerName $PaloAltoIP -Credential (New-Object System.Management.Automation.PSCredential($Username, (ConvertTo-SecureString $Password -AsPlainText -Force))) -AcceptKey
Write-Host "Connection established." -ForegroundColor Green
} catch {
Write-Host "Failed to connect to $PaloAltoIP. Error: $_" -ForegroundColor Red
exit
}
# Execute commands
foreach ($Command in $Commands) {
Write-Host "Executing command: $Command" -ForegroundColor Yellow
try {
$Result = Invoke-SSHCommand -SSHSession $SSHSession -Command $Command -TimeOut 20
Write-Host "Command output:" -ForegroundColor Cyan
Write-Output $Result.Output
} catch {
Write-Host "Error executing command '$Command'. Error: $_" -ForegroundColor Red
}
}
# Close the SSH session
Write-Host "Closing SSH session..." -ForegroundColor Green
Remove-SSHSession -SSHSession $SSHSession
Write-Host "SSH session closed." -ForegroundColor Green
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!