Not sure about execution of groovy SO, however you may try this workaround. If target server is fixed, you may keep the groovy/java code in a jar with limited access on target and write a powershell command to trigger the jar from your operation.