Importing Best Bets as Query Rule in SharePoint 2013 using PowerShell

Use the below format for the CSVfile input

"IRS","","Income Tax;Tax;","Internal Revenue Service","","","",""

Sample PowerShell Script

Add-PSSnapin AdminSnapIn -erroraction SilentlyContinue
Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

$sa = "Search Service App Name"
$ssa = Get-SPEnterpriseSearchServiceApplication $sa
$siteurl = "http://siteurl/"
$ruleManager = New-Object Microsoft.Office.Server.Search.Query.Rules.QueryRuleManager($ssa)
$isVisualBB = "false"
$bestBetCSVFile = import-csv "E:\Path\BestBet.csv" -erroraction SilentlyContinue

Write-Host "File Imported"

foreach($row in $bestBetCSVFile)

$bestBetName = $row.BestBet
$rulename = $bestBetName
$contextName = $row.UserContext
$keywordName = $row.Keyword
$description = $row.Description
$url = $row.Url
$startDate = $row.StartDate
$endDate = $row.EndDate
$position = $row.Position

Write-Host $bestBetName $rulename $contextName $keywordName $description $url $startDate $endDate $row.Position

createBestBetQueryRule -rulename $rulename -keyword $keywordName -ruleManager $ruleManager -bestBetName $bestBetName -contextName $contextName -description $description -url $url -startDate $startDate -endDate $endDate -position $position -isVisualBB $isVisualBB

Write-Host "Added BestBet '$bestBetName' to Keyword '$keywordName'"