Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Changing Path before changing PSSessionConfiguration damages WinRM service #31

Open
jnury opened this issue Nov 17, 2017 · 0 comments
Open
Labels

Comments

@jnury
Copy link
Contributor

jnury commented Nov 17, 2017

On Windows Server 2012 R2:

PS > $psversiontable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

WinRM will be (definitevly) damaged if you run the following script:

Configuration Config  {
    Param (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [String[]]
        $NodeName
    )

    Import-DSCResource -ModuleName 'PSDesiredStateConfiguration'

    Node $NodeName {

        Environment PathJava {
            Name      = "PATH"
            Value     = "%JAVA_HOME%\bin"
            Path      = $true
            Ensure    = "Present"
        }

        Script PSSessionConfig {
        SetScript = {
                $psscPath = "C:\TestJEA.pssc"
                $configurationFileArguments = @{
                    Path                = $psscPath
                    RoleDefinitions     = @{ 'Everyone' = @{ VisibleCmdlets = 'Get-*' } }
                    RunAsVirtualAccount = $true
                    SessionType         = 'RestrictedRemoteServer'
                }
                New-PSSessionConfigurationFile @configurationFileArguments
                Register-PSSessionConfiguration -Name 'TestJEA' -Path $psscPath
            }

            TestScript = {
                return $false
            }

            GetScript = {
                return @{ }
            }
        }
    }
}
Config -NodeName localhost 
Start-DscConfiguration -Path .\Config -Wait -Verbose

After that, WinRM service configuration seems to be corrupted and starting the service lead to that message:
winrm

I did not find any way of getting the service back to life (except VM snapshot reverse ;-))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants