Forum Discussion
charlesfors
Jul 08, 2023Copper Contributor
This script doesn't work if you double-click it. However the command inside the script works perfect
I created a Powershell script with only one command. The command is the one I show below and it works perfectly if you run the command from the Powershell console. This is the command: [System.N...
LainRobertson
Jul 09, 2023Silver Contributor
Hi, Charles.
What are you expecting to happen?
If you're expecting this command to change the system-wide default for .NET, then this is not how the class works. It only changes the session value, meaning double-clicking the PS1 only changes the value inside that script while it's running.
If that's the only command inside that PS1 then it's effectively achieving nothing since it won't impact any other processes.
You can test this for yourself using your interactive PowerShell console session:
- In your first PowerShell console, run your command to set the session to using Tls12
- Open a new PowerShell console session and simply run:
[System.Net.ServicePointManager]::SecurityProtocol
- Observe that it reflects the system default value, not the value you set in step 1 (assuming your system default isn't specified as Tls12, of course.)
Here's what the example looks like across both consoles:
Cheers,
Lain
charlesfors
Jul 09, 2023Copper Contributor
LainRobertson thank you for your explanation, it clarified several doubts.
Thank you once again, Carlos