-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfigure-SSLRemoting.ps1
57 lines (39 loc) · 2.06 KB
/
Configure-SSLRemoting.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
return "This is a walkthrough demo"
Enter-PSSession -VMName srv1 -Credential $artd
$computer = $env:computername #"SRV1"
Get-WSManInstance -resourceuri winrm/config/listener -selectorset @{address = "*"; transport = "http" } -ComputerName $computer
Get-WSManInstance -resourceuri winrm/config/listener -selectorset @{address = "*"; transport = "https" } -ComputerName $computer
#get certificate thumbprint
#how you get the SSL cert installed is up to you
#Jeff - you may need to finish setting up the CA on Dom1
$cred = Get-Credential company\artd
#a hack to pass credentials
net use * \\dom1\c$ /user:company\artd $cred.GetNetworkCredential().Password
$getParams = @{
template = 'CompanyServer'
url = "ldap:" #'https://dom1.company.pri/ADPolicyProvider_CEP_Kerberos/service.svc/cep'
CertStoreLocation = 'Cert:\LocalMachine\My\'
#SubjectName = "CN=Srv1.Company.pri"
Verbose = $True
}
Get-Certificate @getparams
$cert = Get-ChildItem cert:\localmachine\my | Where-Object { $_.EnhancedKeyUsageList -match "Server Authentication" } | Select-Object -first 1
$dns = Resolve-DnsName -Name $computer -TcpOnly -Type A
$settings = @{
Address = $dns.IPAddress
Transport = "https"
CertificateThumbprint = $cert.Thumbprint
Enabled = "True"
Hostname = $cert.DnsNameList.unicode
}
New-WSManInstance -resourceuri 'winrm/config/Listener' -selectorset @{Address = "*"; Transport = "HTTPS" } -ValueSet $settings # -ComputerName $computer -Verbose
Get-WSManInstance -resourceuri winrm/config/listener -selectorset @{address = "*"; transport = "https" } #-ComputerName $computer
#YOU MAY ALSO NEED A FIREWALL RULE
exit
#hostname must match certificate name
enter-pssession -ComputerName srv1.company.pri -UseSSL
<#
Remove-WSManInstance -resourceuri winrm/config/listener -selectorset @{address="*";transport="https"} -ComputerName $computer
#>
# New-WSManInstance winrm/config/Listener -SelectorSet @{Transport=HTTPS} -ValueSet @{Hostname="HOST";CertificateThumbprint="XXXXXXXXXX"}