in powershell-agent/src/main/java/jetbrains/buildServer/powershell/agent/detect/registry/RegistryPowerShellDetector.java [72:103]
private Map<String, PowerShellInfo> findCoreEditions() {
Map<String, PowerShellInfo> result = new HashMap<>();
String rootPath = "SOFTWARE\\Microsoft\\PowerShellCore\\InstalledVersions";
for (PowerShellBitness bitness : PowerShellBitness.values()) {
Set<String> keys = myAccessor.listSubKeys(LOCAL_MACHINE, bitness.toBitness(), rootPath);
for (String key : keys) {
String keyPath = rootPath + "\\" + key;
String homeStr = myAccessor.readRegistryText(LOCAL_MACHINE, bitness.toBitness(), keyPath, "InstallLocation");
if (homeStr == null) {
LOG.warn("Could not fetch InstallLocation from " + keyPath);
continue;
}
File home = asDirectoryOrNull(homeStr);
if (home == null) {
LOG.warn("Found InstallLocation is not a valid directory: " + homeStr);
continue;
}
String version = myAccessor.readRegistryText(LOCAL_MACHINE, bitness.toBitness(), keyPath, "SemanticVersion");
if (version == null) {
LOG.warn("Could not fetch SemanticVersion from " + keyPath);
continue;
}
if (new File(home, "pwsh.exe").exists()) {
PowerShellInfo info = new PowerShellInfo(bitness, home, version, PowerShellEdition.CORE, "pwsh.exe");
logFound(info);
result.put(info.getHome().getAbsolutePath(), info);
}
}
}
return result;
}