-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemos.ps1
192 lines (137 loc) · 4.66 KB
/
demos.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
return "This is a guided walkthrough script"
#region PowerShell Remoting Fundamentals
#wsman and remoting requirements
#enabling remoting
#Test-WSMan
#Test-NetConnection
#region using Group Policy
#start WinRM
#create endpoints
#Create firewall rules
<#
Name : WINRM-HTTP-In-TCP-NoScope
DisplayName : Windows Remote Management (HTTP-In)
Description : Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]
DisplayGroup : Windows Remote Management
Group : @FirewallAPI.dll,-30267
Enabled : True
Profile : Domain, Private
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
Name : WINRM-HTTP-In-TCP
DisplayName : Windows Remote Management (HTTP-In)
Description : Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]
DisplayGroup : Windows Remote Management
Group : @FirewallAPI.dll,-30267
Enabled : True
Profile : Public
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
#>
#or use a PowerShell Startup Script
if ( (Get-Service -Name winrm).StartType -eq 'Disabled' -OR (-Not (Test-WSMan))) {
write-host "Remoting needs to be enabled"
Enable-PSRemoting -Force
}
#endregion
#limitations
#TrustedHosts
#one-to-one
#one-to-many
#using PSSessions
#discovering who is connected
psedit .\get-remotesession.ps1
help about_remote*
help about_pssession*
#endregion
#region Configuring SSL
psedit .\Configure-SSLRemoting.ps1
#endregion
#region The Dreaded 2nd Hop
#credssp
psedit .\demo-credssp.ps1
#kerberos delegation
psedit .\Demo-KerberosDelegation.ps1
#endregion
#region Using disconnected sessions
help about_Remote_Disconnected_Sessions
#endregion
#region Remoting at Scale
#Invoke-Command
#running scripts
#$using:
#copying files over remoting
#endregion
#region Creating Constrained Remoting Endpoints
help about_Session
Get-PSSessionConfiguration
Get-PSSessionConfiguration -Name microsoft.powershell | Select-Object *
Enter-PSSession -VMName srv2 -Credential $artd
help New-PSSessionConfigurationFile -online
$newEP = ".\Restricted.pssc"
$params = @{
Path = $newEP
Author = "Art Deco"
CompanyName = "Company.pri"
Description = "A restricted endpoint"
ExecutionPolicy = "restricted"
LanguageMode = "NoLanguage"
MountUserDrive = $True
RunAsVirtualAccount = $True
TranscriptDirectory = "c:\Transcripts"
VisibleCmdlets = 'Get-Service', 'Get-Process', 'Exit-PSSession', 'Get-Command', 'Get-FormatData', 'Out-File', 'Out-Default', 'Select-Object', 'Measure-Object'
VisibleFunctions = 'Get-Volume'
}
<#
required visible cmdlets
'Exit-PSSession','Get-Command','Get-FormatData','Out-File','Out-Default','Select-Object','Measure-Object'
#>
New-PSSessionConfigurationFile @params
Get-Content $newEP
#need to create the transcript folder
If (-Not (Test-Path c:\Transcripts)) {
mkdir C:\Transcripts
}
help Register-PSSessionConfiguration
# give this group access
# get-adgroup IT | get-adgroupmember
# get-aduser maryl -Properties memberof
#replace the SID
$sddl = "O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;IU)(A;;GA;;;RM)(A;;GXGR;;;S-1-5-21-3873872113-3455461782-542000861-1145)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)"
Register-PSSessionConfiguration -Path $newEP -Name Restricted -SecurityDescriptorSddl $sddl
#or use -ShowSecurityDescriptorUI parameter
Get-PSSessionConfiguration restricted | select *
exit
Enter-PSSession -ComputerName srv2 -Credential company\maryl -ConfigurationName restricted
Get-Command -noun pssessionconfiguration
#will revisit this with JEA
#endregion
#region Getting started with Just Enough Administration
cd p:\techmentor2019\JEA
invoke-item .\hicks-psjea.pptx
#endregion
#region SSH Remoting with PowerShell Core/7
#endregion
#region What about you?
#what are your remoting questions or problems?
#endregion