cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
azhockeynut
Pilgrim

Powershell CA not logging or reading properties

I am launching a powershell CA from the click of a button, it sends me an email thru office 365. not a problem(I have an inbox full!)
I am trying to get PS to read either string values or properties, or both, so I can have a user fill in all of the info, then it sends on the button push of the form.

If I hard code the connection and mail info everything is fine. If I try to set it to read properties or strings, I get empty strings, yes there are values in there...I checked in the IS log.
Speaking of which.....The trace-suiteinfo -LogMessage does not log a thing in my log when I click show logs, I see that it launched the CA, and I get the email, so I know that worked.
I further tested by setting the subject line to each var, (the property one and the string one) both were blank in tests.

what am I missing? anyone have an example of a simple PS script that works to retrieve what I want and use it?
Thanks!!!


Powershell code snippet

Set-ExecutionPolicy Unrestricted -force
trace-suiteinfo -LogMessage "POWERSHELL:INFO - Going to try and retrieve NEW_STRING24"
$PropVal = get-suiteproperty -name SMTP_NETWORK_HOST
$StringValue = resolve-suitestring -StringId NEW_STRING24
trace-suiteinfo -LogMessage $StringValue
trace-suiteinfo -LogMessage $PropVal


$emailSmtpServer = "smtp.office365.com"
$emailSmtpServerPort = "587"
$emailSmtpUser = "myuser@mydomain.com"
$emailSmtpPass = "MyPass"

$emailFrom = "myemail@mydomain.com"
$emailTo = "mymail@myotherdomain.com"

$emailMessage = New-Object System.Net.Mail.MailMessage( $emailFrom , $emailTo )
$emailMessage.Subject = "Subject is: " + $StringVal + " -- Propval: " + $PropVal
$emailMessage.IsBodyHtml = $true
$emailMessage.Body = @"

Let us see if this works from IS CA....


Here is a message that is HTML formatted.


"@

$SMTPClient = New-Object System.Net.Mail.SmtpClient( $emailSmtpServer , $emailSmtpServerPort )
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass );

$SMTPClient.Send( $emailMessage )
exit(0)
Labels (1)
0 Kudos
3 Replies
azhockeynut
Pilgrim

Re: Powershell CA not logging or reading properties

I debugged a bit further, the error makes sense, the cmdlet is not recognized, so what is the namespace of that?

The term 'trace-suiteinfo' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path....
0 Kudos
kdsharma
Flexera beginner

Re: Powershell CA not logging or reading properties

Hi @azhockeynut 

You are correct. It seems the 'trace-suiteinfo' cmdlet is not identified. It requires including of a particular Assembly to the script. I am also searching on the same. The blank values of properties is due to the failure of the execution of script. 

I think it needs to be raised as a bug with Flexera to get it work.

Please let me know if it works for you

Thanks

0 Kudos
Flexera Jenifer
Flexera

Re: Powershell CA not logging or reading properties

Hi @kdsharma ,

 

Which project type you using?Is it Suite/Basic MSI?

If you are executing specific PowerShell custom action via DoAction event it might not work as per Windows limitation.

Please refer:

https://community.flexera.com/t5/InstallShield-Knowledge-Base/PowerShell-Trace-info-Cmdlet-Does-Not-...

 

As well i could set property as well using :

set-property -name CXS_IP_LOCAL -value $localIpAddress assuming property is been created via Property Manager in basic msi project's custom action as mentioned in the KB:

https://community.flexera.com/t5/InstallShield-Knowledge-Base/PowerShell-cmdlet-get-property-used-in...

 

Thanks,

Jenifer

0 Kudos