Skip to content

Commit fd25170

Browse files
Git Markup fix attempt
1 parent 4f6bbbd commit fd25170

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

reference/6/Microsoft.PowerShell.Core/New-PSSessionConfigurationFile.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,19 @@ Customized sessions that include the cmdlets, functions and scripts that technic
6969
### Example 2: Restricting Language in a Session
7070

7171
The first pair of commands uses the **New-PSSessionConfigurationFile** cmdlet to create two session configuration files. The first command creates a no-language file. The second command creates a restricted-language file. Other than the value of the *LanguageMode* parameter, the session configuration files are equivalent.
72+
7273
```powershell
7374
New-PSSessionConfigurationFile -Path .\NoLanguage.pssc -LanguageMode NoLanguage
7475
New-PSSessionConfigurationFile -Path .\RestrictedLanguage.pssc -LanguageMode RestrictedLanguage
7576
```
77+
7678
The second pair of commands uses the configuration files to create session configurations on the local computer.
79+
7780
```powershell
7881
Register-PSSessionConfiguration -Path .\NoLanguage.pssc -Name NoLanguage -Force
7982
Register-PSSessionConfiguration -Path .\RestrictedLanguage.pssc -Name RestrictedLanguage -Force
8083
```
84+
8185
The third pair of commands creates two sessions, each of which uses one of the session configurations that were created in the previous command pair.
8286

8387
```powershell
@@ -86,6 +90,7 @@ $RestrictedLanguage = New-PSSession -ComputerName Srv01 -ConfigurationName Restr
8690
```
8791

8892
The seventh command uses the Invoke-Command cmdlet to run an If statement in the no-Language session. The command fails, because the language elements in the command are not permitted in a no-language session.
93+
8994
```powershell
9095
Invoke-Command -Session $NoLanguage {if ((Get-Date) -lt "1January2014") {"Before"} else {"After"} }
9196
The syntax is not supported by this runspace. This might be because it is in no-language mode.
@@ -96,10 +101,12 @@ The syntax is not supported by this runspace. This might be because it is in no-
96101

97102
The eighth command uses the **Invoke-Command** cmdlet to run the same If statement in the restricted-language session.
98103
Because these language elements are permitted in the restricted-language session, the command succeeds.
104+
99105
```powershell
100106
Invoke-Command -Session $RestrictedLanguage {if ((Get-Date) -lt "1January2014") {"Before"} else {"After"} }
101107
Before
102108
```
109+
103110
The commands in this example compare a no-language session to a restricted-language session.
104111
The example shows the effect of using the *LanguageMode* parameter of **New-PSSessionConfigurationFile** to limit the types of commands and statements that users can run in a session that uses a custom session configuration.
105112

@@ -108,10 +115,13 @@ To run the commands in this example, start Windows PowerShell by using the Run a
108115
### Example 3: Changing a Session Configuration File
109116

110117
The first command uses the **New-PSSessionConfigurationFile** cmdlet to create a session configuration file that imports the required modules
118+
111119
```powershell
112120
New-PSSessionConfigurationFile -Path .\New-ITTasks.pssc -ModulesToImport Microsoft*, ITTasks, PSScheduledJob
113121
```
122+
114123
The second command uses the **Set-PSSessionConfiguration** cmdlet to replace the current .pssc file with the new one. Changes to the session configuration affects all sessions created after the change is completed.
124+
115125
```powershell
116126
Set-PSSessionConfiguration -Name ITTasks -Path .\New-ITTasks.pssc
117127
```
@@ -125,15 +135,20 @@ Previously, these sessions had only the core modules and an internal "ITTasks" m
125135
The first command uses the Get-PSSessionConfiguration command
126136
to get the path of the configuration file for the ITConfig session configuration.
127137
The path is stored in the **ConfigFilePath** property of the session configuration.
138+
128139
```powershell
129140
(Get-PSSessionConfiguration -Name ITConfig).ConfigFilePath
130141
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\ITConfig_1e9cb265-dae0-4bd3-89a9-8338a47698a1.pssc
131142
```
143+
132144
To modify the session configuration copy of the configuration file, you might have to change the file permissions. In this case, the current user, who is a member of the Administrators group on the system, was explicitly granted full control of the file by using the following method: Right-click the file icon, and then click Properties. On the Security tab, click Edit, and then click Add. Add the user, and then, in the Full control column, click Allow.Now the user can modify the file. A new slst alias for the Select-String cmdlet is added to the file.
145+
133146
```powershell
134147
AliasDefinitions = @(@{Name='slst';Value='Select-String'})
135148
```
149+
136150
The second command uses the Test-PSSessionConfigurationFile cmdlet to test the edited file. The command uses the *Verbose* parameter, which displays the file errors that the cmdlet detects, if any.In this case, the cmdlet returns $True, which indicates that it did not detect any errors in the file.
151+
137152
```powershell
138153
Test-PSSessionConfigurationFile -Path (Get-PSSessionConfiguration -Name ITConfig).ConfigFilePath
139154
True

0 commit comments

Comments
 (0)