Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Check if different changing connections still exist

CaptainJaneway
7 - Meteor

I have to determine in a repetitive and fast way if different connection still exist. 

 

My input is a list of IP-Adresses and my output should look like this:

 

IP-AdressConnectionResponse time
1.2.3.4found20ms
4.5.6.7found25ms
8.9.10.11not foundnull

 

Response time would be nice, but is not urgent. My idea was to write a list of cmd ping commands to a .bat file and to run this by command line tool. But I don´t know for example how to handle an error. I appreciate any suggestions.

3 REPLIES 3
JoBen
11 - Bolide

Hi @CaptainJaneway, I was able to do something similar using a powershell script with Alteryx. My powershell script is below, which I saved to my desktop. I then used a Run Command tool to bring the data back into my workflow. Below is a picture of how I configured it. I basically used two CSV files- one with all my IP addresses that I wanted to look up saved to it, and one that powershell wrote to. You can see them both referenced in the code below. I hope this helps!

 

$myArray = get-content -path 'C:\users\JoBen\Desktop\IPAddressList.csv'
foreach ($element in $myarray) {
$ip=[IPAddress] $element
if (Test-Connection $ip -Quiet -Count 1) {
#Writes successful connection IP Address and Response Time
Test-Connection $ip | Select-Object Address,ResponseTime | export-CSV -append -force -path C:\Users\JoBen\Desktop\Output.csv
} else {
# Writes the IP Address that failed
Add-Content -force -path C:\Users\JoBen\Desktop\Output.csv -Value "$ip, Invalid_IP_Address"
}

 


}

 

Help1.PNG

CaptainJaneway
7 - Meteor

Thank you so much. This solution works very well. If I want use hostnames instead of IPs to check the connection, then I have to use $hostname as variable? 

JoBen
11 - Bolide

Okay. You bet. The name of the variable shouldn't matter, but you will need to change the script some to work with host names instead. Try this below to see if it works for you.

 

$myArray = get-content -path 'C:\users\JoBen\Desktop\IPAddressList.csv'
foreach ($element in $myarray) {
if (Test-Connection -ComputerName $element -Quiet -Count 1) {
#Writes successful connection IP Address and Response Time
Test-Connection $element | Select-Object Address,ResponseTime | export-CSV -append -force -path C:\Users\JoBen\Desktop\Output.csv
} else {
# Writes the IP Address that failed
Add-Content -force -path C:\Users\JoBen\Desktop\Output.csv -Value "$element, Invalid_IP_Address"
}

 


}

Labels