Reputation: 6881
I defined a function to append a title to an output file.
function appendTitle($filePath, [string]$title){
Add-Content -Path $filePath -Value "+------------------------+"
Add-Content -Path $filePath -Value $title
Add-Content -Path $filePath -Value "+------------------------+"
}
The issue is that if I run it as such:
appendTitle($filePath, "Net Accounts")
But in the output file it doesn't include the $title variable but just displays:
+------------------------+
+------------------------+
So where did my variable go that I wanted to append?
Upvotes: 1
Views: 242
Reputation: 8889
It's Because you run it inside a parentheses, run it like that:
appendTitle $filepath "Net Accounts"
Upvotes: 3