Skip to content

Instantly share code, notes, and snippets.

@xoner
Created April 17, 2014 09:56
Show Gist options
  • Save xoner/10970093 to your computer and use it in GitHub Desktop.
Save xoner/10970093 to your computer and use it in GitHub Desktop.
Java security options deployer
$javaDeployment = ''
$profilesDir = ''
## We are runnig Windows Vista, 7, 8 , Server 2008, 2008 R2, 2012 or highter
if ([System.Environment]::OSVersion.Version.Major -ge 6)
{
Write-Host -ForegroundColor Green "OS Windows Vista, 7, 2008, 2008R2 or highter"
$javaDeployment = 'AppData\LocalLow\Sun\Java\Deployment'
$profilesDir = 'C:\Users'
}
# We are running Windows XP or server 2003 (spanish localized)
elseif ([System.Environment]::OSVersion.Version.Major -eq 5)
{
Write-Host -ForegroundColor Green "OS Windows XP or 2003"
$javaDeployment = 'Datos de Programa\Sun\Java\Deployment'
$profilesDir = 'C:\Documents and Settings'
}
else
{
Write-Host -ForegroundColor Red "OS not supported"
exit
}
$templFolder = [System.IO.Path]::Combine($env:USERPROFILE, $javaDeployment)
foreach($item in (ls $profilesDir))
{
if($item.PSIsContainer)
{
$userDestDir = [System.IO.Path]::Combine($item.FullName, $javaDeployment);
#echo $userDestDir;
if ((Test-Path "$userDestDir") -and ($item.FullName -ne $env:USERPROFILE))
{
echo "$($item.FullName) has sun deployment";
$configPathTmpl = $templFolder + '\deployment.properties'
$urlExceptionPathTmpl = $templFolder + '\security\exception.sites';
cp -Force $configPathTmpl $userDestDir
cp -Force $urlExceptionPathTmpl $($userDestDir + '\security')
echo ""
echo ""
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment