Created
February 19, 2024 15:41
-
-
Save tkouba/c023aa272032b84efd43794717cc66ca to your computer and use it in GitHub Desktop.
Get Kepware KEPServerEX V6 configuration root dirwectory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#PSScriptInfo | |
.VERSION 1.0 | |
.GUID d1e5442a-c2cf-403d-a4f9-e4a54b4886bd | |
.AUTHOR Tomas Kouba | |
.COMPANYNAME Axians CZ | |
.COPYRIGHT (c) 2024 Axians CZ. All rights reserved. | |
.TAGS | |
.LICENSEURI | |
.PROJECTURI | |
.ICONURI | |
.EXTERNALMODULEDEPENDENCIES | |
.REQUIREDSCRIPTS | |
.EXTERNALSCRIPTDEPENDENCIES | |
.RELEASENOTES | |
#> | |
<# | |
.SYNOPSIS | |
Get KEPServerEX configuration root directory. | |
.DESCRIPTION | |
Get KEPServerEX configuration root directory. Relative path to KEPServerEX V6 configuration directory from root is '\Kepware\KEPServerEX\V6' | |
.INPUTS | |
NONE | |
.OUTPUTS | |
NONE | |
.EXAMPLE | |
C:\PS> .\Get-KepwareConfigRoot | |
Description | |
----------- | |
Get KEPServerEX configuration root directory. | |
.NOTES | |
Version : 1.0, 2024-02-19 | |
Requires : PowerShell | |
.LINK | |
#> | |
[CmdletBinding()] | |
Param( | |
) | |
PROCESS { | |
#disable debug confirmation messages | |
if($PSBoundParameters['Debug']){$DebugPreference = "Continue"} | |
try { | |
# Relative path to KEPServerEX V6 configuration directory from root is | |
#$kepSubDir = '\Kepware\KEPServerEX\V6' | |
# Detect KEPServerEX configuration root from registry (running configuration) | |
if (-not $ConfigRoot) { | |
$regPath = 'HKLM:\SOFTWARE\Kepware\KEPServerEX\V6\Install', 'HKLM:\SOFTWARE\WOW6432Node\Kepware\KEPServerEX\V6\Install' | Where-Object { Test-Path -Path $_ } | |
if ($regPath) { | |
$ConfigRoot = (Get-ItemProperty -Path $regPath).AppDataPath | |
Write-Verbose "Set config root to default $ConfigRoot" | |
} else { | |
Write-Error "Kepware KEPServerEX registry entry not found." | |
break | |
} | |
} | |
return $ConfigRoot | |
} | |
catch { | |
#show error message (non terminating error so that the rest of the pipe input get processed) | |
Write-Error $_ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment