Mind posting the actual script, we're not fortune tellers here :)
Without knowing what exactly you're trying to run, my best guess is that you have not added the current user as a member of the ADSyncOperators group. Here's an article detailing what each group is used for: https://learn.microsoft.com/en-us/archive/blogs/iamsupport/support-info-azure-ad-connect-sync-security-groups
