How to Stop a PowerShell Script From Restarting A Server After Running

Welcome Forums General PowerShell Q&A How to Stop a PowerShell Script From Restarting A Server After Running

Viewing 1 reply thread
  • Author
    Posts
    • #272644
      Participant
      Topics: 4
      Replies: 12
      Points: 43
      Rank: Member

      Hi All I am running a PowerShell Script to Uninstall VMware Horizon Client on Servers but when it completes the uninstall it automatically restarts the server.

      How can I get the script to run and perform the uninstall without automatically restarting the servers?

      Below is the script I am using to perform the uninstall.

      #####################################Assumed Actions##############################################
      ## This script is running on a computer that is known to have the software we’re looking for on it
      ##################################################################################################

      ## Code from our “finding the old application script”
      $InstalledProduct = Get-WmiObject -Namespace ‘root\cimv2\sms’ -Class SMS_InstalledSoftware
      $VMwareHorizonClient = $InstalledProduct | where { ($_.ARPDisplayName -Like ‘VMware Horizon Client’) }

      ## Check out the object to see how we can referencce the LocalPackage (cached MSI)
      $VMwareHorizonClient

      ## Create the code to put in our software upgrade script
      ## To make the uninstall silent an extremely common set of switches for the msiexec is /qn (quiet with no interface)
      $CachedMSI = $VMwareHorizonClient.LocalPackage

      ## The cached MSI’s Path is always in the LocalPackage property under each instance in SMS_InstalledSoftware
      Start-Process ‘msiexec.exe’ -ArgumentList “/x $CachedMSI /qn” -Wait -NoNewWindow

    • #272662
      Participant
      Topics: 4
      Replies: 98
      Points: 442
      Helping Hand
      Rank: Contributor

      This will be handled best with switches in the MSI arguments.

      https://docs.microsoft.com/en-us/windows/win32/msi/standard-installer-command-line-options

Viewing 1 reply thread
  • You must be logged in to reply to this topic.