Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuning the creation of new CLI apps #6444

Open
3 tasks
martinlingstuyl opened this issue Oct 22, 2024 · 3 comments
Open
3 tasks

Tuning the creation of new CLI apps #6444

martinlingstuyl opened this issue Oct 22, 2024 · 3 comments

Comments

@martinlingstuyl
Copy link
Contributor

Hi guys!

The CLI has new functionality in place to create a new application to use the CLI on a Microsoft 365 tenant. We have to run m365 setup and follow the questions to the end. Which is nice!

Now I've been brainstorming with my colleagues who had a few questions about this functionality.

We'd like to tune the process a bit to make it even more user friendly for people who have to use it often. So especially for users regularly working with new tenants, like systems integrators who regularly have new customers this is important.

We thought of the following improvements:

  • Be able to setup the application without reconfiguring the CLI entirely.
    If we now run m365 setup it will ask us a lot of questions. But if we're working with the CLI all the time, we generally like to skip that, as we've already configured it to our liking. We don't want it to override our configuration. We just want to create a new app.

  • See the tenant name, tenantId and appId when running m365 connection list
    We use custom scripting to determine if we already have a connection with a tenant. If we do not, it should start the setup process. If we do, it should switch to that tenant.

  • Be able to specify a custom App Name.
    We often work with both PnP PowerShell AND the CLI for Microsoft 365. We want to create an app that's named "M365 Shell tooling" (for example),

How about that? Let's discuss!

As an example, this is the powershell script my colleague wrote, to make working with multiple tenants easier for him.

function Connect-M365Interactive {
    [cmdletBinding()]
    param (
        [parameter(mandatory=$true)]$tenantName
    )
    $connections = (m365 connection list --output json | ConvertFrom-Json)
    $existingConnection = $connections | Where name -eq "$tenantName-interactive"
    if($existingConnection) {
        m365 connection use --name "$tenantName-interactive"
        return
    }
    $cred = Get-PnPStoredCredential -Name "$tenantName-interactive" -ErrorAction SilentlyContinue
    if(!$cred) {
        Write-Host "No credential found for $tenantName-interactive"
        m365 setup
        $connectionData = (m365 cli config list --output json) | ConvertFrom-Json
        Add-PnPStoredCredential -Name "$tenantName-interactive" -Username $connectionData.clientId -Password (ConvertTo-SecureString -String $connectionData.tenantId -AsPlainText -Force)
        $cred = Get-PnPStoredCredential -Name "$tenantName-interactive"
    }
    m365 login --tenant $cred.GetNetworkCredential().Password --appId $cred.Username --connectionName "$tenantName-interactive"
}
@milanholemans
Copy link
Contributor

Be able to setup the application without reconfiguring the CLI entirely

Totally agree, when setting up a new app registration for a new tenant/customer, it's frustrating that all my config is gone.

See the tenant name, tenantId and appId when running m365 connection list

Looks like a nice enhancement to me.

Be able to specify a custom App Name.

You can still modify it using the UI, right?

@martinlingstuyl
Copy link
Contributor Author

You can still modify it using the UI, right?

Of course, but that's too much trouble. Why not automate it?!
And even PnP PowerShell has this 😉

@waldekmastykarz
Copy link
Member

Great suggestions and agreed with all of them. I suggest we take them in separate issues one by one. Let's do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants