Get-tenantlistindb (from previous post)

Now that we have our tenants listed in a database table, listing them is quite easy.
Added a switch that allow you to also list deleted/removed tenants.

function get-tenantlistindb {
    param(
        [switch]$all
    )
    $SQLInstance = "localhost\SQLExpress"
    $SQLDatabase = "Microsoft365"
    $sqlqr = "select * from [Microsoft365].[dbo].[tenants]"
    if (-not $all) {
        $sqlqr += " where active='1'"
    }
    $tenants = invoke-sqlcmd -query $sqlqr -ServerInstance $SQLInstance -Database $SQLDatabase
    $tenants
}

Leave a Reply