How to call function script with parameters

I’ve created a powershell function that requires the employeeID to collect all the data from that user.
now I want to call that function in a different powershell script passing on the required employeeID how do I do this? the function is called collect_data the filename is function_collect_data.ps1
these are the parameters of the function

function collect_data(){
    [Parameter(Mandatory=$True, ValueFromPipelineByPropertyName=$True)]

  $ReactivateMe = get-aduser -filter {employeeID -eq $EmployeeID} -Properties EmployeeID, EmailAddress, Samaccountname, Description, UserPrincipalName, DistinguishedName, City, Co, extensionattribute1, extensionattribute5, extensionattribute11, extensionattribute12, extensionattribute13, extensionattribute14,info|
  select-object EmployeeID,Emailaddress,Samaccountname,Description, UserPrincipalName,DistinguishedName, City, Co, extensionattribute1, extensionattribute5, extensionattribute11, extensionattribute12, extensionattribute13, extensionattribute14,info
  $reactivateme |export-csv c:\temp\reactivate.csv -NoTypeInformation
$users = import-csv C:\temp\reactivate.csv

I know that I can call the function collect_Data xxxxxx where the xxx is the employeeID and this works but if I call the specific function from a different file how would I pass the employeeID into my function?

I’m not completely sure what you’re actually asking. I’d recommend to either “outsource” this particular function to a separate file and call it from the different script needing this function by dot sourcing. Here you can read more about:

… or use an even more professional approach and create a module with this function. This way you could use

to make sure the needed modules are available for the script to run.

Regardless of that I’d highly recommend to use only approved verbs and the well known naming conventions of PowerShell to name your functions.

Functions usually return a PSObject, so in this use case, you might create a wrapper function to get specific properties for your company and do Get-CompanyAdUser, but it’s going to return the data. The Select-Object should be unnecessary, it is just recreating the PSObject returned from Get-ADUser with the same properties you returned from command. After you export the data, then you are re-importing the data (e.g. Import-Csv), but this is unnecessary because you have the data stored in the $reactivateme variable. The implementation would more like this (not tested):

function Get-AcerAdUser(){
    begin {
        $props = @(
    process {

        try {
            $results = Get-ADUser -filter {employeeID -eq $EmployeeID} -Properties $props -ErrorAction Stop
        catch {
            Throw ('Handle: Failed call to Get-ADUser. {0}' -f $_)
    end {

Import-Module -Name ActiveDirectory

$adUser = Get-AcerAdUser -EmployeeID 12345
$adUser | Export-Csv C:\Temp\reactivate.csv -NoTypeInformation