I am currently working on a powershell script that maps directories along with loading database software. I have this current vbscript I am converting to powershell that is suppose to validate a temporary file path , but I am getting a little confused on what I may need to take out and what I can leave in.
Here is the original vbscript ...
'
' assure that temp version of Perl is used
'
perlPath = basePath & "install\perl\bin;"
WshShell.Environment("Process")("PATH") = perlPath & WshShell.Environment("System")("PATH")
'
' assure that temp version of Perl Lib is used
'
perlLib = basePath & "\install\perl\lib;" & basePath & "\install\perl\site\lib;"
WshShell.Environment("Process")("PERL5LIB") = perlLib
Here is what I have written in powershell so far ...
#
# assure that Oracle's version of Powershell is used
#
$psPath = $basePath + "install\powershell\bin;"
$sysPath = $WshShell.Environment("System") | Where-Object { $_ -match "PATH" } |
foreach-object {$_.Substring(9)} | Out-String
$psPos = $sysPath.contains($psPath)
if( -not ($psPos)){
[Environment]::SetEnvironmentVariable("PATH", ($psPath + $sysPath), "Process")
}
#
# assure that Oracle's version of Powershell Module is used
#
$psMod = $homePath + "\perl\lib;" + $homePath + "\perl\site\lib;" # still need to convert
$sysMod = $Env:PSModulePath
$psPos = $sysMod.contains($psMod)
if( -not ($psPos)){
[Environment]::SetEnvironmentVariable("PATH", ($psPath + $sysChk), "Process")
}}
The same validation is done later in the script with the "System" variables. I do have a module that I will be using, but the rest are scripts. I guess I am not sure if what I am converting is the right way to verify these pathways exist and if not to add the new pathways.