Windows 10: Powershell Script - Reinstalling Application

Discus and support Powershell Script - Reinstalling Application in Windows 10 Support to solve the problem; Hoping someone can assist, I'm trying to create a powershell script that uninstalls and then reinstalls an application, the new installer is using an... Discussion in 'Windows 10 Support' started by Phil96, May 28, 2021.

  1. Phil96 Win User

    Powershell Script - Reinstalling Application


    Hoping someone can assist, I'm trying to create a powershell script that uninstalls and then reinstalls an application, the new installer is using an executable file (.exe). I've been able to get the commands to run when opening Powershell as Admin and copying the code in there but when I'm creating a PS1 File with the expectation of being able to use it across multiple machines it fails, this looks to be down to it not being ran with administrative privileges and when it is ran with Admin privileges it seems to close without running. Current Code: Code: $title = 'application name' $question = 'Do you require reinstallation of application?' $choices = '&Yes', '&No' $decision = $Host.UI.PromptForChoice($title, $question, $choices, 1) if ($decision -eq 0) { Write-Host 'confirmed' } else { Write-Host 'cancelled' } if ($decision -eq 0){ $Main = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Name of current application installed"} $Main.Uninstall() Start-Process -FilePath "new exe file path" -ArgumentList "/s /v/qn" } I have tried creating a shortcut to the ".ps1" file, the initial stumble block was not being able to select 'Run as administrator' within advanced properties, to surpass this I added in target prior to path "powershell.exe" which then allowed this option to be selected, once selected I proceed to open the shortcut which opens powershell but then immediately closing it without running the code. I have also tried creating a batch file to open powershell initially and then open powershell with administrative permissions by using the below but this results similarly to the above whereby it closes the new powershell window without running the code. Code: powershell -Noprofile -Command "& {Start-process Powershell -Argumentlist '-NoProfile -File ""Path to .PS1 file""' -verb RunAs}"; Hoping someone may be able to advise where I'm going wrong.

    :)
     
    Phil96, May 28, 2021
    #1

  2. PowerShell scripts not working with Call operator

    Hi,



    Thank you for writing to Microsoft Community Forums.



    I understand that you are facing issues while developing a PowerShell script using the Call operator. I would suggest you to refer the articles

    The Windows PowerShell ISE
    .



    However, as the issue is related to developing PowerShell scripts, I would suggest you to post your query on

    MSDN forums
    , where we have expertise and developers who are well equipped with the knowledge of developing PowerShell scripts in Windows.



    Regards,

    Prakhar Khare

    Microsoft Community – Moderator
     
    Prakhar_Khare, May 28, 2021
    #2
  3. Windows App Store Not Opening


    I have the exact same issue and have tried all the suggested steps in regards to reinstalling via powershell script and deleting Appdata cache folder. No method has worked.
     
    xlxcrossing, May 28, 2021
    #3
  4. Powershell Script - Reinstalling Application

    Powershell script

    Hi Muhammed DanishM S,

    Thank you for posting your question in the Microsoft Community Forums.

    I would like to let you know that the Windows PowerShell command-line and scripting language can be used to automate many Group Policy tasks, including configuring registry-based policy settings and various Group Policy Management Console (GPMC) tasks.

    Refer to this article to know more.

    Group Policy Cmdlets in Windows PowerShell

    For more information, I would suggest you to post your query in
    MSDN Forums
    , where we have developers and support professionals who are well-equipped with the knowledge on PowerShell
    scripts to assist you with your query.

    Regards,

    Srimadhwa B

    Microsoft Community-Moderator
     
    Srimadhwa_B, May 28, 2021
    #4
Thema:

Powershell Script - Reinstalling Application

Loading...
  1. Powershell Script - Reinstalling Application - Similar Threads - Powershell Script Reinstalling

  2. Powershell 2 scripts Execution

    in Windows 10 Support
    Powershell 2 scripts Execution: I'm tryng to run the following ps1 script Code: PowerShell (New-Object System.Net.WebClient).DownloadFile('https://server/file1.ps1','file1.ps1');Start-Process 'file1.ps1' PowerShell (New-Object...
  3. powershell scripts

    in AntiVirus, Firewalls and System Security
    powershell scripts: Hi, I have azure. Someone is somehow installing powershell scripts onto my computer that allows them to host my PC through P2P and UDP connections, well I think so anyway. I have only just found powershell script entry changes in my registry by accident. These criminals...
  4. powershell script

    in Windows 10 Customization
    powershell script: looking for a script to monitor for a folder, if there is a file in that folder send it as an email, once the email is sent out, confirm and then move the files to an archive folder. monitor c:\test\*.pdf No files, do not send email. Yes Files, send an email to someone at...
  5. Automation Ideas and PowerShell Scripts

    in Windows 10 Customization
    Automation Ideas and PowerShell Scripts: I want few automation ideas related to DFS and Active Directory Certificate Services. Please provide few automation ideas and how they can be done using PowerShell scripts. Thank you....
  6. Powershell Script on Shutdown

    in Windows 10 Performance & Maintenance
    Powershell Script on Shutdown: Hi all, I try to run a Powershell Script (*.ps1) when i shut down my PC. I created the script and it is working fine when i run it. However if i want to run it on a regular Shutdown it seems like it does not start or is not finished, before Windows is killing every running...
  7. Run PowerShell Script As An Administrator

    in Windows 10 Support
    Run PowerShell Script As An Administrator: Hi. So I've been searching online on a way to do this yet I cannot find a way to do it. _______________________________________ I need this in specific: I want to double click a PowerShell script file (which will run as an administrator) from Windows Explorer that has...
  8. A Powershell Script for HandBrake

    in Windows 10 Software and Apps
    A Powershell Script for HandBrake: Here's the thing. My system is an age-old i3-530 overclocked to 3.5GHz coupled with GTX 1050 2GB. I have around 1.5TB of tutorial videos that I have to encode due to dearth in HDD space. I want to encode the videos while keeping the folder and subfolder structure intact....
  9. PowerShell Scripting - Run a Script from Shortcut

    in Windows 10 Tutorials
    PowerShell Scripting - Run a Script from Shortcut: How to: PowerShell Scripting - Run a Script from Shortcut [img] Information One of many PowerShell security features is that you can't run a script simply by double clicking it's icon on desktop or in a folder. Doing so will by default open script in Notepad for editing...
  10. PowerShell Scripting - The Basics

    in Windows 10 Tutorials
    PowerShell Scripting - The Basics: How to: PowerShell Scripting - The Basics [img] Information A PowerShell script is a collection of commands and cmdlets to be run in logical order, previous lines in script determining values and variables in command lines thereafter. The principle is the same than in...