Forum Discussion
iRule content show up in one line
When I create an iRule from a powershell script that includes HTTP content, the irule gets created, however, the HTTP is not delimited in the rule when you look at. Its all on one line. Is there any way to get the html to show up properly.
5 Replies
Could you please provide some sample PS code? Adding `n to a string in PS would cause it to use a new line but I'm not sure if that's what you want?
- Jeffrey_Silver1
Nimbostratus
Patrik, the issue seems to be that even if you put the proper newline characters in the actual text, when you assign that text to the object the newline or carriage returns are not recognized. The irule in the code below gets created but when you go into the web interface and view the irule, all of the content is on a single line.
$data = Get-Content $invar1 $RuleDefinition = New-Object -TypeName iControl.LocalLBRuleRuleDefinition $RuleDefinition.rule_name = $rule **$RuleDefinition.rule_definition = $data** $ic.LocalLBRule.create( (,$RuleDefinition) ) After a few attempts I finally understood your dilemma. When reading from a file you get a System.Object array.
Converting this to a string removes the line breaks.
Try this:
$def = (Get-Content iRuleContent.txt) -join "`n"
$RuleDefinition = New-Object -TypeName iControl.LocalLBRuleRuleDefinition $RuleDefinition.rule_name = "iRulewithlines" $RuleDefinition.rule_definition = $def $f5.LocalLBRule.create($RuleDefinition )
- Jeffrey_Silver1
Nimbostratus
Patrik, thanks for you help. You got me pointed in the right direction. What I had to do was to read the HTML file in line by line, and append those lines to an array followed by the [char]13. With the array filled, I used the array name as input to the rule_definition string. Works like a charm.
- Actually you don't need to add [char]13. Seems like the commandlet takes care of that for you as long as you give it a proper string.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com