Public/Test-StoreNetwork.ps1

Function Test-StoreNetwork {
    <#
.SYNOPSIS
    Tests a stores network elements to determine functionality
 
.NOTES
    Name: Test-StoreNetwork
    Author: Luke Hagar
    Version: 1.0
    DateCreated: January 20th, 2021
 
.EXAMPLE
    Test-StoreNetwork -Store SWBEE
 
.LINK
     
#>

    
    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory = $false,
            ValueFromPipeline = $true,
            ValueFromPipelineByPropertyName = $true,
            Position = 0
        )]
        [Alias('physicalDeliveryOfficeName')]
        [String]$Store
    )
    
    BEGIN {
        $StoreElements = @("SW1", "SW2", "SW3", "KRON", "WLC1", "FS1", "SS1" , "AP1", "AP2", "AP3", "AP4", "AP5", "AP6", "AP7", "AP8", "AP9", "AP10", "AP11", "AP12", "AP13", "AP14", "AP15", "AP16", "AP17", "AP18", "AP19", "AP20", "AP21", "AP22", "AP23")
        $TestConnectionBlock = { 
            param (
                $Element,
                $Location
            )
            If ($Test = Test-Connection "$Location-$Element" -Count 1 -ErrorAction SilentlyContinue | Select-Object Address, IPV4Address, ResponseTime) {
                [PSCustomObject]@{
                    Store        = $Location
                    HostName     = "$Location-$Element"
                    IPV4Address  = $Test.IPV4Address
                    ResponseTime = $Test.ResponseTime
                }
            }
            Else {
                [PSCustomObject]@{
                    Store        = $Location
                    HostName     = "$Location-$Element"
                    IPV4Address  = "Offline"
                    ResponseTime = "Offline"
                }
            } }
    }
    
    PROCESS {
        $JobList = @()
        $Location = $Store.Replace(' ', '')
        Foreach ($Element in $StoreElements) {
            Write-Verbose "Starting Job for $Location-$Element"
            $JobList += Start-Job -ScriptBlock $TestConnectionBlock -ArgumentList $Element, $Location
        }
        Write-Verbose "Waiting on Jobs"
        $JobList | Get-Job | Wait-Job | Out-Null
        Write-Verbose "Receiving Jobs"
        $Results = $JobList | Get-Job | Receive-Job
        Write-Verbose "Outputting Results"
        Return $Results
    }
    END { }
}