Skip to content

PowerShell unable to load Az.Resources module  #2334

Closed

Description

System Details

  • macOS Catalina 10.15.1
  • VSCode version 1.41.0-insider
  • PowerShell extension version ms-vscode.powershell-preview 2019.11.0

System Details Output

### PSES version: 2.0.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      6.2.3
PSEdition                      Core
GitCommitId                    6.2.3
OS                             Darwin 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

I am trying to run a PowerShell script that uses the Az.Resources module to export info from Azure AD. This script has worked in the past, and I believe the problems started after I upgraded to macOS Catalina.

I've pasted in the script below and also the output.

Script:

# this exports users from Azure AD into a csv file format specified by Tableau for importing users into Tableau Server
# created by [email protected]
# last modified 2019-10-16

# retrieve the object id for the nelson Office Azure AD security group
Get-AzADGroup -DisplayName "Nelson Office"

# retrieve all users belonging to the NO security group
$users = Get-AzADGroupMember -GroupObjectId "0bbfc2a1-e862-49f9-9745-c3d82a62cd5b"

# create custom objects for each user with the properties required by Tableau Server for importing users
$userArray = @()
foreach ($user in $users) {
    $properties = @{'UserName' = $user.UserPrincipalName;
                    'Password' = 'password'
                    'DisplayName' = $user.DisplayName;
                    'LicenseLevel' = '';
                    'AdminitratorLevel' = '';
                    'PublishingCapability' = '';
                    'Email' = $user.UserPrincipalName}
    $userArray += New-Object –TypeName PSObject –Prop $properties
}

# output to csv
$userArray | Select-Object -Property UserName, Password, DisplayName, LicenseLevel, AdminitratorLevel, PublishingCapability, Email | 
    ConvertTo-Csv | Set-Content -Path ./azure-ad-users.csv 

# strip out text qualifiers from the csv and also the header row and re-save file
(Get-Content -Path ./azure-ad-users.csv).Replace('"','') | Select-Object -Skip 1 | Set-Content -Path ./azure-ad-users.csv

# display results
Get-Content -Path ./azure-ad-users.csv#### Expected Behaviour

Output:

PowerShell Integrated Console

PS /Users/chip/Dropbox/Code/Powershell> Unable to find type [Microsoft.PowerShell.PSConsoleReadLine].
At line:1 char:71
+ ... :RunClassConstructor([Microsoft.PowerShell.PSConsoleReadLine].TypeHan ...
+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (Microsoft.PowerShell.PSConsoleReadLine:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
 
PS /Users/chip/Dropbox/Code/Powershell> /Users/chip/Dropbox/Code/Powershell/export-azure-ad-users.ps1

Get-AzADGroup : The 'Get-AzADGroup' command was found in the module 'Az.Resources', but the module could not be loaded. For more information, run 'Import-Module Az.Resources'.
At /Users/chip/Dropbox/Code/Powershell/export-azure-ad-users.ps1:6 char:1
+ Get-AzADGroup -DisplayName "Nelson Office"
+ ~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Get-AzADGroup:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
 
Get-AzADGroupMember : The 'Get-AzADGroupMember' command was found in the module 'Az.Resources', but the module could not be loaded. For more information, run 'Import-Module Az.Resources'.
At /Users/chip/Dropbox/Code/Powershell/export-azure-ad-users.ps1:9 char:10
+ $users = Get-AzADGroupMember -GroupObjectId "0bbfc2a1-e862-49f9-9745- ...
+          ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Get-AzADGroupMember:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
 
[email protected],password,Krupesh Desai,,,,[email protected]
PS> ./export-azure-ad-users.ps1
Get-AzADGroup : The 'Get-AzADGroup' command was found in the module 'Az.Resources', but the module could not be loaded. For more information, run 'Import-Module Az.Resources'.
At /Users/chip/Dropbox/Code/Powershell/export-azure-ad-users.ps1:6 char:1
+ Get-AzADGroup -DisplayName "Nelson Office"
+ ~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Get-AzADGroup:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
 
Get-AzADGroupMember : The 'Get-AzADGroupMember' command was found in the module 'Az.Resources', but the module could not be loaded. For more information, run 'Import-Module Az.Resources'.
At /Users/chip/Dropbox/Code/Powershell/export-azure-ad-users.ps1:9 char:10
+ $users = Get-AzADGroupMember -GroupObjectId "0bbfc2a1-e862-49f9-9745- ...
+          ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Get-AzADGroupMember:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
 
[email protected],password,Krupesh Desai,,,,[email protected]
ersion: $($pseditor.EditorServicesVersion)"; "`n### PowerShell version:`n$($PSVersionTable | Out-String)"}ions:`n$(code-insiders --list-extensions --show-versions | Out-String)"; "`n### PSES v
code-insiders : The term 'code-insiders' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:27
+ & {"### VSCode version: $(code-insiders -v)"; "`n### VSCode extension ...
+                           ~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (code-insiders:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException 

### VSCode version: 
code-insiders : The term 'code-insiders' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:76
+ ... ode-insiders -v)"; "`n### VSCode extensions:`n$(code-insiders --list- ...
+                                                     ~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (code-insiders:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

VSCode extensions:

PSES version: 2.0.0.0

PowerShell version:

Name Value


PSVersion 6.2.3
PSEdition Core
GitCommitId 6.2.3
OS Darwin 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

PS /Users/chip/Dropbox/Code/Powershell> Unable to find type [Microsoft.PowerShell.PSConsoleReadLine].
At line:1 char:71

  • ... :RunClassConstructor([Microsoft.PowerShell.PSConsoleReadLine].TypeHan ...
  •                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  • CategoryInfo : InvalidOperation: (Microsoft.PowerShell.PSConsoleReadLine:TypeName) [], RuntimeException
  • FullyQualifiedErrorId : TypeNotFound

PS /Users/chip/Dropbox/Code/Powershell> /Users/chip/Dropbox/Code/Powershell/export-azure-ad-users.ps1

Get-AzADGroup : The 'Get-AzADGroup' command was found in the module 'Az.Resources', but the module could not be loaded. For more information, run 'Import-Module Az.Resources'.
At /Users/chip/Dropbox/Code/Powershell/export-azure-ad-users.ps1:6 char:1

  • Get-AzADGroup -DisplayName "Nelson Office"
  • CategoryInfo : ObjectNotFound: (Get-AzADGroup:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

Get-AzADGroupMember : The 'Get-AzADGroupMember' command was found in the module 'Az.Resources', but the module could not be loaded. For more information, run 'Import-Module Az.Resources'.
At /Users/chip/Dropbox/Code/Powershell/export-azure-ad-users.ps1:9 char:10

  • $users = Get-AzADGroupMember -GroupObjectId "0bbfc2a1-e862-49f9-9745- ...
  •      ~~~~~~~~~~~~~~~~~~~
    
  • CategoryInfo : ObjectNotFound: (Get-AzADGroupMember:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

Attached Logs

I've attached the powershell and editor services logs:
Archive.zip

Activity

  1. ghost added
    Needs: Triage
    on Nov 27, 2019
  2. rjmholt commented on Nov 28, 2019

    @rjmholt
    Contributor

    Looks like something odd happened with some of the output script formatting there. But in any event, this is a duplicate of #2292. I have a prototype of a fix in that issue, so please try it out and let me know in that issue if it solves the problem or if you have any other issues with it.

  3. added
    Resolution-Duplicate
    and removed
    Needs: Triage
    on Nov 28, 2019
  4. chip-felton commented on Nov 28, 2019

    @chip-felton
    Author
  5. ghost added
    Needs: Maintainer Attention
    on Nov 28, 2019
  6. chip-felton commented on Nov 28, 2019

    @chip-felton
    Author
  7. rjmholt commented on Nov 29, 2019

    @rjmholt
    Contributor

    Good information -- thanks for letting me know. You're on macOS, yes?

  8. rjmholt commented on Nov 29, 2019

    @rjmholt
    Contributor

    Any idea when this will make its way into the main release?

    It'll likely be in the next preview

  9. chip-felton commented on Nov 30, 2019

    @chip-felton
    Author
  10. ghost closed this as completedon Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-Duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions