My powershell acts very strangely when I try to make a function. To demonstrate, Here is a basic function that, I dunno, calculates the quadratic formula:
1 function Get-Quadratic {
2
3 [CmdletBinding()]
4
5 param (
6 [Parameter(Position = 0, Mandatory = $true)]
7 [int32]$a
8 [Parameter(Position = 1, Mandatory = $true)]
9 [int32]$b
10 [Parameter(Position = 2, Mandatory = $true)]
11 [int32]$c
12 )
13
14 Write-Output $a + " " + $b + " " + $c
15 }
And if you were to try loading this in with . .\quadratic.ps1
, you get:
At C:\Users\(me)\Desktop\Cur\playground\quadratic.ps1:7 char:11
+ [int32]$a
+ ~
Missing ')' in function parameter list.
At C:\Users\(me)\Desktop\Cur\playground\quadratic.ps1:1 char:24
+ function Get-Quadratic {
+ ~
Missing closing '}' in statement block or type definition.
At C:\Users\(me)\Desktop\Cur\playground\quadratic.ps1:12 char:1
+ )
+ ~
Unexpected token ')' in expression or statement.
At C:\Users\(me)\Desktop\Cur\playground\quadratic.ps1:15 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingEndParenthesisInFunctionParameterList
I have followed tutorials down to the pixel when trying to make functions, but my powershell doesn't seem to like even the most basic commands. If it helps, my version is
Major Minor Build Revision
----- ----- ----- --------
5 1 19041 1320