Still having an issue with Powershell. I am trying to run a PowerShell script shortly after starting my installer. SetupBuilder copies the script to a temporary folder %TEMP%\FacilityDocs and then calls for it shortly after. I am able to get the script to run fine if I just copy the command into a regular PowerShell prompt but I cannot get it to run properly using SetupBuilder’s “Run Program”. I have attached a screencap of my current settings and the error I’m getting when trying to run the installer. This is the command that is being run (it got cut off in the screencap):

Start-Process PowerShell -ArgumentList "-ExecutionPolicy Bypass -File $Env:Tmp\Facilitydocs\PreCheck.ps1" -Verb RunAs

Name:  screen print.png
Views: 543
Size:  22.7 KB
Name:  frmReadMail_Attachment.jpg
Views: 698
Size:  1.1 KB

Below is the PowerShell script in case it would help. This script must run elevated.

<### New Environment variable notes:

FDinstall: Continue/Cancel
- Indicates whether SetupBuilder will continue or cancel install after this "Pre-Check" script is run

NETstat: (Pass/Fail)
- Indicates whether the .NET framework is installed
NETvers: (Pass/Fail)
- Indicates whether the .NET framework is on the required version or newer
NETRSreq: (Yes/No)
- Indicates whether the installation of .NET will require SetupBuilder to execute a restart command

SQLbrDefStat: (Variable)
- SQLBrowser default (existing) status in case the installer is cancelled (to revert to old settings)
SQLbrDefStartup: (Variable)
- SQLBrowser default (existing) startup mode in case the installer is cancelled (to revert to old settings)

SQLstat: (Pass/Fail)
- Indicates whether SQL server is installed on the local machine
SQLuser: (SB) (Variable)
- User defined SQL username
SQLpw: (SB) (Variable)
- User defined SQL password
SQLinstall: (SB) (New/Existing)
- If SQL is installed, user selection to install FacilityDocs as a new instance or use the existing instance
SQLserver: (SB) (Variable)
- Get-ServerName script returns this variable after checking against instance name
SQLinst: (SB) (Variable)
- User defined SQL instance name
SQLauth: (SB) (MM/Win)
- User defined SQL authentication method
LclSQLinstance: (Variable)
- Stores detected SQL instance names on local machine

#>

Function Out-IniFile
{
[CmdletBinding()]
Param
(
[switch]$Append,

[ValidateSet("Unicode","UTF7","UTF8","UTF32","ASCII ","BigEndianUnicode","Default","OEM")]
[Parameter()]
[string]$Encoding = "Unicode",


[ValidateNotNullOrEmpty()]
[ValidatePattern('^([a-zA-Z]\?.+\.ini$')]
[Parameter(Mandatory=$True)]
[string]$FilePath,

[switch]$Force,

[ValidateNotNullOrEmpty()]
[Parameter(ValueFromPipeline=$True,Mandatory=$True)]
[Hashtable]$InputObject,

[switch]$Passthru
)

Begin
{Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started"}

Process
{
Write-Verbose "$($MyInvocation.MyCommand.Name):: Writing to file: $Filepath"

if ($append) {$outfile = Get-Item $FilePath}
else {$outFile = New-Item -ItemType file -Path $Filepath -Force:$Force}
if (!($outFile)) {Throw "Could not create File"}
foreach ($i in $InputObject.keys)
{
if (!($($InputObject[$i].GetType().Name) -eq "Hashtable"))
{
#No Sections
Write-Verbose "$($MyInvocation.MyCommand.Name):: Writing key: $i"
Add-Content -Path $outFile -Value "$i=$($InputObject[$i])" -Encoding $Encoding
}
else
{
#Sections
Write-Verbose "$($MyInvocation.MyCommand.Name):: Writing Section: [$i]"
Add-Content -Path $outFile -Value "[$i]" -Encoding $Encoding
Foreach ($j in $($InputObject[$i].keys | Sort-Object))
{
if ($j -match "^Comment[\d]+")
{
Write-Verbose "$($MyInvocation.MyCommand.Name):: Writing comment: $j"
Add-Content -Path $outFile -Value "$($InputObject[$i][$j])" -Encoding $Encoding
}
else
{
Write-Verbose "$($MyInvocation.MyCommand.Name):: Writing key: $j"
Add-Content -Path $outFile -Value "$j=$($InputObject[$i][$j])" -Encoding $Encoding
}

}
Add-Content -Path $outFile -Value "" -Encoding $Encoding
}
}
Write-Verbose "$($MyInvocation.MyCommand.Name):: Finished Writing to file: $path"
if ($PassThru) {Return $outFile}
}

End
{Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended"}
}

"Checking system status. Please wait..."

### Assemblies and Modules
Add-Type -AssemblyName PresentationFramework
Import-Module BitsTransfer

<### Windows version check
$OSversionMajor = [Environment]::OSVersion.Version.Major
$OSversionMinor = [Environment]::OSversion.Version.Minor
$OSversionBit = (Get-WmiObject Win32_OperatingSystem).OSArchitecture
#> # Not needed as of 11-07-17

$FDinstall = "Continue"

### Microsoft .NET Version Check - Set .NET status environment variables and indicate whether .NET install requires restart
$NETrelease = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\' -Name Release -ErrorAction SilentlyContinue -ErrorVariable evNETrelease).release
$NETinstalled = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\' -Name Install -ErrorAction SilentlyContinue -ErrorVariable evNETinstalled).install
If($evNETrelease -or $evNETinstalled)
{
$NETstat = "Fail"
$NETvers = "Fail"
$NETRSreq = "Yes"
}
Elseif (($NETinstalled -ne 1) -or ($NETrelease -lt 379893))
{
$NETstat = "Fail"
$NETvers = "Fail"
$NETRSreq = "Yes"
}
Else
{
$NETstat = "Pass"
$NETvers = "Pass"
$NETRSreq = "No"
}

### Microsoft SQL check - Set SQL status environment variables, enable SQLBrowser service, and test for existing instances
"Checking SQL Path..."
If((Test-Path 'HKLM:\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL') -eq "True")
{
try
{
"Checking Microsoft SQL status. Please wait..."
$SQLstat = "Pass"
$SQLbrDefStat = (Get-Service SQLBrowser).Status
$SQLbrDefStartup = (Get-WmiObject -Class Win32_Service -Filter "Name='SQLBrowser'").StartMode
Set-Service SQLBrowser -StartupType Manual
Set-Service SQLBrowser -Status Running
$LclSQLinstance = ([System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() | Where {$_.ServerName -eq $env:COMPUTERNAME}).InstanceName -replace (" ","|")
}
Catch
{
$FDinstall = "Cancel"
[System.Windows.MessageBox]::Show("FacilityDocs installer encountered an error. Please contact Bronze Bow Software support for further assistance.","ERROR","Ok","Error")
}
}
Else
{
"Could not find SQL path"
$SQLstat = "Fail"
}

# Create INI config file
$Config = @{"FDinstall"=$FDinstall;"NetStat"=$NETstat;"NetVe rs"=$NETvers;"NetRSreq"=$NETRSreq;"SQLbrDefStat"=$ SQLbrDefStat;"SQLbrDefStartup"=$SQLbrDefStartup;"S QLstat"=$SQLstat;"SQLuser"="";"SQLinstall"="";"SQL server"=$env:COMPUTERNAME;"SQLinst"="";"SQLauth"=" ";"LclSQLinstance"=$LclSQLinstance}
$NewINIContent = @{“Config”=$Config}
Out-IniFile -InputObject $NewINIContent -FilePath "$Env:Tmp\FacilityDocs\FDconfiguration.INI" -Force

Start-Sleep -Seconds 5