This script is rather complicated to use but when scripting rigs, it is very useful. It can position any object at the position of another object, orient it to another object and scale it based on the distance of two other objects and a factor. Furthermore you can change the rotation order and apply a freeze transform at the end. Instead of the freezing, I recommend to use the group option because then the object will keep its local orientation. And all this with one single command!