This repository was archived by the owner on Jun 16, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathNew-PSUEnvironment.txt
More file actions
343 lines (254 loc) · 13.4 KB
/
Copy pathNew-PSUEnvironment.txt
File metadata and controls
343 lines (254 loc) · 13.4 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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
NAME
New-PSUEnvironment
SYNOPSIS
Creates a new PowerShell Universal environment.
SYNTAX
New-PSUEnvironment [-AppToken <String>] [-Arguments <String>] [-ComputerName <String>] [-Modules <String[]>] -Name <String> [-PSModulePath <String[]>] [-Path <String>] [-PersistentRunspace] [-Variables <String[]>] [-UseDefaultCredentials] [-Integrated] [-StartupScript <String[]>] [-Version <String>] [-RunspaceRecycling] [-MaxRunspaces <Int32>] [-EnableDebugger] [-Credential <Variable>] [-MaxVirtualMemory <Int64>] [-RecycleSchedule <String>] [-Description <String>] [-DisableImplicitWinCompat] [-Minimal] [-ProcessStartupScript <String>] [-Disabled] [-TrustCertificate] [-Type <EnvironmentType>] [-Verb <String>] [<CommonParameters>]
DESCRIPTION
Environments define PowerShell execution environments within PowerShell Universal. You can use them when executing APIs, Scripts, Dashboards and the security processes for authentication and authorization.
Environments are stored within the ./universal/environments.ps1 file.
You can also use this cmdlet to create environments through the REST API.
PARAMETERS
-AppToken <String>
The AppToken that is used for calling the PowerShell Universal Management API. You can also call Connect-PSUServer before calling this cmdlet to set the AppToken for the entire session.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Arguments <String>
Arguments to pass to the PowerShell process when starting the environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-ComputerName <String>
Specifies the computer name or URL that should be called when accessing the PowerShell Universal Management API. You can also use Connect-PSUServer before calling this cmdlet to set the computer name for the entire session.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases Uri
Accept wildcard characters? false
-Modules <String[]>
Modules to automatically load when creating new runspaces in the environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Name <String>
The name of the environment.
Required? true
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-PSModulePath <String[]>
Additional paths to add to the PSModulePath for the environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Path <String>
The path to the PowerShell executable.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-PersistentRunspace [<SwitchParameter>]
Whether to enable persistent runspaces. This is only used for APIs.
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Variables <String[]>
Variables to import into the runspace. These are variables defined by New-PSUVariable.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-UseDefaultCredentials [<SwitchParameter>]
Use default credentials when connecting to the management API
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Integrated [<SwitchParameter>]
Executes the command internally rather than using the Management API. Only works when running script from within PowerShell Universal.
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-StartupScript <String[]>
A script to run when creating the runspaces in this environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Version <String>
A version number to display.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-RunspaceRecycling [<SwitchParameter>]
Whether to recycle runspaces. Runspaces will be recycled (disposed and recreated) after an amount of time or a number of uses.
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-MaxRunspaces <Int32>
The maximum number of runspaces to create for this environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-EnableDebugger [<SwitchParameter>]
Enables the PowerShell debugging feature for this environment.
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Credential <Variable>
The credential to use with this environment
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-MaxVirtualMemory <Int64>
The maximum virtual memory in bytes. When the threshold is reached, the process is restarted. Ignored for the integrated environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-RecycleSchedule <String>
A CRON schedule to restart this environment. Ignored for the integrated environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Description <String>
A description for this environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-DisableImplicitWinCompat [<SwitchParameter>]
Disables Windows PowerShell Implicit Compatibility mode.
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Minimal [<SwitchParameter>]
A minimal environment that does not load any modules or variables.
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-ProcessStartupScript <String>
A script that runs once when the process starts. This is not run for each runspace.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Disabled [<SwitchParameter>]
Environment is disabled.
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-TrustCertificate [<SwitchParameter>]
Whether the cmdlet should ignore certificate issues.
Required? false
Position? named
Default value False
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Type <EnvironmentType>
The type of environment. PowerShell 7 and Windows PowerShell 5.1 are supported. Use Custom to create a custom environment
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
-Verb <String>
The verb to use when creating the process for this environment. This is not used for the integrated environment.
Required? false
Position? named
Default value None
Accept pipeline input? False
Aliases none
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
OUTPUTS
System.Object
NOTES
-------------------------- Example 1 --------------------------
PS C:\> New-PSUEnvironment -Name '7.1' -Path 'pwsh.exe'
Creates a new environment called 7.1 that uses the pwsh.exe for running APIs, scripts or dashboards.
-------------------------- Example 2 --------------------------
PS C:\> New-PSUEnvironment -Name '7.1' -Path 'pwsh.exe' -ArgumentList "-ExecutionPolicy Bypass"
Creates a new environment called 7.1 that uses the pwsh.exe executable and sets the execution policy to ByPass.
-------------------------- Example 3 --------------------------
PS C:\> New-PSUEnvironment -Name '7.1' -Path 'pwsh.exe' -ArgumentList "-ExecutionPolicy Bypass" -Variables @("*")
Creates a new environment that uses all the variables defined with New-PSUVariable.
-------------------------- Example 4 --------------------------
PS C:\> New-PSUEnvironment -Name '7.1' -Path 'pwsh.exe' -ArgumentList "-ExecutionPolicy Bypass" -Modules @("ActiveDirectory")
Creates a new environment that automatically loads the ActiveDirectory module.
-------------------------- Example 5 --------------------------
PS C:\> New-PSUEnvironment -Name '7.1' -Path 'pwsh.exe' -ArgumentList "-ExecutionPolicy Bypass" -PersistentRunspace
Creates a new environment that uses persistent runspaces. Persistent runspaces are used for APIs and do not reset between each execution.
RELATED LINKS
New-PSUVariable