-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathTest-Uri.ps1
More file actions
36 lines (28 loc) · 797 Bytes
/
Test-Uri.ps1
File metadata and controls
36 lines (28 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<#
.SYNOPSIS
Determines whether a string is a valid URI.
.INPUTS
System.String value to test for a valid URI format.
.OUTPUTS
System.Boolean indicating that the string can be parsed as a URI.
.FUNCTIONALITY
Data formats
.EXAMPLE
Test-Uri.ps1 http://example.org
True
.EXAMPLE
Test-Uri.ps1 0
False
#>
#Requires -Version 3
[CmdletBinding()][OutputType([bool])] Param(
# The string to test.
[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][AllowEmptyString()][AllowNull()][string] $InputObject,
# What kind of URI to test for: Absolute, Relative, or RelativeOrAbsolute.
[Parameter(Position=1)][UriKind] $UriKind = 'Absolute'
)
Process
{
if(!$InputObject) {return $false}
return [uri]::TryCreate($InputObject,$UriKind,[ref]$null)
}