For Azure AD joined accounts, I believe you can try:
$UPN = whoami /upn
Connect-AzureAD -AccountId $UPN
Otherwise credentials are required Connect-AzureAD in either the Connect-AzureAD command or via the login window. This is by design for security purposes. One option is to use the -Credentials parameter and pass the username/password, but then you would still be using the credentials in the script itself.
There is a related discussion on this topic here that includes these options, along with some pre-written scripts: https://techcommunity.microsoft.com/t5/azure-active-directory-identity/connect-azuread-with-login-credentials/m-p/145012