Also, as you’re just getting started, using Read-Host to prompt for a parameter value is generally a poor practice.
function Get-HostProperties {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)][string]$ComputerName
}
...
}
Will cause a prompt for the value if it isn’t provided. This is the preferred way to accomplish that. Learn PowerShell Toolmaking in a Month of Lunches covers that and other techniques. Additionally, formatting your output within the function is a common “gotcha” and leads the output being less useful. In your function, for example, you cannot pipe the output of Get-HostProperties to anything like Export- or ConvertTo- or anything. See our free ebook, The Big Book of PowerShell Gotchas or Learn Windows PowerShell in a Month of Lunches. Generally, functions should not format output. You can accomplish the same thing, in a more flexible fashion, by using Select-Object instead of Format-Table.