Share the script please. When it comes to the Graph SDK, the most important thing is permissions. You need to specify which permissions are needed, and provide consent for them as part of the connectivity process. Something like this:
Connect-MgGraph -Scopes Users,Read,All,Sites.Read.All
The exact permissions will depend on the cmdlets leveraged in the script.
Another thing to note is that it comes to enumerating SharePoint Online sites, currently only application permissions are supported. You cannot connect as a user that is, you need to run the cmdlet via service principal. See this article for details: https://learn.microsoft.com/en-us/powershell/microsoftgraph/app-only?view=graph-powershell-1.0