Tests/AzureAD/test.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
93
94
95
96
97
98
99
100
101
102

Remove-NavContainer nav2018 -ErrorAction Ignore
Remove-NavContainer nav2017 -ErrorAction Ignore
Remove-NavContainer nav2016 -ErrorAction Ignore

$githubFolder = "C:\Users\freddyk\Documents\GitHub\Microsoft\nav-docker\Run"
$dt = [DateTime]::new(2018,2,5)
$files = @()
Get-ChildItem -Path $githubFolder -Recurse -File | % {
    if ($_.LastWriteTimeUtc.CompareTo($dt) -gt 0) {
        if (!($_.name.Contains("SetupWebClient") -or $_.name.Contains("SetupClickOnce"))) {
            $files += $_.FullName
        }
        Write-Host ("Override " + $_.FullName.SubString($githubFolder.Length+1))
    }
}

$files
if ($Credential -eq $null -or $credential -eq [System.Management.Automation.PSCredential]::Empty) {
    $credential = get-credential -UserName $env:USERNAME -Message "Using Windows Authentication. Please enter your Windows credentials."
}

$protocol = "http://"
$https = ($protocol -eq "https://")

$AadAdminCredential = New-Object System.Management.Automation.PSCredential ( "admin@navdemo15.onmicrosoft.com", (ConvertTo-SecureString -String "Pepsimax4ever" -AsPlainText -Force) )
$containerName = "nav2018"
$nav2018appProperties = Create-AadAppsForNavContainer -AadAdminCredential $AadAdminCredential `
                                              -appIdUri "$protocol$containerName/nav/" `
                                              -iconPath "c:\temp\nav.png"

$files2018 = $files
$files2018 += "C:\Users\freddyk\Documents\GitHub\Microsoft\nav-docker\Run\110\SetupWebClient.ps1"
$files2018 += "C:\Users\freddyk\Documents\GitHub\Microsoft\nav-docker\Run\110\SetupClickOnce.ps1"
New-NavContainer -accept_eula `
                 -containerName $containerName `
                 -Credential $Credential `
                 -authenticationEMail $AadAdminCredential.UserName `
                 -auth aad `
                 -usessl:$https `
                 -imageName "microsoft/dynamics-nav:2018" `
                 -updateHosts `
                 -includeCSide `
                 -additionalParameters @("-e clickonce=Y") `
                 -doNotExportObjectsToText `
                 -myScripts $files2018

$containerName = "nav2017"
$nav2017appProperties = Create-AadAppsForNavContainer -AadAdminCredential $AadAdminCredential `
                                              -appIdUri "$protocol$containerName/nav/webclient/" `
                                              -iconPath "c:\temp\nav.png"

$files2017 = $files
$files2017 += "C:\Users\freddyk\Documents\GitHub\Microsoft\nav-docker\Run\100\SetupWebClient.ps1"
$files2017 += "C:\Users\freddyk\Documents\GitHub\Microsoft\nav-docker\Run\100\SetupClickOnce.ps1"
New-NavContainer -accept_eula `
                 -containerName $containerName `
                 -Credential $Credential `
                 -authenticationEMail $AadAdminCredential.UserName `
                 -auth aad `
                 -usessl:$https `
                 -imageName "microsoft/dynamics-nav:2017" `
                 -updateHosts `
                 -includeCSide `
                 -additionalParameters @("-e clickonce=Y") `
                 -doNotExportObjectsToText `
                 -myScripts $files2017

$containerName = "nav2016"
$nav2016appProperties = Create-AadAppsForNavContainer -AadAdminCredential $AadAdminCredential `
                                              -appIdUri "$protocol$containerName/nav/webclient/" `
                                              -iconPath "c:\temp\nav.png" 

$files2016 = $files
$files2016 += "C:\Users\freddyk\Documents\GitHub\Microsoft\nav-docker\Run\90\SetupWebClient.ps1"
$files2016 += "C:\Users\freddyk\Documents\GitHub\Microsoft\nav-docker\Run\90\SetupClickOnce.ps1"
New-NavContainer -accept_eula `
                 -containerName $containerName `
                 -Credential $Credential `
                 -authenticationEMail $AadAdminCredential.UserName `
                 -auth aad `
                 -usessl:$https `
                 -imageName "microsoft/dynamics-nav:2016" `
                 -updateHosts `
                 -includeCSide `
                 -additionalParameters @("-e clickonce=Y") `
                 -doNotExportObjectsToText `
                 -myScripts $files2016

#Configure-NavContainerForAadAuth -containerName $containerName `
# -NavAdminUsername $env:USERNAME `
# -AadAdminUsername $AadAdminCredential.UserName `
# -ssoAdAppId $AdProperties.SsoAdAppId `
# -SsoAdAppKeyValue $AdProperties.SsoAdAppKeyValue `
# -ExcelAdAppId $AdProperties.ExcelAdAppId `
# -PowerBiAdAppId $AdProperties.PowerBiAdAppId `
# -PowerbIAdAppKeyValue $AdProperties.PowerBiAdAppKeyValue
#
#docker restart $containerName
#
#Start-Process -FilePath "C:\Program Files (x86)\Internet Explorer\iexplore.exe" -ArgumentList "-private https://$containerName/NAV/WebClient"