0

I have the following PS1 code:-

cd $HelperPath
    #----------------------------------------------
    # Create configuration lists in central repository in SharePoint
    #----------------------------------------------
    Show-Message -Message "Step 1a: Create groups and adding users to it" 
    & "$HelperPath\Microsoft.Legal.MatterCenter.CreateGroups.exe" "true" $Username $Password

Now i want to add [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 before calling the .exe file,, so how the final syntax should be? for example something as follow??

Show-Message -Message "Step 1a: Create groups and adding users to it"      & "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $HelperPath\Microsoft.Legal.MatterCenter.CreateGroups.exe" "true" $Username $Password 
4
  • 1
    Put a semi-colon ; between the two commands Commented Jun 19, 2022 at 8:59
  • 1
    Unsure if you specifically need TLS 1.2, but I would go with [Net.SecurityProtocolType]::Tls13 instead if your system supports it. Commented Jun 19, 2022 at 9:09
  • @Theo thanks, i wrote the following syntax Show-Message -Message "Step 1a: Create groups and adding users to it"& "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; $HelperPath\Microsoft.Legal.MatterCenter.CreateGroups.exe" "true" $Username $Password but got this error The term '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ;C:\c\tree\master\cloud\src\deployments\Scripts\Helper Utilities\Microsoft.Legal.MatterCenter.UpdateView.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Commented Jun 19, 2022 at 11:02
  • @BoogaRoo can you please provide the exact syntax to amend my code? Commented Jun 19, 2022 at 11:12

1 Answer 1

1

In this case I would suggest just putting it on a line by itself above the call to the executable:

cd $HelperPath
    #----------------------------------------------
    # Create configuration lists in central repository in SharePoint
    #----------------------------------------------
    Show-Message -Message "Step 1a: Create groups and adding users to it"
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13
    & "$HelperPath\Microsoft.Legal.MatterCenter.CreateGroups.exe" "true" $Username $Password

If you really must have it on a single line as described in the question, you can put a semicolon between each statement:

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

Also, I would suggest using TLS 1.3 if your system supports it. I've included that in the code here.

Sign up to request clarification or add additional context in comments.

2 Comments

Roook will try both, but for the first syntax should i write it with out "" ?
Yes. There is no need to enclose the TLS command in quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.