Nice script, however if you have any jobs disabled purposely, when the availability group fails over, it will re-enable those jobs. You'd have to always update this script and hardcode the jobs which are manually disabled (or create a lookup table).
I prefer to put a step 1 in all of my jobs to check if the current node is primary or not. If it's not primary, it just doesn't go to step 2. Much cleaner and I don't have to worry about keeping a script up to date.