I work for a company in which we resell Office365 products. That being said, we have access to many domains that are our clients.
That being said, sometimes, we have to connect to the PS Module of O365 to get certain info about mailboxes, users etc…
Here’s a little script we made:
Get Tenant ID
Get-MsolPartnerContract -DomainName domain.onmicrosoft.com
Connect to an MSOL tenant
$tenID=(get-msolpartnercontract -domain domain.onmicrosoft.com).tenantId.guid
Get Commands for a tenant (add -tenantID $tenID to the command after running the one above)
Get-MsolUser email@example.com -tenantID $tenID
Connect to Exchange Powershell for a client
$Creds = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/PowerShell-LiveID?DelegatedOrg=domain.onmicrosoft.com -Credential $Creds -Authentication Basic –AllowRedirection
My question is the following:
Is there a way to build a script, so that we create variables so that it asks us for the domain and the TenantID is a more user friendly way ?
The end goal would be to build a script that would have ask for the domain and tenant ID only and once we enter that, we easily get in the PowerShell session to get commands such as get-mailbox and so on…
Any help would be appreciated.