I am running '4.1.5'
The issue i am running into is i can not for the life of me figure out how to pass parameters to a powershell script i need to execute via PSADT
what im trying to do is run the Log4j update for Opentext Actuate11
The update requires two powershell scripts to be ran a prepare.ps1 and a replace_log4j.ps1
I am able to run the prepare.ps1 in the Pre-install step using
Try {
$PathToPs1File = "$($adtSession.DirFiles)\log4j-jar-updater2-mbir-iserver\powershell\prepare.ps1"
##&$PathToPs1File
} Catch {
Invoke-ADTFunctionErrorHandler -Cmdlet 'MyStandAloneScript' -SessionState $ExecutionContext.SessionState -ErrorRecord $_ -LogMessage "The StandAloneScript failed to run"
}
But then i need to run the following command and can not get anything to work using Start-ADTProcess, The file is in the default files location
$($adtSession.DirFiles)\log4j-jar-updater2-mbir-iserver\powershell\replace_log4j.ps1 -Directory -Version
$($adtSession.DirFiles)\log4j-jar-updater2-mbir-iserver\powershell\replace_log4j.ps1 -Directory "C:\Program Files (x86)\Actuate11" -Version 11SP6
i also think another issue im having is if i set the Varibles via the Replace script and try to run it Calling it with & im getting this error because it cant find the files it needs to reference
It should be possible to simply run your scripts within the PSADT script by prefixing the path with a dot and space (at least that is how I used to run a .ps1 script in an earlier PSADT 3.10.1 script of mine):
. "$($adtSession.DirFiles)\log4j-jar-updater2-mbir-iserver\powershell\prepare.ps1"
and
. "$($adtSession.DirFiles)\log4j-jar-updater2-mbir-iserver\powershell\replace_log4j.ps1" -Directory "C:\Program Files (x86)\Actuate11" -Version 11SP6
1 Like
@Adrian_Scott I'd recommend the ampersand (&) operator over the dot-source operator most of the time as it creates a new scope for the script, whereas the dot-source operator will run the code as if it's typed directly in the script, which could clobber variables or otherwise make a mess.
@Davidtoole1 in your code above, you show a path to the CSV starting with ..\. This path is going to be relevant to whatever your current working directory is ($PWD.Path) and not so much the script. If you need it to be relative to the script, start your path off with $PSScriptRoot. If it's in Files or SupportFiles, you can use $adtSession.DirFiles or $adtSession.DirSupportFiles, respectively.
2 Likes