microsoft / zerotrustassessment

Repository for the Zero Trust Assessment project
https://aka.ms/ztassess
MIT License
37 stars 26 forks source link

Need a way to run in a multi-tenant / MSP environment #33

Open thetootall opened 6 months ago

thetootall commented 6 months ago

Hi team,

I would love to see a way to specify either a tenant ID or vanity domain name as a switch when I authenticate, as I have a single Global Reader credential via GDAP to access my clients, versus having to run this with separate credentials.

Is it possible to have it feed this into the module to make it more flexible?

spaelling commented 1 month ago
$TenantIds = @('mytenantid1','mytenantid2')
foreach ($TenantId in $TenantIds) {    
    $null = Connect-AzAccount -TenantId $TenantId
    $AccessToken = Get-AzAccessToken -TenantId $TenantId -ResourceTypeName MSGraph -AsSecureString -WarningAction SilentlyContinue | Select-Object -ExpandProperty Token
    Invoke-ZTAssessment -AccessToken (ConvertFrom-SecureString $AccessToken -AsPlainText)
}

Sadly they ask for the access token in plaint text. That is bad practice, but this way it is not stored in plain text as a variable at least.