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
CodePudding user response:
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.