-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Create the default PSSession configuration, not tied to a specific PowerShell version. #6519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
2945dcd
[Feature] Create the default PSSession configuration, not tied to a s…
kalgiz f63fa87
[Feature] Tests for Enable-PSRemoting
kalgiz 1cc6d32
[Feature] Enable-PSRemoiting command fix.
kalgiz b200048
[Feature] Enable-PSRemoting, dealing with corner case added.
kalgiz 969f611
[Feature] Remoting tests correction
kalgiz 0701ed2
[Feature] Install-PowerShellRemoting script adds the configuration na…
kalgiz e73c156
Merge branch 'master' of https://github.com/kalgiz/PowerShell into re…
kalgiz d545c92
[Feature]
kalgiz f280922
[Feature] Correcting tests for non Windows platforms.
kalgiz 6beafc0
commit
kalgiz 0f375d2
Merge branch 'master' of https://github.com/PowerShell/PowerShell int…
kalgiz 67a8772
[Feature] Not overwriting existing session by command Enable-PSRemoting.
kalgiz a30542d
[Feature] Enable-PSRemoting command correction.
kalgiz a9da476
Merge branch 'master' of https://github.com/kalgiz/PowerShell into re…
kalgiz cb19b50
Merge branch 'master' of https://github.com/PowerShell/PowerShell
kalgiz 3c0fa49
Merge branch 'master' of https://github.com/kalgiz/PowerShell
kalgiz 3fcb173
Merge branch 'master' of https://github.com/kalgiz/PowerShell into re…
kalgiz d9782a3
[Feature] Comments for endpoints' name clarifications added.
kalgiz 4a8b4c5
Merge branch 'master' of https://github.com/PowerShell/PowerShell
kalgiz 9d81797
Merge branch 'master' of https://github.com/kalgiz/PowerShell
kalgiz 9dfa552
Merge branch 'master' of https://github.com/PowerShell/PowerShell
kalgiz 95474a0
Merge branch 'master' of https://github.com/kalgiz/PowerShell into re…
kalgiz 1836dca
Code fixes.
kalgiz 7b2af9f
Set-StrictoMode Latest added to the psremoting scripts.
kalgiz 4247332
Merge branch 'master' of https://github.com/PowerShell/PowerShell
kalgiz 412ca3a
Merge branch 'master' of https://github.com/kalgiz/PowerShell
kalgiz f4a9ade
and ShouldProcess in Intall-PowerShellRemoting script.
kalgiz dd00e2c
Enable-PSRemoting corrections after running SA.
kalgiz ba55e12
-ErrorAction Stop in Install-PowerShellRemoting module.
kalgiz 7c4560b
-ErrorAction Stop used for commands in Enable-PSRemoting definition.
kalgiz 21fd7ae
check for administrator rights moved to the beginning of the script.
kalgiz 5f3a58a
Merge branch 'master' of https://github.com/PowerShell/PowerShell
kalgiz 701e6ff
Merge branch 'master' of https://github.com/kalgiz/PowerShell into re…
kalgiz 40f98ff
Merge branch 'master' of https://github.com/PowerShell/PowerShell
kalgiz 1d6e199
Merge branch 'master' of https://github.com/kalgiz/PowerShell into re…
kalgiz b8517e7
[Feature] Write-Error if Install-PowerShellRemoting is called without…
kalgiz e0f15c4
Merge branch 'master' of https://github.com/kalgiz/PowerShell into re…
kalgiz 26046c5
Merge branch 'remoting-conf-name' of https://github.com/kalgiz/PowerS…
kalgiz f7b0127
Correcting erorr appearing because of the Strict Mode
kalgiz 479a2dc
[Feature] Write-Error with -Category and -ErrorId parameters.
kalgiz 0c74b16
[Feature] Remove check of the value of non assigned variable.
kalgiz 9aa27fb
Merge branch 'master' of https://github.com/PowerShell/PowerShell
kalgiz aede937
Merge branch 'master' of https://github.com/kalgiz/PowerShell
kalgiz f01b4ca
Merge branch 'master' of https://github.com/kalgiz/PowerShell into re…
kalgiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Feature] Not overwriting existing session by command Enable-PSRemoting.
- Loading branch information
commit 67a87729f4e16b223a5f92e9ac2e6bb2a2f5152b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4867,6 +4867,39 @@ function Register-Endpoint | |
restart-service winrm -confirm:$false | ||
}} | ||
|
||
function Register-EndpointIfNotPresent | ||
{{ | ||
param( | ||
[Parameter()] [string] $configurationName | ||
) | ||
# | ||
# This cmdlet will make sure default powershell end points exist upon successful completion. | ||
# | ||
# Windows PowerShell: | ||
# Microsoft.PowerShell | ||
# Microsoft.PowerShell32 (wow64) | ||
# | ||
# PowerShell Core: | ||
# PowerShell.<version ID> | ||
# | ||
$errorCount = $error.Count | ||
$endPoint = Get-PSSessionConfiguration $configurationName -Force:$Force -ErrorAction silentlycontinue 2>&1 | ||
$newErrorCount = $error.Count | ||
|
||
# remove the 'No Session Configuration matches criteria' errors | ||
for ($index = 0; $index -lt ($newErrorCount - $errorCount); $index ++) | ||
{{ | ||
$error.RemoveAt(0) | ||
}} | ||
|
||
$qMessage = $queryForRegisterDefault -f ""$configurationName"",""Register-PSSessionConfiguration {0} -force"" | ||
if ((!$endpoint) -and | ||
($force -or $pscmdlet.ShouldProcess($qMessage, $captionForRegisterDefault))) | ||
{{ | ||
Register-Endpoint $configurationName | ||
}} | ||
}} | ||
|
||
function Enable-PSRemoting | ||
{{ | ||
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact=""Medium"")] | ||
|
@@ -4895,40 +4928,15 @@ function Enable-PSRemoting | |
# first try to enable all the sessions | ||
Enable-PSSessionConfiguration @PSBoundParameters | ||
|
||
# | ||
# This cmdlet will make sure default powershell end points exist upon successful completion. | ||
# | ||
# Windows PowerShell: | ||
# Microsoft.PowerShell | ||
# Microsoft.PowerShell32 (wow64) | ||
# | ||
# PowerShell Core: | ||
# PowerShell.<version ID> | ||
# | ||
$errorCount = $error.Count | ||
$endPoint = Get-PSSessionConfiguration {0} -Force:$Force -ErrorAction silentlycontinue 2>&1 | ||
$newErrorCount = $error.Count | ||
|
||
# remove the 'No Session Configuration matches criteria' errors | ||
for ($index = 0; $index -lt ($newErrorCount - $errorCount); $index ++) | ||
{{ | ||
$error.RemoveAt(0) | ||
}} | ||
|
||
$qMessage = $queryForRegisterDefault -f ""{0}"",""Register-PSSessionConfiguration {0} -force"" | ||
if ((!$endpoint) -and | ||
($force -or $pscmdlet.ShouldProcess($qMessage, $captionForRegisterDefault))) | ||
{{ | ||
Register-Endpoint {0} | ||
}} | ||
Register-EndpointIfNotPresent {0} | ||
|
||
# Create the default PSSession configuration, not tied to any specific PowerShell version. | ||
$powershellNr = $PSVersionTable.PSVersion.ToString() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to $powershellVersionMajor. |
||
$dotPos = $powershellNr.IndexOf(""."") | ||
if ($dotPos -ne -1) {{ | ||
$powershellNr = $powershellNr.Substring(0, $dotPos) | ||
}} | ||
Register-Endpoint (""PowerShell."" + $powershellNr) | ||
Register-EndpointIfNotPresent (""PowerShell."" + $powershellNr) | ||
|
||
# PowerShell Workflow and WOW are not supported for PowerShell Core | ||
if (![System.Management.Automation.Platform]::IsCoreCLR) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, please add an example name in the comment to illustrate how the endpoint name should look. I think this will help other developers reading the code.
8000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added.