Problems with Powershell Script in 1-3-AnyOrgOrPersonal Tutorial

Siegfried Heintze 1,861 Reputation points
2020-05-12T17:29:50.17+00:00

After fighting to get some tutorial examples from 9781484250396 working, I learned that most of the examples required that I check the ID tokens feature for Implicit grant flow.

So I'm abandoning tutorials in the above book and I'm hoping 1-3-AnyOrgOrPersonal will demonstrate some good techniques with regard to security and ID tokens.

As per the directions I execute these commands:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
cd .\AppCreationScripts\
.\Configure.ps1

I'm getting errors. Is there a bug in this power shell script?

Thanks

Siegfried

Notes:
I am having trouble posting all the error message text -- this web site aborts my posts if they get too long.

This could be related to how-to-restore-original-default-aad-directory.html.

PS C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts> .\Configure.ps1
Import-Module : The specified module 'AzureAD' was not loaded because no valid module file was found in any module directory.
At C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts\C
onfigure.ps1:152 char:1

  • Import-Module AzureAD
  • ~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ResourceUnavailable: (AzureAD:String) [Import-Module], FileNotFoundException
  • FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Connect-AzureAD : The term 'Connect-AzureAD' 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 C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts\C
onfigure.ps1:82 char:22

  • $creds = Connect-AzureAD -Credential $Credential
  • ~~~~~~~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (Connect-AzureAD:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Get-AzureADTenantDetail : The term 'Get-AzureADTenantDetail' 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 C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts\C
onfigure.ps1:95 char:15

  • $tenant = Get-AzureADTenantDetail
  • ~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (Get-AzureADTenantDetail:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Get-AzureADUser : The term 'Get-AzureADUser' 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 C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts\C
onfigure.ps1:99 char:13

  • $user = Get-AzureADUser -ObjectId $creds.Account.Id
  • ~~~~~~~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (Get-AzureADUser:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Creating the AAD application (WebApp)
New-AzureADApplication : The term 'New-AzureADApplication' 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 C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts\C
onfigure.ps1:103 char:28

  • $webAppAadApplication = New-AzureADApplication -DisplayName "WebAp ...
  • ~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (New-AzureADApplication:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

New-AzureADServicePrincipal : The term 'New-AzureADServicePrincipal' 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 C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts\C
onfigure.ps1:113 char:30

  • $webAppServicePrincipal = New-AzureADServicePrincipal -AppId $curr ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (New-AzureADServicePrincipal:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Get-AzureADApplicationOwner : The term 'Get-AzureADApplicationOwner' 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 C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts\C
onfigure.ps1:116 char:13

  • $owner = Get-AzureADApplicationOwner -ObjectId $webAppAadApplicati ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (Get-AzureADApplicationOwner:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Add-AzureADApplicationOwner : The term 'Add-AzureADApplicationOwner' 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 C:\Users\shein\Source\Repos\MicrosoftAADGitHubExamples\VariousSignInEg\1-WebApp-OIDC\1-3-AnyOrgOrPersonal\AppCreationScripts\C
onfigure.ps1:119 char:9

  • Add-AzureADApplicationOwner -ObjectId $webAppAadApplication.O ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (Add-AzureADApplicationOwner:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,457 questions
0 comments No comments
{count} votes

8 answers

Sort by: Most helpful
  1. ohseongkooi 1 Reputation point
    2020-05-12T17:35:57.297+00:00

    **

    strong text

    **

    0 comments No comments

  2. Dave Patrick 426.1K Reputation points MVP
    2020-05-12T17:47:41.593+00:00

    QnA currently supports the products listed in right-hand pane (more to be added) Better to reach out to subject matter experts in dedicated forums over here.

    https://social.technet.microsoft.com/Forums/en-US/home?forum=winserverpowershell

    (please don't forget to mark helpful replies as answer)


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    0 comments No comments

  3. Siegfried Heintze 1,861 Reputation points
    2020-05-12T18:27:35.293+00:00

    I'm a little surprised because it looks like a AAD problem to me.

    Nevertheless, here is the new posting:

    problems-with-powershell-script-in-1-3-anyorgorper.html

    0 comments No comments

  4. Dave Patrick 426.1K Reputation points MVP
    2020-05-12T18:28:48.8+00:00

    Sounds good, you're welcome.

    (please don't forget to mark helpful replies as answer)

    0 comments No comments

  5. soumi-MSFT 11,716 Reputation points Microsoft Employee
    2020-05-12T18:34:01.613+00:00

    @Siegfried Heintze , Looking at the errors it looks like the script is failing as the AzureAD Poswershell cmdlet is missing on your machine.

    You can try installing this module using the following steps:

    1. Install the PS module: install-module AzureAD
    2. Connect to the AzureAD module: connect-AzureAD

    Ideally this should get the script going. I have personally tried that script out and it worked for me.

    Incase the install-module cmdlet fails by any chance, try the following:

    1. import-module AzureAD
    2. get-module -name Azure AD
    3. install-module AzureAD

    Hope this helps. Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as "Answer" if the above response helped in answering your query.

    0 comments No comments