Did you run the cmdlets in the Exchange Management Shell? The Get-MailContact cmdlet is part of the module ExchangePowerShell.
To install the Exchange Management Shell you may refer to this link
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.