Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Public/Ping.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<#
.SYNOPSIS
Tests ping capability
.DESCRIPTION
Test that a remote system is pingable and also that the remote system is allowing ping packets.
.PARAMETER Target
Specifies the Domain Name System (DNS) name or IP address of the target computer.
.PARAMETER Property
Specifies a property of the TestNetConnectionResult object to test.
.PARAMETER Should
A Script Block defining a Pester Assertion.
.EXAMPLE
Ping localhost PingSucceeded { Should Be $true }
.EXAMPLE
Ping remoteserver PingSucceeded { Should Be $true }
.NOTES
Assertions: Be, BeExactly, Match, MatchExactly
#>
function Ping {
[CmdletBinding()]
param(
[Parameter(Mandatory, Position=1)]
[Alias("ComputerName")]
[string]$Target,

[Parameter(Mandatory, Position=2)]
[ValidateSet("AllNameResolutionResults", "BasicNameResolution", "ComputerName", "Detailed", "DNSOnlyRecords", "InterfaceAlias",
"InterfaceDescription", "InterfaceIndex", "IsAdmin", "LLMNRNetbiosRecords", "MatchingIPsecRules", "NameResolutionSucceeded",
"NetAdapter", "NetRoute", "NetworkIsolationContext", "PingReplyDetails", "PingSucceeded", "RemoteAddress", "RemotePort",
"SourceAddress", "TcpClientSocket", "TcpTestSucceeded", "TraceRoute")]
[string]$Property,

[Parameter(Mandatory, Position=3)]
[scriptblock]$Should
)

$params = Get-PoshspecParam -TestName TcpPort -TestExpression {Test-NetConnection -ComputerName $Target -ErrorAction SilentlyContinue} @PSBoundParameters

Invoke-PoshspecExpression @params
}