Home > database >  '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ;\UpdateView.
'[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ;\UpdateView.

Time:06-19

I have the following inside my Power Shell PS1 file, to set Tls12 call .exe :-

Show-Message -Message "Step 1a: Create groups and adding users to it" 
    & "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $HelperPath\UpdateView.exe" "true" $Username $Password

    If ((Get-Content $ErrorLogFile) -ne $Null) {
        Show-Message -Message "Creating group and adding users to it failed" -Type ([MessageType]::Failure)
        RevertAll $ScriptDirectory 1
        return
    }

but i am getting this error:-

& : The term '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
\UpdateView.exe' is not
recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At C:\c\tree\master\cloud\src\deployments\Scripts\Deploy.ps1:352 char:7
      & "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityPro ...
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : ObjectNotFound: ([Net.ServicePoi....UpdateView.exe:String) [], CommandNotFoundException
      FullyQualifiedErrorId : CommandNotFoundException

any advice please?

CodePudding user response:

&, the call operator takes a command / executable name / path only as an argument, not whole statements.

(While it can also accept a script block { ... } containing one or more full statements, there's no need for it here, though you can generally use it to create a child scope).

Simply execute the two statements in sequence:

# Set the protocol (an assignment statement)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Call the executable (a command call).
& $HelperPath\UpdateView.exe" true $Username $Password

CodePudding user response:

You appear to be trying to combine PowerShell and call an executable in the same command, that is not something that can be done.

Even if it would work it will not have the effect you want. Enabling TLS1.2 in the PowerShell session will have no effect on the executable you then call.

  • Related