0

I need to be able to append everyone's deployment.properties file to add additional lines to enable all versions of TLS. Big enterprise uses multiple different versions of Java and also multiple different departments use different exceptions. I have attempted to append the file using powershell but it inserts line spaces between each letter.

this is the only PS script i found that is able to insert into the file.

echo "`r`n deployment.security.SSLv3=true" >> "c:\users\%userprofile%\AppData\LocalLow\Sun\Java\Deployment\deployment.properties"

notice it enters it after the last line and wont let me return down

Here is the code i need to insert

# Advanced Security Settings\Use TLS 1.0
deployment.security.TLSv1=true
deployment.security.TLSv1.locked
# Advanced Security Settings\Use TLS 1.1
deployment.security.TLSv1.1=false
deployment.security.TLSv1.1.locked
# Advanced Security Settings\Use TLS 1.2
deployment.security.TLSv1.2=false
deployment.security.TLSv1.2.locked
# Miscellaneous\Place Java icon in system tray
# Miscellaneous\Java Quick Starter
deployment.system.tray.icon=false
deployment.system.tray.icon.locked

I just need to know how I can do it via a script or powershell for the entire enterprise. with out replacing the original deployment.properties file and with proper formatting. Thanks guys!

1
  • To get going: $text = Get-Content -Path file; $text += "new line"; Set-Content -Path file $text -Encoding UTF8
    – Gerrit
    May 8, 2018 at 20:46

1 Answer 1

2

The $env:userprofile\AppData\LocalLow\Sun\Java\Deployment\deployment.properties" file has (presumably) ANSI (or UTF-8) encoding.

On the other hand, about_Redirection help topic says:

… When you are writing to files, the redirection operators use Unicode encoding. If the file has a different encoding, the output might not be formatted correctly…

To redirect content to non-Unicode files, use the Out-File or Add-Content cmdlet with its Encoding parameter. For instance, something like

$CodeToInsert = @'
# Advanced Security Settings\Use TLS 1.0
deployment.security.TLSv1=true
deployment.security.TLSv1.locked
# Advanced Security Settings\Use TLS 1.1
deployment.security.TLSv1.1=false
deployment.security.TLSv1.1.locked
# Advanced Security Settings\Use TLS 1.2
deployment.security.TLSv1.2=false
deployment.security.TLSv1.2.locked
# Miscellaneous\Place Java icon in system tray
# Miscellaneous\Java Quick Starter
deployment.system.tray.icon=false
deployment.system.tray.icon.locked
'@
$FilePath = "$env:USERPROFILE\AppData\LocalLow\Sun\Java\Deployment\deployment.properties"

Add-Content -Path $FilePath -Value $CodeToInsert -Encoding default

See also

Note: you can query the file.encoding property or Charset.defaultCharset() to find the current default encoding in Java.

For the entire enterprise, you could configure above script to Run Once on user logon.

1
  • I found something interesting regarding this deployment.properties file. No matter what switches you add to the end of the file (even if present elsewhere in the file) they will still change the switch to the desired value in the Java Control Panel. Java then recreates the file with the new values, and deletes the duplicate switches.
    – Eryper
    May 10, 2018 at 19:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .