首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从PowerShell代码访问FinalBuilder变量

从PowerShell代码访问FinalBuilder变量
EN

Stack Overflow用户
提问于 2011-11-23 23:58:40
回答 2查看 1.2K关注 0票数 3

我在我的FinalBuilder项目中添加了“执行PowerShell脚本”操作。手册说我可以使用以下语法访问FinalBuilder变量(在Specify Script区域输入):

代码语言:javascript
复制
$FBVariables.GetVariable("VarName")

但问题是,在我的例子中,$FBVariables总是null,我的意思是下面的语句返回True

代码语言:javascript
复制
$FBVariables -eq $null

我不知道我做错了什么。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-11-24 01:54:00

$FBVariablesExecute PowerShell Script操作中不可用。

您必须使用Run Script (我想在旧版本中使用Execute Script )操作,在Script Editor选项卡中将language设置为Powershell,在这里您可以使用#FBVariables

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

票数 3
EN

Stack Overflow用户

发布于 2011-11-25 10:57:40

以下是LogVariables操作中包含的工作PowerShell脚本的示例。我发现不能对变量使用PowerShell操作,所以我使用了另一个操作,并添加了一个脚本来传入/传出Powershell Commandlet的信息。

Powershell脚本

代码语言:javascript
复制
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8245248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档