Forum Discussion
omykhan
Altostratus
Dec 30, 2024TMSH Command to list ASM policies not attached to any virtual servers in all partitions
Hi there, Can someone help find out the TMSH Command to list ASM policies not attached to any virtual servers in all partitions?
Juergen_Mang
MVP
Jan 17, 2025For such tasks I have a script framework for the F5 REST-API named restsh. Unfortunately I can not share it, but this is a snippet to solve your demand:
F5_URI="https://<f5-mgmt-ip>"
alias GET="curl -k -s --fail -u "<user>:<pass>"
while read -r POLICY_ID
do
POLICY_DATA=$(GET "$F5_URI/mgmt/tm/asm/policies/$POLICY_ID?\$select=fullPath,virtualServers,manualVirtualServers")
POLICY_NAME=$(jq -r ".fullPath" <<< "$POLICY_DATA")
VIRTUAL_SERVERS=$(jq -r '[.virtualServers.[]?,.manualVirtualServers.[]?] | length' <<< "$POLICY_DATA")
[ "$VIRTUAL_SERVERS" -eq 0 ] && echo "$POLICY_NAME"
done < <(GET "$F5_URI/mgmt/tm/asm/policies?\$select=name,id" | jq -r '.items[].id')
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects