www.powershellgallery.com Open in urlscan Pro
40.87.85.101  Public Scan

URL: https://www.powershellgallery.com/packages/MSAL.PS/4.2.1.1/Content/Get-MsalClientApplication.ps1
Submission Tags: falconsandbox
Submission: On September 08 via api from US — Scanned from DE

Form analysis 1 forms found in the DOM

GET /packages

<form aria-label="Package search bar" action="/packages" method="get">
  <div class="container">
    <div class="row">
      <div class="col-sm-offset-1 col-sm-2"></div>
      <div class="col-sm-12 col-md-8">
        <div class="form-group special-margin-left">
          <label for="search">Search PowerShell packages:</label>
          <div class="input-group" role="presentation">
            <input name="q" type="text" class="form-control ms-borderColor-blue search-box" id="search" aria-label="Enter packages to search, use the arrow keys to autofill." placeholder="PowerShellGet, Get-AzVM, etc..." autocomplete="on" value="">
            <span class="input-group-btn">
              <button class="btn btn-default btn-search ms-borderColor-blue ms-borderColor-blue--hover" type="submit" title="Search PowerShell packages" aria-label="Search PowerShell packages">
                <span class="ms-Icon ms-Icon--Search" aria-hidden="true"></span>
              </button>
            </span>
          </div>
          <div id="autocomplete-results-container" class="text-left" tabindex="0"></div>
          <script type="text/html" id="autocomplete-results-row">
            <!-- ko if: $data -->
          <!-- ko if: $data.PackageRegistration -->
          <div class="col-sm-4 autocomplete-row-id autocomplete-row-data">
            <span data-bind="attr: { id: 'autocomplete-result-id-' + $data.PackageRegistration.Id, title: $data.PackageRegistration.Id }, text: $data.PackageRegistration.Id"></span>
          </div>
          <div class="col-sm-4 autocomplete-row-downloadcount text-right autocomplete-row-data">
            <span data-bind="text: $data.DownloadCount + ' downloads'"></span>
          </div>
          <div class="col-sm-4 autocomplete-row-owners text-left autocomplete-row-data">
            <span data-bind="text: $data.OwnersString + ' '"></span>
          </div>
          <!-- /ko -->
          <!-- ko ifnot: $data.PackageRegistration -->
          <div class="col-sm-12 autocomplete-row-id autocomplete-row-data">
            <span data-bind="attr: { id: 'autocomplete-result-id-' + $data, title: $data  }, text: $data"></span>
          </div>
          <!-- /ko -->
          <!-- /ko -->
          </script>
          <script type="text/html" id="autocomplete-results-template">
            <!-- ko if: $data.data.length > 0 -->
          <div data-bind="foreach: $data.data" id="autocomplete-results-list">
            <a data-bind="attr: { id: 'autocomplete-result-row-' + $data, href: '/packages/' + $data, title: $data }" tabindex="-1">
            <div data-bind="attr:{ id: 'autocomplete-container-' + $data }" class="autocomplete-results-row">
            </div>
        </a>
          </div>
          <!-- /ko -->
          </script>
        </div>
      </div>
    </div>
  </div>
</form>

Text Content

This site uses cookies for analytics, personalized content and ads. By
continuing to browse this site, you agree to this use. Learn more
Skip To Content
Toggle navigation
 * Packages
 * Publish
 * Statistics
 * Documentation

 * Sign in

Search PowerShell packages:




MSAL.PS

4.2.1.1


GET-MSALCLIENTAPPLICATION.PS1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<#
.SYNOPSIS
    Get client application from local session cache.
.DESCRIPTION
    This cmdlet will return a client application object from the local session
cache. If it does not yet exist, a new client application will be created and
added to the cache.
.EXAMPLE
    PS C:\>Get-MsalClientApplication -ClientId
'00000000-0000-0000-0000-000000000000'
    Get public client application using default settings.
.EXAMPLE
    PS C:\>$ConfidentialClientOptions = New-Object
Microsoft.Identity.Client.ConfidentialClientApplicationOptions -Properties @{
ClientId = '00000000-0000-0000-0000-000000000000' }
    PS C:\>$ConfidentialClientOptions | Get-MsalClientApplication -ClientSecret
(ConvertTo-SecureString 'SuperSecretString' -AsPlainText -Force) -TenantId
'00000000-0000-0000-0000-000000000000'
    Pipe in confidential client options object to get a confidential client
application using a client secret and target a specific tenant.
.EXAMPLE
    PS C:\>$ClientCertificate = Get-Item
Cert:\CurrentUser\My\0000000000000000000000000000000000000000
    PS C:\>$ConfidentialClientOptions = New-Object
Microsoft.Identity.Client.ConfidentialClientApplicationOptions -Properties @{
ClientId = '00000000-0000-0000-0000-000000000000'; TenantId =
'00000000-0000-0000-0000-000000000000' }
    PS C:\>$ConfidentialClientOptions | Get-MsalClientApplication
-ClientCertificate $ClientCertificate
    Pipe in confidential client options object to get a confidential client
application using a client certificate and target a specific tenant.
#>
function Get-MsalClientApplication {
    [CmdletBinding(DefaultParameterSetName='PublicClient')]
    [OutputType([Microsoft.Identity.Client.PublicClientApplication],[Microsoft.Identity.Client.ConfidentialClientApplication])]
    param
    (
        # Identifier of the client requesting the token.
        [parameter(Mandatory=$true, ParameterSetName='PublicClient')]
        [parameter(Mandatory=$false, ParameterSetName='PublicClient-InputObject')]
        [parameter(Mandatory=$true, ParameterSetName='ConfidentialClientSecret')]
        [parameter(Mandatory=$true, ParameterSetName='ConfidentialClientCertificate')]
        [parameter(Mandatory=$false, ParameterSetName='ConfidentialClient-InputObject')]
        [string] $ClientId,
        # Secure secret of the client requesting the token.
        [parameter(Mandatory=$true, ParameterSetName='ConfidentialClientSecret')]
        [parameter(Mandatory=$false, ParameterSetName='ConfidentialClient-InputObject')]
        [securestring] $ClientSecret,
        # Client assertion certificate of the client requesting the token.
        [parameter(Mandatory=$true, ParameterSetName='ConfidentialClientCertificate')]
        [parameter(Mandatory=$false, ParameterSetName='ConfidentialClient-InputObject')]
        [System.Security.Cryptography.X509Certificates.X509Certificate2] $ClientCertificate,
        # Address to return to upon receiving a response from the authority.
        [parameter(Mandatory=$false)]
        [uri] $RedirectUri,
        # Tenant identifier of the authority to issue token.
        [parameter(Mandatory=$false)]
        [string] $TenantId,
        # Address of the authority to issue token.
        [parameter(Mandatory=$false)]
        [uri] $Authority,
        # Public client application options
        [parameter(Mandatory=$true, ValueFromPipeline=$true, ParameterSetName='PublicClient-InputObject', Position=0)]
        [Microsoft.Identity.Client.PublicClientApplicationOptions] $PublicClientOptions,
        # Confidential client application options
        [parameter(Mandatory=$true, ValueFromPipeline=$true, ParameterSetName='ConfidentialClient-InputObject', Position=0)]
        [Microsoft.Identity.Client.ConfidentialClientApplicationOptions] $ConfidentialClientOptions,
        # Create application in cache if it does not already exist
        [parameter(Mandatory=$false)]
        [switch] $CreateIfMissing
    )

    [hashtable] $paramMsalClientApplication = $PSBoundParameters
    if ($paramMsalClientApplication.ContainsKey('CreateIfMissing')) { [void] $paramMsalClientApplication.Remove('CreateIfMissing') }
    $NewClientApplication = New-MsalClientApplication -ErrorAction Stop @paramMsalClientApplication
    switch ($PSCmdlet.ParameterSetName) {
        "PublicClient" {
            [Microsoft.Identity.Client.IPublicClientApplication] $ClientApplication = $PublicClientApplications | Where-Object { $_.ClientId -eq $NewClientApplication.ClientId -and $_.AppConfig.RedirectUri -eq $NewClientApplication.AppConfig.RedirectUri -and $_.AppConfig.TenantId -eq $NewClientApplication.AppConfig.TenantId } | Select-Object -First 1
        }
        "ConfidentialClientSecret" {
            [Microsoft.Identity.Client.IConfidentialClientApplication] $ClientApplication = $ConfidentialClientApplications | Where-Object { $_.ClientId -eq $NewClientApplication.ClientId -and $_.AppConfig.ClientSecret -eq $NewClientApplication.AppConfig.ClientSecret -and $_.AppConfig.RedirectUri -eq $NewClientApplication.AppConfig.RedirectUri -and $_.AppConfig.TenantId -eq $NewClientApplication.AppConfig.TenantId } | Select-Object -First 1
        }
        "ConfidentialClientCertificate" {
            [Microsoft.Identity.Client.IConfidentialClientApplication] $ClientApplication = $ConfidentialClientApplications | Where-Object { $_.ClientId -eq $NewClientApplication.ClientId -and $_.AppConfig.ClientCredentialCertificate -eq $NewClientApplication.AppConfig.ClientCredentialCertificate -and $_.AppConfig.RedirectUri -eq $NewClientApplication.AppConfig.RedirectUri -and $_.AppConfig.TenantId -eq $NewClientApplication.AppConfig.TenantId } | Select-Object -First 1
        }
    }

    if (!$ClientApplication) {
        if ($CreateIfMissing) {
            $ClientApplication = $NewClientApplication
            Write-Verbose ('Adding Application with ClientId [{0}] and
RedirectUri [{1}] to
cache.' -f $ClientApplication.AppConfig.ClientId, $ClientApplication.AppConfig.RedirectUri)
            if ($ClientApplication -is [Microsoft.Identity.Client.IPublicClientApplication]) {
                $PublicClientApplications.Add($ClientApplication)
            }
            else {
                $ConfidentialClientApplications.Add($ClientApplication)
            }
        }
    }
    else {
        Write-Debug ('Application with ClientId [{0}] and RedirectUri [{1}]
already exists. Using application from
cache.' -f $ClientApplication.AppConfig.ClientId, $ClientApplication.AppConfig.RedirectUri)
    }

    return $ClientApplication
}


Contact Us
Terms of Use
Privacy Policy
Gallery Status
Feedback
FAQs
© 2022 Microsoft Corporation