Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

script does not uninstall java nor output to text file

$
0
0

I have this powershell script made and the following provided for information:

this is a non standard install for Java that has to be installed from a script.  basically this script will run against a given amount of servers, stop the required services ( pertains to the application that requires Java on the server), uninstall java, install java, configure java with correct parameters and security permissions then lastly output a log file to the server that is running the script (folder) of each server .  each server will have thier own text file.   so two issues first java uninstalls but does not install due to a permissions error, and the other  issue that is occuring is there should be a log file for each server the log file will have the server name as the file namey, the script will look at the server list and run the code on that server so basically the script will run at the same time on all the servers, and create log file for each server and put in the folder i designate.  - this is not occuring based on the Powershell script below. what parameter is missing below. thanks

 

 

$user = Read-Host 'Username:'
$pass = Read-Host 'Password:'
$result = "D:\Temp\" + $env:COMPUTERNAME +"_JavaUpdate.log"
$copyfinal = "\\wsive005pap\d$\BatchFiles\Java_Update\"

#Stop NCSB and Tomcat Services
Stop-Service Tomcat7
Stop-Service "NuanceCSB"

#Uninstall Java
Get-WmiObject -Class win32_product | ? {$_.Vendor -like "*Oracle*"} | % {msiexec /x "$($_.IdentifyingNumber)" /qn | Out-Null}
Start-Sleep -s 120
"Java 7 Uninstalled" | Out-File $result -append

#Install Java
$JRE = "D:\Installations\NVP 4.0 Install\jre-7u76-windows-i586.exe"

& $JRE /s INSTALLDIR=D:\Apps\Progra~1\Java\jre7\ /l D:\Temp\javainstall.log | Out-Null
Start-Sleep -s 240
"Java 7 Installed" | Out-File $result -append

#Configure Java
$pattern = "security.provider.10=sun.security.mscapi.SunMSCAPI"
$javasec = "D:\APPS\Program Files (x86)\Java\jre7\lib\security\java.security"
$viecore = "security.provider.11=cryptix.provider.Cryptix"

(Get-Content $javasec) |
    Foreach-Object{
        if($_ -match $pattern)
        {
            $_ 
            $viecore
        } else {
            $_ 
        }    
     } | Set-Content $javasec
"Java Configured" | Out-File $result -append

#Start NCSB and Tomcat Services
Start-Service Tomcat7
Start-Service "NuanceCSB"

#Updating log files and push to the central server
$javaver = gci "D:\APPS\Program Files (x86)\Java\jre7\bin\java.exe"
$tomcatver = "D:\APPS\Program Files (x86)\Apache Software Foundation\Tomcat 7.0_Tomcat7\lib\catalina.jar"

"*****Check Java and Tomcat Version*****" | Out-File $result -append
& $javaver -cp $tomcatver org.apache.catalina.util.ServerInfo | Out-File $result -append
"*****Check Services Started*****" | Out-File $result -append
Get-Service | Where-Object {$_.Name -eq "NuanceCSB"} | Out-File $result -append
Get-Service | Where-Object {$_.Name -eq "Tomcat7"} | Out-File $result -append
"*****Check Java Security File*****" | Out-File $result -append
Select-String -Path $javasec -Pattern "cryptix" | Out-File $result -append
"*****Print log file for CTI connections*****" | Out-File $result -append
Get-Content "D:\APPS\NuanceCSB\logs\stdout.log" | Out-File $result -append
"*****Print log file for connector*****" | Out-File $result -append
Get-Content "D:\APPS\NuanceCSB\logs\CSB.log" | Out-File $result -append


NET USE \\wsive005pap\d$ $pass /user:CORP\$user
Copy-Item $result $copyfinal
NET USE \\wsive005pap\d$ /delete

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles