How to avoid the unrecognized arguments having issues with the quotes usage
az aks command invoke --resource-group test-shared-dev --name test-aks-dev --command "kubectl get pods --all-namespaces -o jsonpath= `"{.items[*].spec['initContainers', 'containers'][*].image}`""
To resolve this issue, you'll need to modify the command so that it handles the quoting and piping correctly. Here's an updated version of the command that avoids syntax issues by using escaped quotes for nested commands. First part I have already updated in comment section.
For the additional sorting, use this-
az aks command invoke --resource-group arkorg --name arko-cluster1 --command "kubectl get pods --all-namespaces -o jsonpath='{.items[].spec.containers[].image} {.items[].spec.initContainers[].image}' | tr -s '[[:space:]]' '\n' | sort | uniq -c"
works on powershell as well
References: