| 7 | script: string = ""; |
| 8 | |
| 9 | getLatestModuleScript(moduleName: string): string { |
| 10 | const command: string = `Get-Module -Name ${moduleName} -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1`; |
| 11 | this.script += `try { |
| 12 | $ErrorActionPreference = "Stop" |
| 13 | $WarningPreference = "SilentlyContinue" |
| 14 | $output = @{} |
| 15 | $data = ${command} |
| 16 | $output['${Constants.AzVersion}'] = $data.Version.ToString() |
| 17 | $output['${Constants.Success}'] = "true" |
| 18 | } |
| 19 | catch { |
| 20 | $output['${Constants.Error}'] = $_.exception.Message |
| 21 | } |
| 22 | return ConvertTo-Json $output`; |
| 23 | core.debug(`GetLatestModuleScript: ${this.script}`); |
| 24 | return this.script; |
| 25 | } |
| 26 | |
| 27 | checkModuleVersionScript(moduleName: string, version: string) { |
| 28 | const command: string = `Get-Module -Name ${moduleName} -ListAvailable | Where-Object Version -match ${version}`; |