One pattern I’ve noticed, especially when dealing with commands that may or may not be executed locally is where a script offers a parameter for the computer name (or a list of computer names).

What Are People Doing?

Sometimes, that parameter will be defaulted to $env:ComputerName

[Parameter(Mandatory=$false, Position=1, ValueFromPipeline=$true)][string] $ComputerName = $env:ComputerName

Other times, there will be an if statement checking to see if the parameter is null and assigning $env:ComputerName if it has no other value.
From there, the script will go on to do something like 
## How Can I Be Cooler?




[Splatting can offer another option.](/blog/2011/04/clean-up-your-parameters)  We still need to do a null check, but we can build up a hash table with the known parameters we would like to pass, and if $ComputerName exists, we can tack that on later.  We can then pass the whole thing to the command in one fell swoop.