I have the following function:

```

function DivideAndCreateFiles ([string] $file, [string] $ruleName) {
    $Suffix = 0
    $FullData = Get-Content $file
    $MaxIP = 40

    while ($FullData.count -gt 0 ){
        $NewData = $FullData | Select-Object -First $MaxIP
        $FullData = $FullData | Select-Object -Skip $MaxIP
        $NewName = "$ruleName$Suffix"
        New-Variable -name $NewName -Value $NewData
        Get-Variable -name $NewName -ValueOnly  | out-file "$NewName.txt" 
        $Suffix++
    }

}

```

This function takes a file location, this file holds hundreds of ips. It then iterate the file and create files from it each one holding 40 IP's naming it $rulename$suffix so if $rulename=blabla

I would get blabla\_0, blabla\_1, and so on, each with 40 ips.

I need to convert this logic and put it inside a jenkins job.
This file is in the working dir of the job and is called ips.txt

```
suffix = 0
maxIP = 40
ips = readFile('ips.txt')

...

```