Passing string value

Hello,

I have the function below that finds out what type of form is from a CSV. We have Transfer, New Hire, and Deletion forms from HR.

How would I pass, Transfer for example?

function Type_Of_Form
{    
    param ([string]$Args)
    $Employees_CSV."Type of Form".GetValue[$People] -eq $Args
}

Not positive I understand the question, but, you’ve used a reserved word for the argument variable.

Try this and see if it applies to your problem.

function Type_Of_Form
{    
    param ([string]$FType)
    "test" -eq $FType
}

Type_of_Form("test")
Type_of_Form("nottest")

Thank you, I didn’t know $Args was a reserved word. I’ll try another and test

function Get-HRForm  {    
    param (
    [ValidateSet("Transfer", "New Hire", "Deletion")]
    [string]$Type = "Transfer"
    )
    
    "Processing CSV as {0}" -f $Type
}

Output:

Get-HRForm

Processing CSV as Transfer

Get-HRForm -Type 'New Hire'

Processing CSV as New Hire

Get-HRForm -Type 'Foo'

Get-HRForm : Cannot validate argument on parameter 'Type'. The argument "Foo" does not belong to the set "Transfer,New Hire,Deletion" specified by the ValidateSet 
attribute. Supply an argument that is in the set and then try the command again.
At line:11 char:18
+ Get-HRForm -Type 'Foo'
+                  ~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-HRForm], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Get-HRForm