locked
Uninstall OSSEC Agent with PSEXEC Powershell Script RRS feed

  • Question

  • I'm looking to uninstall ossec agents on multiple machines through the use of Powershell and psexec.. Any ideas as to why this won't work? I want to make this a silent uninstall as well.. If you know of a better way - please let me know.. 

    #List of Servers that need OSSEC uninstalled
    
    $OSSEC_Servers = Get-Content "C:\users\USERNAME\desktop\uninstall\OSSECUNINSTALL.txt"
    
    
    #Begins Ping status for Servers #Connects PSexec
    foreach ($Server in $OSSEC_Servers)
    {
    
    Write-Host "Starting Control for Computer $Server at $starttime `n" -ForegroundColor Cyan -BackgroundColor DarkBlue | out-default
    $pingStatus = Get-WmiObject -Query "Select * from win32_PingStatus where Address='$Server'"
    if($pingStatus.StatusCode -eq 0) 
    {
    Write-Host "Ping Control for Computer $Server at $starttime successfully. Now connecting PSEXEC `n" -ForegroundColor Cyan -BackgroundColor DarkBlue | out-default
    C:\Scripts\PsExec.exe \\$Servers\C:\Program Files (x86)\ossec-agent\uninstall.exe
    }
    }

    Monday, May 22, 2017 7:52 PM

All replies

  • You cannot use a network file.  The file must be local to the computer you are trying to run it on.


    \_(ツ)_/

    • Proposed as answer by Hello_2018 Monday, June 5, 2017 2:00 AM
    Monday, May 22, 2017 8:13 PM
  • Hi,
    Was your issue resolved? 
    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.
    Best Regards,
    Andy

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, June 5, 2017 2:01 AM