Andrey.Burda
Posts: 23
Joined: Tue Dec 14, 2021 12:06 pm

Dynamic property name for AI_GetMsiProperty

Tue Jan 25, 2022 8:58 am

Hello,

I want to pass in a dynamic value for AI_GetMsiProperty inside the Power Shell inline script (execution time is set to Immediately) but it does not work.

General aim is to get a folder path inside the loop by calculating a property name from "Files and Folders".

For instance I haver a folder "TestApi" and "TestApi1", the identifiers generated by AI are: TestApi_Dir and TestApi1_Dir.
I have a comma separated string with a list of folder names in custom property - MIGRATION_SERVICES. It value is "TestApi,TestApi1".

In Power Shell script I do the following:

Code: Select all

$migrationServices = AI_GetMsiProperty MIGRATION_SERVICES

$migrationServices.Split(",") | ForEach-Object {
  $dirName = $_ + "_Dir"
  $Path = AI_GetMsiProperty $dirName
  if ($Path -ne '') {
  }
}
exit 0
$dirName is set to: TestApi_Dir and TestApi1_Dir.
The problem is that $Path is always empty, but this line will return a correct path: $Path = AI_GetMsiProperty TestApi_Dir

I wonder what I missed?

Regards,
Andrey

Catalin
Posts: 4929
Joined: Wed Jun 13, 2018 7:49 am

Re: Dynamic property name for AI_GetMsiProperty

Wed Jan 26, 2022 5:00 pm

Hello Andrey,

Please note that the AI_GetMsiProperty cmdlet cand only be used with installer properties.

In your case, $dirName is a variable, not an installer property.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Andrey.Burda
Posts: 23
Joined: Tue Dec 14, 2021 12:06 pm

Re: Dynamic property name for AI_GetMsiProperty

Thu Jan 27, 2022 3:44 pm

Hi Catalin,

Thanks for the reply.
Is there any way to receive AI properties in Powershell script a bit more dynamically, for instance by string name ?

Regards,
Andrey

Catalin
Posts: 4929
Joined: Wed Jun 13, 2018 7:49 am

Re: Dynamic property name for AI_GetMsiProperty

Mon Jan 31, 2022 9:42 am

Hello Andrey,

You can first retrieve the property into a variable and then pass the value to another variable, something like this:

Code: Select all

$var = AI_GetMsiProperty SOME_PROPERTY
$var2 = $var

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Andrey.Burda
Posts: 23
Joined: Tue Dec 14, 2021 12:06 pm

Re: Dynamic property name for AI_GetMsiProperty

Tue Feb 01, 2022 11:21 am

Hi Catalin,

Unfortunately, I have a string name of the property and I want to get it value that set in AI Properties.
Looks like PowerShell inline script is not my option at all.

Regards,
Andrey

Catalin
Posts: 4929
Joined: Wed Jun 13, 2018 7:49 am

Re: Dynamic property name for AI_GetMsiProperty

Tue Feb 01, 2022 2:48 pm

Hello Andrey,

Perhaps I am misunderstanding something here.

So, you have the name of the property stored in a variable, e.g.:

$var = "MY_PROP"

and then you want to retrieve the value of "MY_PROP" into another variable, e.g.:

Code: Select all

$var2 = AI_GetMsiProperty $var
where $var would eventually be replaced by "MY_PROP" and then $var2 would have the value of "MY_PROP"?

Is this what you are trying to achieve? If this is the case, then I'm afraid this might not be possible with the AI_GetMsiProperty cmdlet.

However, there might be another way, through the Get-Property cmdlet (which we recently added), e.g.:

Code: Select all

$var = "MY_PROP"

$var2 = Get-Property -name $var
Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Andrey.Burda
Posts: 23
Joined: Tue Dec 14, 2021 12:06 pm

Re: Dynamic property name for AI_GetMsiProperty

Tue Feb 01, 2022 3:34 pm

Hi Catalin,

Seems that "Get-Property cmdlet" is what I need.
Thanks a lot!

Regards,
Andrey

Catalin
Posts: 4929
Joined: Wed Jun 13, 2018 7:49 am

Re: Dynamic property name for AI_GetMsiProperty

Tue Feb 01, 2022 3:50 pm

You are always welcome, Andrey!

Glad I could help.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”