speedy
September 29, 2014, 2:04pm
1
I wanted a way to set some properties with spark without overwriting the users preferences. Here is the solution I came up with.
There are a few assumptions made. First you have powershell install on the workstation, that spark.properties is in the same location for everyone.
create a powershell script with the following, and then run it at logon script via GPO.
$updates=@{
‘ssoEnabled’=‘true’
‘server’=‘xmppserver.com ’
‘autoLoginEnabled’=‘true’
‘toasterPopup’=‘true’
‘windowTakesFocus’=‘true’
}
(Get-Content $env:APPDATA\spark\spark.properties) |
ForEach-Object{
$key=$_.Split(’=’)[0]
if($val=$updates[$key]){
‘{0}={1}’ -f $key,$val
}else{
$_
}
} |
Set-Content $env:APPDATA\spark\spark.properties
That’s it. Hope this helps
wroot
September 29, 2014, 2:27pm
2
It is not actually enforcing, as they can change it after the login. I have done it a while ago for Exodus properties file (xml) with a vbs script, can be applied to Spark:
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objFolder = objFSO.GetFolder(“E:\Admin\Exodus”)
RepSubfolders objFolder
Sub RepSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Set objFile = objFSO.OpenTextFile(Subfolder & “\exodus.xml”, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, “192.168.12.41”, “jiveserver”)
Set objFile = objFSO.OpenTextFile(Subfolder & “\exodus.xml”, ForWriting)
objFile.WriteLine strNewText
objFile.Close
Set objFile = objFSO.OpenTextFile(Subfolder & “\exodus.xml”, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, “false”, “true”)
Set objFile = objFSO.OpenTextFile(Subfolder & “\exodus.xml”, ForWriting)
objFile.WriteLine strNewText
Next
End Sub
wroot
September 29, 2014, 2:28pm
3
Well, in this vbs you have to know what the altered text is, so it won’t work in all scenarios probably.
speedy
September 29, 2014, 2:35pm
4
You’re right, its not true enforcement, but I think it will get the job done for the most part. Maybe I should change the title up a bit!