@@ -91,15 +91,59 @@ function New-AzDataMigrationLoginsMigration
91
91
# Testing Whether Console App is downloaded or not
92
92
$TestExePath = Test-Path - Path $ExePath ;
93
93
94
+ # Console app download address
95
+ $ZipSource = " https://sqlassess.blob.core.windows.net/app/LoginsMigration.zip" ;
96
+ $ZipDestination = Join-Path - Path $BaseFolder - ChildPath " LoginsMigration.zip" ;
97
+
94
98
# Downloading and extracting LoginsMigration Zip file
95
99
if (-Not $TestExePath )
96
100
{
97
- $ZipSource = " https://sqlassess.blob.core.windows.net/app/LoginsMigration.zip " ;
98
- $ZipDestination = Join-Path - Path $BaseFolder - ChildPath " LoginsMigration.zip " ;
101
+ # Downloading and extracting LoginMigration Zip file
102
+ Write-Host " Downloading and extracting latest LoginMigration Zip file... "
99
103
Invoke-RestMethod - Uri $ZipSource - OutFile $ZipDestination ;
100
-
101
104
Expand-Archive - Path $ZipDestination - DestinationPath $BaseFolder - Force;
102
105
}
106
+ else
107
+ {
108
+ # Get local exe version
109
+ Write-Host " Checking installed Login.Console.exe version..." ;
110
+ $installedVersion = (Get-Item $ExePath ).VersionInfo.FileVersion;
111
+ Write-Host " Installed version: $installedVersion " ;
112
+
113
+ # Get latest console app version
114
+ Write-Host " Checking whether there is newer version..." ;
115
+ $VersionFileSource = " https://sqlassess.blob.core.windows.net/app/loginconsoleappversion.json" ;
116
+ $VersionFileDestination = Join-Path - Path $BaseFolder - ChildPath " loginconsoleappversion.json" ;
117
+ Invoke-RestMethod - Uri $VersionFileSource - OutFile $VersionFileDestination ;
118
+ $jsonObj = Get-Content $VersionFileDestination | Out-String | ConvertFrom-Json ;
119
+ $latestVersion = $jsonObj.version ;
120
+
121
+ # Compare the latest exe version with the local exe version
122
+ if ([System.Version ]$installedVersion -lt [System.Version ]$latestVersion )
123
+ {
124
+ Write-Host " Found newer version of Logins.Console.exe '$latestVersion '" ;
125
+
126
+ Write-Host " Removing old Logins.Console.exe..."
127
+ # Remove old zip file
128
+ Remove-Item - Path $ZipDestination ;
129
+
130
+ # Remove existing folder and contents
131
+ $ConsoleAppDestination = Join-Path - Path $BaseFolder - ChildPath " Logins.Console.csproj" ;
132
+ Remove-Item - Path $ConsoleAppDestination - Recurse;
133
+
134
+ # Remove version file
135
+ Remove-Item - Path $VersionFileDestination ;
136
+
137
+ # Downloading and extracting LoginMigration Zip file
138
+ Write-Host " Downloading and extracting latest LoginMigration Zip file..."
139
+ Invoke-RestMethod - Uri $ZipSource - OutFile $ZipDestination ;
140
+ Expand-Archive - Path $ZipDestination - DestinationPath $BaseFolder - Force;
141
+ }
142
+ else
143
+ {
144
+ Write-Host " Installed Logins.Console.exe is the latest one..." ;
145
+ }
146
+ }
103
147
104
148
# Collecting data
105
149
if ((' CommandLine' ) -contains $PSCmdlet.ParameterSetName )
0 commit comments