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)