3

I added "Execute PowerShell Script" action to my FinalBuilder project. Manual says that I can access FinalBuilder variables using following syntax (entered in Specify Script area):

$FBVariables.GetVariable("VarName")

But the problem is $FBVariables in my case is always null, I mean following statement returns True:

$FBVariables -eq $null

I have no idea what I am doing wrong.

Roman
  • 4,531
  • 10
  • 40
  • 69

2 Answers2

3

$FBVariables is not available in the Execute PowerShell Script action.

You will have to use the Run Script ( or Execute Script in older versions I think) action, set language to Powershell in the Script Editor tab and here you can use #FBVariables

http://www.finalbuilder.com/Default.aspx?tabid=456&aft=9647#10952

manojlds
  • 290,304
  • 63
  • 469
  • 417
0

Here is an example of a working PowerShell script contained in a LogVariables Action. I found you couldn't use the PowerShell Action with variables, so I just used another action and added a script to pass information in/out of Powershell Commandlets.

Powershell Script

Function ConvertNametoFolder([string]$FileName="VirtualServerInstanceName.web.config",    [string]$FileSuffix="web.config")
{
   [string]$Result = ""
   if ($FileLen -ne "")
   {
      [int]$FileLen = $FileName.Length
      [int]$SuffixLen = $FileSuffix.Length
      $Result = $FileName

      $Result = $FileName.SubString(0,($FileLen-$SuffixLen)-1)

      # String join method (not safe)
      #$Result =  $Result + "\" + $FileSuffix

      # .net Framework safe method for combining folder\file paths to Windows Standards.
      $Result = [System.IO.Path]::Combine($Result, $FileSuffix)
    }
Return $Result
}

$FileIn = $FBVariables.GetVariable("varWebConfigFilePath") # Passed-in at runtime
[string]$PathOut =  ConvertNametoFolder $FileIn
$FBVariables.GetVariable("varIisSettingFile")
$FBVariables.SetVariable("varWebConfigFileDestinationPath", $PathOut)
MonkeyDreamzzz
  • 3,978
  • 1
  • 39
  • 36
Jamie Clayton
  • 1,007
  • 11
  • 24