forked from rstefanetti/Powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelperFunctions.ps1
More file actions
111 lines (100 loc) · 2.64 KB
/
Copy pathHelperFunctions.ps1
File metadata and controls
111 lines (100 loc) · 2.64 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
function New-SSLWebBinding
{
Param
(
[Parameter(Mandatory=$True)]
[string]$Name,
[Parameter(Mandatory=$true)]
[string]$Thumbprint,
[Parameter(Mandatory=$false)]
[string]$IP = '*',
[Parameter(Mandatory=$false)]
[int]$Port = '443'
)
# Create a new binding to a site
New-WebBinding -Name $Name -Port $Port -Protocol https -IPAddress $IP
Write-Verbose "Binding created for $Name"
# Change location
$location = Get-Location
Set-Location -Path IIS:\SslBindings
# Remove binding
Get-Item "$IP!$Port" | Remove-Item
# Bind certificate to site
Get-Item Cert:\LocalMachine\my\$Thumbprint | New-Item $IP!$Port
# Change location to former location
Set-Location -Path IIS:\
Set-Location -Path $location
Write-Verbose "Certificate added to binding"
}
function New-DesktopShortcut
{
Param
(
[Parameter(Mandatory=$true)]
[string]$Name,
[Parameter(Mandatory=$true)]
[string]$TargetPath,
[Parameter(Mandatory=$false)]
[string]$WorkingDirectory,
[Parameter(Mandatory=$false)]
[string]$IconLocation,
[Parameter(Mandatory=$false)]
[string]$Arguments
)
$filename = "C:\Users\Public\Desktop\$Name.lnk"
if (!(Test-Path -Path $filename)) {
$Shell = New-object -comobject WScript.Shell
$Shortcut = $Shell.CreateShortcut($filename)
$Shortcut.TargetPath = $TargetPath
if (!$WorkingDirectory) {
$WorkingDirectory = Split-Path $TargetPath
}
$Shortcut.WorkingDirectory = $WorkingDirectory
if ($Arguments) {
$Shortcut.Arguments = $Arguments
}
if ($IconLocation) {
$Shortcut.IconLocation = $IconLocation
}
$Shortcut.save()
}
}
function Get-UserInput
{
Param
(
[Parameter(Mandatory=$True)]
[string]$Id,
[Parameter(Mandatory=$True)]
[string]$Text,
[Parameter(Mandatory=$false)]
[string]$Default
)
if ($Default) {
$Text = ($Text + " (Default " + $Default + ")")
}
$reply = Get-Variable -name "Hardcode$Id" -ValueOnly -ErrorAction SilentlyContinue
if ($reply) {
if ($reply -eq 'default') {
$Default
} else {
$reply
}
Write-Verbose "$Text : $reply"
} else {
$reply = Read-Host $Text
if (!$reply) {
$Default
} else {
$reply
}
}
}
function Get-MyIp
{
$url = "http://checkip.dyndns.com"
$WebClient = New-Object System.Net.WebClient
$xml = [xml]($WebClient.DownloadString($url).ToString())
$ip = $xml.html.body.Split(":")[1].Trim()
$ip
}