| description | Avoid Using ComputerName Hardcoded |
|---|---|
| ms.custom | PSSA v1.21.0 |
| ms.date | 06/28/2023 |
| ms.topic | reference |
| title | AvoidUsingComputerNameHardcoded |
Severity Level: Error
The names of computers should never be hard coded as this will expose sensitive information. The
ComputerName parameter should never have a hard coded value.
Remove hard coded computer names.
Function Invoke-MyRemoteCommand ()
{
Invoke-Command -Port 343 -ComputerName hardcoderemotehostname
}Function Invoke-MyCommand ($ComputerName)
{
Invoke-Command -Port 343 -ComputerName $ComputerName
}Function Invoke-MyLocalCommand ()
{
Invoke-Command -Port 343 -ComputerName hardcodelocalhostname
}Function Invoke-MyLocalCommand ()
{
Invoke-Command -Port 343 -ComputerName $env:COMPUTERNAME
}