Chapters/analyzing-your-script/Result.ps1

function Get-Disk {
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true)]
        [string[]]$ComputerName
    )
    foreach ($comp in $computername) {
        $logfile = "errors.txt"
        Write-Verbose "Trying $comp"
        try {
            Get-CimInstance -ClassName win32_logicaldisk -ComputerName $comp -ea stop
        } catch {
            $comp | Out-File $logfile -Append
        }
    }
}