Basic Powershell Azure Connection

stay puft 226 Reputation points
2023-02-10T22:03:48.8733333+00:00

OK, I admit, I am behind the curve. I have been using PowerShell and getting my commands to work as a sysadmin for some time, and things were fine. Now I am learning that the latest is PowerShell 7 and PowerShell graph andmy connections are not working anymore, and I am continuing to fail back to PowerShell 5 which works, but i am told is being deprecated, so I would like to get this to work.

So Assuming that I am on a bran new system, and I want to log into my Azure AD to GET and SET some attributes.

  • I install powershell 7
  • install-module azureAD
  • import-module azureAD
  • Connect-azureAD - but I am getting an error in this most basic step (Could not load type 'System.Security.Cryptography.SHA256Cng')

Could someone please explain to me as if i we a young child on how to make the new connections to Azure AD.

What am I missing, why does something that was so easy now have to be so hard??

And related, what about MS graph??? Is this just a Powershell web gui (is this command line or not) with more Secuity? I am trying to read some of the documentation but I just don't get it. How would I do the same thing above, but with MS graph?

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,811 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 47,596 Reputation points
    2023-02-11T03:17:12.7666667+00:00

    Does the "Could not load type 'System.Security.Cryptography.SHA256Cng" error line also say from which version of .Net it was unable to load that type?

    I remember this error from a long time ago. Back then the problem was that the azuread module (and PS7) was using .Net CORE, while PS5 was using .Net Framework. IIRC, the workaround was to use the -UseWindowsPowerShell switch on the Import-Module cmdlet.

    This is just one of the problems that crop up because PS7 uses .Net CORE (which has no Windows dependencies), while PS5 runs only on Windows,

    0 comments No comments

  2. Spencer 6 Reputation points
    2023-02-11T03:49:45.1+00:00

    https://learn.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0

    Try using =<PS5.1

    PS 7 you can begin using the Graph SDK https://learn.microsoft.com/en-us/powershell/microsoftgraph/overview?view=graph-powershell-1.0

    Using the migration guide: https://learn.microsoft.com/en-us/powershell/microsoftgraph/migration-steps?view=graph-powershell-1.0

    Example

    The equivalent of the Get-AzureADUser cmdlet is Get-MgUser. This cmdlet has additional parameters that let you do more with its output. For example, the -ConsistencyLevel parameter that allows you to do Count, Filter, and Search.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.