# create test data try { $list = New-Object System.Collections.Generic.list[string]; $max = 300; for ($i = 1; $i -le $max; $i++) { $str = "key:$($i),value:$($i)" $list.Add($str) } $path = "./my-data.txt" $outFilePath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($path) Write-Host $outFilePath [System.IO.File]::WriteAllLines($outFilePath, $list, [System.Text.Encoding]::UTF8); } catch { Write-Output "[exception]" Write-Output $_ }