cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DLee65
Level 13

set-suiteproperty fails

I am running into a problem on WIndows 7 x86 using a PowerShell script where set-suiteproperty is failing to set a property. This is working on Windows Vista x64 in my testing. Both are clean systems - with the exception that I installed powershell on Windows Vista.

On Windows 7 x86, just before the statement for set-suiteproperty -name RUNSQLSETUP -value $true, I successfully write trace-suiteinfo -LogMessage "POWERSHELL:INFO - Named instance not found, RUNSQLSETUP property set to true"
However, a subsequent trace-suiteinfo message DOES not write to the log. So it appears that something causes the action to exit.

On vista x64 everything writes correctly to the log file and the properties are all correctly set. So I believe I have the syntax set correctly. I tried manually setting the execution policy for powershell to remotesigned just in case it might be related, however, that did not change the behavior.

Ultimately, this PowerShell function will be replace by a C++ dll call, but in the interim period I would like to get this to work.
if ($namedInstance -eq $null)
{
#instance not installed, return false, sql server 2012 needs to be installed
#return false
trace-suiteinfo -LogMessage "POWERSHELL:INFO - Named instance not found, RUNSQLSETUP property set to true"
set-suiteproperty IsSQLBetterEdition $false
set-suiteproperty -name RUNSQLSETUP -value $true
set-suiteproperty -name SupportedSqlText -value $strNewSQLInstallText
trace-suiteinfo -LogMessage $strNewSQLInstallText
Exit(0)
}
Labels (1)
0 Kudos
(4) Replies
DLee65
Level 13

Ahh, I think I see the error in the code. I am lacking the switch -name IsSQLBetterEdition and -value $false on the first line following the trace-suiteinfo.
Why this works in Windows Vista x64 I am not certain.
0 Kudos
DLee65
Level 13

Something else must be wrong.
I adjusted my code and still it will not set properties, it exists on trying to set the first property. Any action up to setting the first property is fine.
I can read the registry, set variables, modify variables, etc.

So my guess that why this works on Vista is that the name and value arguments are positional arguments.
My updated code is this:
if ($namedInstance -eq $null)
{
#instance not installed, return false, sql server 2012 needs to be installed
#return false
trace-suiteinfo -LogMessage "POWERSHELL:INFO - Named instance not found, RUNSQLSETUP property set to true"
trace-suiteinfo -LogMessage "POWERSHELL:INFO Testing for more changes"
set-suiteproperty -name IsSQLBetterEdition -value $False
trace-suiteinfo -LogMessage "POWERSHELL:INFO - Property 'IsSQLBetterEdition' should now be set to False"
set-suiteproperty -name RUNSQLSETUP -value $True
set-suiteproperty -name SupportedSqlText -value $strNewSQLInstallText
trace-suiteinfo -LogMessage $strNewSQLInstallText
Exit(0)
}

This is Windows 7 x86 SP1 and it should not have any problems executing this code segment.
With this modification the second trace-suiteinfo message will print to the log file. However 'IsSQLBetterEdition' does not and the third trace-suiteinfo does not.

Return results on Vista are as follows:
1-8-2014[01:32:39 PM]: (PowerShell Action): Attempting to load through CLR 4 APIs...
1-8-2014[01:32:39 PM]: (PowerShell Action): Loaded CLR successfully
1-8-2014[01:32:39 PM]: (PowerShell Action): POWERSHELL:INFO Attempting to determine SQL Server Installed version
1-8-2014[01:32:39 PM]: (PowerShell Action): POWERSHELL:INFO - Named instance not found, RUNSQLSETUP property set to true
1-8-2014[01:32:39 PM]: (PowerShell Action): POWERSHELL:INFO Testing for more changes
1-8-2014[01:32:39 PM]: Engine: property 'IsSQLBetterEdition' value now 'False'
1-8-2014[01:32:39 PM]: (PowerShell Action): POWERSHELL:INFO - Property 'IsSQLBetterEdition' should now be set to False
1-8-2014[01:32:39 PM]: Engine: property 'RUNSQLSETUP' value now 'True'
1-8-2014[01:32:39 PM]: (PowerShell Action): set-suiteproperty -name RUNSQLSETUP -value True
1-8-2014[01:32:39 PM]: Engine: property 'SupportedSqlText' value now 'Microsoft SQL Server 2012 Express will be installed and configured to be used with Amazing Charts.'
1-8-2014[01:32:39 PM]: (PowerShell Action): Microsoft SQL Server 2012 Express will be installed and configured to be used with Amazing Charts.
1-8-2014[01:32:39 PM]: Action returned value 0x00000000


Windows 7:
1-8-2014[01:25:41 PM]: (PowerShell Action): Attempting to load through CLR 4 APIs...
1-8-2014[01:25:41 PM]: (PowerShell Action): Getting meta host...
1-8-2014[01:25:41 PM]: (PowerShell Action): Loaded CLR successfully
1-8-2014[01:25:41 PM]: (PowerShell Action): POWERSHELL:INFO Attempting to determine SQL Server Installed version
1-8-2014[01:25:41 PM]: (PowerShell Action): POWERSHELL:INFO - Named instance not found, RUNSQLSETUP property set to true
1-8-2014[01:25:41 PM]: (PowerShell Action): POWERSHELL:INFO Testing for more changes
1-8-2014[01:25:41 PM]: Action returned value 0x00000000


I am going to attempt this process with a simplified project and PowerShell script and see what happens. What bothers me is that the same code executes successfully on Vista but not on Windows 7.
I installed PowerShell 3.0 on Windows 7 but my results deteriorated.
0 Kudos
DLee65
Level 13

I started a new project this morning with a very basic Suite project that just adds the orca.msi and a powershell script in onbegin.
The following code fails with powershell 3.0 installed on Windows 7x86 professional sp1. I am in the process of creating a Windows 7x64 Ultimate sp1 image and testing in that environment. First I will test with PowerShell 2.0 installed and then upgrade to 3.0. The code fails with the line $result = Test-Path -Path $key

If I substitute the suite specific code with comments and insert write-host statements the code will execute without errors in the ISE environment.
So it appears that the InstallShield engine has some problem with executing some of the PowerShell statements like "Test-Path" But without Test-Path my other statements fail because I need to test that registry paths exist prior to calling Get-ItemProperty or that too errors out.

What I do not understand is that all of this is working in Vista x64. I have not attempted other operating systems yet.
trace-suiteinfo -LogMessage "POWERSHELL: INFO Testing the Powershell interface"
set-suiteproperty -name IsSQLBetterEdition -value $False
trace-suiteinfo -LogMessage "Checking for registry key: hklm:software\microsoft\microsoft sql server\instance names\sql"
$key = "HKLM:software\microsoft\microsoft sql server\instance names\sql"
$result = Test-Path -Path $key
trace-suiteinfo -LogMessage "POWERSHELL: INFO Test-Path result: $result"
if ($result)
{
trace-suiteinfo -LogMessage "POWERSHELL: INFO Test-Path $key FOUND"
return (Get-ItemProperty $key -name "AMAZINGCHARTS")."AMAZINGCHARTS"
}
else
{
trace-suiteinfo -LogMessage "SQL Server AMAZINGCHARTS instance not found"
return $null
}
0 Kudos
DLee65
Level 13

It appears that my image of Windows 7x86 may be bad. I downloaded a new ISO from MSDN and installed Windows 7x86 Ultimate sp1 and it is working as I would expect.
I did the same for Windows 7x64 Ultimate sp1 and it works as I would expect.
I am going to repeat the process for Windows 7x86 Professional and see if there is any difference. There should not be. I wonder if my image was a upgrade from Windows 7 x86 RC to SP1.

In any case, it appears to be the operating system and not my code, and that makes it very bad for testing *sigh*, because QA reported unusual bugs that got me on to this path of looking into this issue. Now I have to go to QA and say that their operating system may be suspect.

At least I know that the PowerShell code is not intended for release.
0 Kudos