forked from BornToBeRoot/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-TrustedHost.ps1
65 lines (51 loc) · 1.43 KB
/
Get-TrustedHost.ps1
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
###############################################################################################################
# Language : PowerShell 4.0
# Filename : Get-TrustedHost.ps1
# Autor : BornToBeRoot (https://github.com/BornToBeRoot)
# Description : Get trusted hosts (WinRM)
# Repository : https://github.com/BornToBeRoot/PowerShell
###############################################################################################################
<#
.SYNOPSIS
Get trusted hosts (WinRM)
.DESCRIPTION
Get trusted hosts (WinRM).
.EXAMPLE
Get-TrustedHost
TrustedHost
-----------
192.168.178.28
172.16.1.*
Windows7x64
.LINK
https://github.com/BornToBeRoot/PowerShell/blob/master/Documentation/Function/Get-TrustedHost.README.md
#>
function Get-TrustedHost
{
[CmdletBinding()]
param(
)
Begin{
}
Process{
$TrustedHost_Path = "WSMan:\localhost\Client\TrustedHosts"
try{
[String]$TrustedHost_Value = (Get-Item -Path $TrustedHost_Path).Value
}
catch{
throw
}
if([String]::IsNullOrEmpty($TrustedHost_Value))
{
return
}
foreach($TrustedHosts in $TrustedHost_Value.Split(','))
{
[pscustomobject] @{
TrustedHost = $TrustedHosts
}
}
}
End{
}
}