NavContainerHelper-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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
$ErrorActionPreference = "Stop"

. (Join-Path $PSScriptRoot "NavContainerHelper.ps1")

# This script performs a simple happy-path test of most navcontainerhelper functions

$imageName = "navdocker.azurecr.io/dynamics-nav:11.0.18920.0"
$containerName = "test"

$username = $env:USERNAME
$password = Read-Host -AsSecureString -Prompt "Please enter the admin password for Nav Container"

# TEMP solution: The following files must exist
$licenseFile = "c:\demo\license.flf"

$fobPath = "C:\temp\Test.fob"
$txtPath = "C:\temp\Test.txt"
$deltaPath = "C:\demo\Delta"

$v1AppPath = "C:\temp\Search2.navx"
$v1AppName = "Search"

$v2AppPath = "C:\temp\uns\Search2.app"
$v2AppName = "Search"

docker pull $imageName

# New-CSideDevContainer
New-CSideDevContainer -accept_eula `
                      -containerName $containerName `
                      -devImageName $imageName `
                      -licenseFile $licenseFile `
                      -vmAdminUsername $username `
                      -adminPassword $password `
                      -UpdateHosts `
                      -Auth Windows

# Test-NavContainer
if (Test-NavContainer -containerName $containerName) {
    Write-Host "$containerName is running!"
}

# Get-NavContainerNavVersion
$navVersion = Get-NavContainerNavVersion -containerOrImageName $imageName
Write-Host "Nav Version of $imageName is $navVersion"
$navVersion = Get-NavContainerNavVersion -containerOrImageName $containerName
Write-Host "Nav Version of $containerName is $navVersion"

# Get-NavContainerImageName
$imageName = Get-NavContainerImageName -containerName $containerName
Write-Host "ImageName of $containerName is $imageName"

# Get-NavContainerGenericTag
$tag = Get-NavContainerGenericTag -containerOrImageName $imageName
Write-Host "Generic tag of $imageName is $tag"
$tag = Get-NavContainerGenericTag -containerOrImageName $containerName
Write-Host "Generic tag of $containerName is $tag"

# Get-NavContainerOsVersion
$osversion = Get-NavContainerOsVersion -containerOrImageName $imageName
Write-Host "OS Version of $imageName is $osversion"
$osversion = Get-NavContainerOsVersion -containerOrImageName $containerName
Write-Host "OS Version of $containerName is $osversion"

# Get-NavContainerLegal
$legal = Get-NavContainerLegal -containerOrImageName $imageName
Write-Host "Legal link of $imageName is $legal"
$legal = Get-NavContainerLegal -containerOrImageName $containerName
Write-Host "Legal link of $containerName is $legal"

# Get-NavContainerCountry
$country = Get-NavContainerCountry -containerOrImageName $imageName
Write-Host "Country of $imageName is $country"
$country = Get-NavContainerCountry -containerOrImageName $containerName
Write-Host "Country of $containerName is $country"

# Get-NavContainerIpAddress
$ipAddress = Get-NavContainerIpAddress -containerName $containerName
Write-Host "IP Address of $containerName is $ipAddress"

# Get-NavContainerSharedFolders
$sharedFolders = Get-NavContainerSharedFolders -containerName $containerName
Write-Host "Shared Folders with $containerName are:"
$sharedFolders.GetEnumerator() | % { Write-Host ($_.Name + " -> " + $_.Value) }

# Get-NavContainerPath
$path = "c:\demo\extensions\$containerName\my\AdditionalSetup.ps1"
$containerPath = Get-NavContainerPath -containerName $containerName -path $path
Write-Host "Container Path of $path in $containerName is $containerPath"

# Get-NavContainerId
$containerId = Get-NavcontainerId -containerName $containerName
Write-Host "Id of $containerName is $containerId"

# Get-NavContainerName
$containerName = Get-NavcontainerName -containerId $containerId
Write-Host "Name of $containerId is $containerName"

# Import-ObjectsToNavContainer (.fob)
Import-ObjectsToNavContainer -containerName $containerName `
                             -objectsFile $fobPath

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName

# Import-ObjectsToNavContainer (.txt)
Import-ObjectsToNavContainer -containerName $containerName `
                             -objectsFile $txtPath

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName

# Import-ObjectsToNavContainer (.txt)
Import-DeltasToNavContainer -containerName $containerName `
                            -deltaFolder $deltaPath

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName

# Convert-ModifiedObjectsToAl
Convert-ModifiedObjectsToAl -containerName $containerName `
                            -startId 50100

# Install NavSip
Install-NAVSipCryptoProviderFromNavContainer -containerName $containerName

# App Handling functions v1 extensions
if (Test-Path $v1AppPath) {
    Publish-NavContainerApp -containerName $containerName -appFile $v1AppPath
    Get-NavContainerAppInfo -containerName $containerName
    Install-NavContainerApp -containerName $containerName -appName $v1AppName
    Uninstall-NavContainerApp -containerName $containerName -appName $v1AppName
    Unpublish-NavContainerApp -containerName $containerName -appName $v1AppName
    Get-NavContainerAppInfo -containerName $containerName
}

if (Test-Path $v2AppPath) {
    # App Handling functions v2 extensions
    Publish-NavContainerApp -containerName $containerName -appFile $v2AppPath
    Get-NavContainerAppInfo -containerName $containerName
    Sync-NavContainerApp -containerName $containerName -appName $v2AppName
    Install-NavContainerApp -containerName $containerName -appName $v2AppName
    Uninstall-NavContainerApp -containerName $containerName -appName $v2AppName
    Unpublish-NavContainerApp -containerName $containerName -appName $v2AppName
    Get-NavContainerAppInfo -containerName $containerName
}

# Remove-NavContainer
Remove-NavContainer -containerName $containerName -UpdateHosts

# New-CSideDevContainer
New-CSideDevContainer -accept_eula `
                      -containerName $containerName `
                      -devImageName $imageName `
                      -licenseFile $licenseFile `
                      -vmAdminUsername $username `
                      -adminPassword $password `
                      -UpdateHosts `
                      -Auth NavUserPassword

# Test-NavContainer
if (Test-NavContainer -containerName $containerName) {
    Write-Host "$containerName is running!"
}

# Get-NavContainerNavVersion
$navVersion = Get-NavContainerNavVersion -containerOrImageName $imageName
Write-Host "Nav Version of $imageName is $navVersion"
$navVersion = Get-NavContainerNavVersion -containerOrImageName $containerName
Write-Host "Nav Version of $containerName is $navVersion"

# Get-NavContainerImageName
$imageName = Get-NavContainerImageName -containerName $containerName
Write-Host "ImageName of $containerName is $imageName"

# Get-NavContainerGenericTag
$tag = Get-NavContainerGenericTag -containerOrImageName $imageName
Write-Host "Generic tag of $imageName is $tag"
$tag = Get-NavContainerGenericTag -containerOrImageName $containerName
Write-Host "Generic tag of $containerName is $tag"

# Get-NavContainerOsVersion
$osversion = Get-NavContainerOsVersion -containerOrImageName $imageName
Write-Host "OS Version of $imageName is $osversion"
$osversion = Get-NavContainerOsVersion -containerOrImageName $containerName
Write-Host "OS Version of $containerName is $osversion"

# Get-NavContainerLegal
$legal = Get-NavContainerLegal -containerOrImageName $imageName
Write-Host "Legal link of $imageName is $legal"
$legal = Get-NavContainerLegal -containerOrImageName $containerName
Write-Host "Legal link of $containerName is $legal"

# Get-NavContainerCountry
$country = Get-NavContainerCountry -containerOrImageName $imageName
Write-Host "Country of $imageName is $country"
$country = Get-NavContainerCountry -containerOrImageName $containerName
Write-Host "Country of $containerName is $country"

# Get-NavContainerIpAddress
$ipAddress = Get-NavContainerIpAddress -containerName $containerName
Write-Host "IP Address of $containerName is $ipAddress"

# Get-NavContainerSharedFolders
$sharedFolders = Get-NavContainerSharedFolders -containerName $containerName
Write-Host "Shared Folders with $containerName are:"
$sharedFolders.GetEnumerator() | % { Write-Host ($_.Name + " -> " + $_.Value) }

# Get-NavContainerPath
$path = "c:\demo\extensions\$containerName\my\AdditionalSetup.ps1"
$containerPath = Get-NavContainerPath -containerName $containerName -path $path
Write-Host "Container Path of $path in $containerName is $containerPath"

# Get-NavContainerId
$containerId = Get-NavcontainerId -containerName $containerName
Write-Host "Id of $containerName is $containerId"

# Get-NavContainerName
$containerName = Get-NavcontainerName -containerId $containerId
Write-Host "Name of $containerId is $containerName"

# Import-ObjectsToNavContainer (.fob)
Import-ObjectsToNavContainer -containerName $containerName `
                             -objectsFile $fobPath `
                             -adminPassword $password

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName `
                              -adminPassword $password

# Import-ObjectsToNavContainer (.txt)
Import-ObjectsToNavContainer -containerName $containerName `
                             -objectsFile $txtPath `
                             -adminPassword $password

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName `
                              -adminPassword $password

# Convert-ModifiedObjectsToAl
Convert-ModifiedObjectsToAl -containerName $containerName `
                            -adminPassword $password `
                            -startId 50100

# Remove-NavContainer
Remove-NavContainer -containerName $containerName -UpdateHosts


#help Get-NavContainerNavVersion -full
#help Get-NavContainerImageName -full
#help Get-NavContainerGenericTag -full
#help Get-NavContainerOsVersion -full
#help Get-NavContainerLegal -full
#help Get-NavContainerCountry -full
#help Get-NavContainerIpAddress -full
#help Get-NavContainerSharedFolders -full
#help Get-NavContainerPath -full
#help Get-NavContainerName -full
#help Get-NavContainerId -full
#help Test-NavContainer -full
#help New-CSideDevContainer -full
#help New-NavContainer -full
#help Remove-NavContainer -full
#help Get-NavContainerSession -full
#help Remove-NavContainerSession -full
#help Enter-NavContainer -full
#help Open-NavContainer -full
#help Wait-NavContainerReady -full
#help Import-ObjectsToNavContainer -full
#help Compile-ObjectsInNavContainer -full
#help Export-NavContainerObjects -full
#help Create-MyOriginalFolder -full
#help Create-MyDeltaFolder -full
#help Convert-Txt2Al -full
#help Convert-ModifiedObjectsToAl -full
#help Publish-NavContainerApp -full
#help Sync-NavContainerApp -full
#help Install-NavContainerApp -full
#help Uninstall-NavContainerApp -full
#help Unpublish-NavContainerApp -full
#help Get-NavContainerAppInfo -full
#help Install-NAVSipCryptoProviderFromNavContainer -full
#help Replace-NavServerContainer -full
#help Recreate-NavServerContainer -full

Clear-Variable -Name "password"