Would you consider not running this from global scope in background? Perhaps use another scope and ensure these steps are done to allow it, etc. and run the script to get this over with?

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!