When creating functions that accept a computer name as a parameter you will often see this syntax
[string]$computername = ‘localhost’
This is designed to give a default value in the event of a value not being passed. That’s a good idea if there is a sensible, safe, value you can use and you aren’t making the parameter mandatory.
The only objection I have is to using ‘localhost’
I have seen this break down – for instance if you try to use the System.DirectoryServices.AccountManagement classes against accounts on the local machine. On the other hand you have to use it when dealing with the WSMAN provider.
Just be aware that ‘localhost’ can cause issues