The following script provides you if we need to make changes to the appliances that are reachable. Here in the example, we are trying to unlock the admin user for the reachable appliances.
Create test.sh file
touch test.sh
#!/bin/bash
source /etc/profile.d/versa-profile.sh
source . /var/versa/vnms/data/conf/default.conf
sudo -u postgres psql -d vnms -t -c "select name from appliance_status where ping_status='REACHABLE'" | \
while read line; do echo -e "request devices device $line config system unlock-user admin\n" | ncs_cli ; done
Copy and Paste the above content in test.sh
Provide executable permission
chmod +x test.sh
Then run it from shell
bash -x ./test.sh