I’m currently working on a small project that will use constrained remoting endpoints together with RunAs credentials. It all went fine until I decided to change part of configuration for a moment to test something. I’m using PSSession Configuration Files all the time, so I decided I will create a new one, different from the one used before and just change configuration of endpoint using Set-PSSessionConfiguration cmdlet.
I tried once, twice… but nothing really changed. And eventually it hit me.
When you create new configuration file with cmdlet designed for it and you do not specify GUID for this file – PowerShell will generate one for you. It’s fine when you are registering new configuration. But when you are trying to change existing one with it you will get no results (errors, warnings). And it won’t work either. Why? Well, GUID of the new configuration file has to match with GUID of registered configuration, that’s all… It may sound obvious, but took me a few minutes to figure it out. Eventually I used snippet like that to create configuration file “valid” for updating my endpoint X:
$Options = @{ Path = 'NewConfig.pssc' GUID = (Get-PSSessionConfiguration -Name X).GUID } New-PSSessionConfigurationFile @Options
Once I’ve edited the file and made necessary changes I could use it to set configuration for my endpoint.