MCPcopy Create free account
hub / github.com/Azure/powershell / checkModuleVersionScript

Method checkModuleVersionScript

src/Utilities/ScriptBuilder.ts:27–43  ·  view source on GitHub ↗
(moduleName: string, version: string)

Source from the content-addressed store, hash-verified

25 }
26
27 checkModuleVersionScript(moduleName: string, version: string) {
28 const command: string = `Get-Module -Name ${moduleName} -ListAvailable | Where-Object Version -match ${version}`;
29 this.script += `try {
30 $ErrorActionPreference = "Stop"
31 $WarningPreference = "SilentlyContinue"
32 $output = @{}
33 $data = ${command}
34 $output['${Constants.versionExists}'] = [string]::IsNullOrEmpty($data)
35 $output['${Constants.Success}'] = "true"
36 }
37 catch {
38 $output['${Constants.Error}'] = $_.exception.Message
39 }
40 return ConvertTo-Json $output`;
41 core.debug(`CheckModuleVersionScript: ${this.script}`);
42 return this.script;
43 }
44
45 getInlineScriptFile(inlineScript: string, errorActionPreference: string) {
46 this.script = `$ErrorActionPreference = '${errorActionPreference}'${os.EOL}${inlineScript}`

Callers 1

checkModuleVersionMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected