You could try to change the following line:
Connect-VIServer ${ip} -WarningAction 0
To:
Connect-VIServer -Credential ${CREDENTIAL} ${ip} -WarningAction 0
In this case credentials may provide access to system with adequate permissions to connect.
You may also want to try playing with –User and –Password arguments.