79098919

Date: 2024-10-17 15:59:01
Score: 0.5
Natty:
Report link

The solution was that I needed to:

Import-Module Az.Accounts

before loading my modules, or within my class definition itself.

class MyClass {
    [string]$azureTenantId

    # Constructor
    MyClass () {
        #this is required        
        Import-Module Az.Accounts
    }

    [void] connectAzAccount(){
        Connect-AzAccount -TenantId $this.azureTenantId
    }

    [void] setTenantId([string]$tenantId){
        $this.azureTenantId = $tenantId
    }
}
Reasons:
  • Blacklisted phrase (0.5): I need
  • Has code block (-0.5):
  • Self-answer (0.5):
Posted by: Adam Winter