I have never done powershell but i think it is still the same rules so here we go.
It is not a good practice generally to do I/O from every single function you have. You could adopt a practice of using a script/scriptblock that calls all you functions/subroutines from it and do you I/O from it. Your Test-Connection $device method could also use a time out value though if you think you are good with the default one, no problem.
In other languages, those could be global variables, right? And i think this is a poor way of managing commandline args since powershell comes bundled with a way to do it better.
param (
[string]$device = $(throw "-device name is required."),
[int]$port,
[int]$start = 100, <# default start port #>
[int]$stop = 299, <# default stop port #>
)
Have a look at
https://devcentral.f5.com/articles/powershell-abcs-p-is-for-parametersLook at this for inspiration, improving and learning on how best this could be done in poweshell:
https://github.com/attackdebris/babel-sf/blob/master/powershell/portscan-powershell.ps1