Debrata 1
asked on
PowerShell
I am trying to uninstall a software from Computers in the network. The script below works on my computer but when i create GPO for user log on script it does not work. can anyone help with this ?
Get-wmiobject win32_product | ?{$_.name -match "Java"} | %{$_.uninstall()}
Get-wmiobject win32_product | ?{$_.name -match "Java"} | %{$_.uninstall()}
I only assume... due to lack of info.
Why do you think it is a PS script?
:D
Probably it is but I have to exclude this as well.
Why do you think it is a PS script?
:D
Probably it is but I have to exclude this as well.
ASKER
Thanks. :D
Specify the path to the script... UNC path if the script is stored on shared media.
Specify the path to the script... UNC path if the script is stored on shared media.
ASKER
Thank you
@ Hello I am testing it on my computer first i will put the UNC path in the GPO after the script runs successfully
PS2.PNG
@ Hello I am testing it on my computer first i will put the UNC path in the GPO after the script runs successfully
PS2.PNG
I see that running PS scripts is restricted...
ASKER
@ Hello that is the point of "PowerShell.exe -ExecutionPolicy ByPass" in the script
@Shaun Vermaak do you have any idea ? I am a new to PowerShell
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6&viewFallbackFrom=powershell-Microsoft.PowerShell.Core
@Shaun Vermaak do you have any idea ? I am a new to PowerShell
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6&viewFallbackFrom=powershell-Microsoft.PowerShell.Core
You can not put a software install, uninstall as a user GPO, as the user might not gave requisite rights.
Since you are using powershell, use psexec from sysinternals to script the process.
Or use a computer GPO on shutdown or startup to run your command which will run at system privilege and has requisite rights to install/remove software.
If you use software deployment policy, commonly the package there includes an option that you can revoke and it will be uninstalled.
Since you are using powershell, use psexec from sysinternals to script the process.
Or use a computer GPO on shutdown or startup to run your command which will run at system privilege and has requisite rights to install/remove software.
If you use software deployment policy, commonly the package there includes an option that you can revoke and it will be uninstalled.
ASKER
@arnold
Thanks for the info. I add it to computer startup script GPO and linked it to the OU that has computers But the script still didn't run.
Thanks for the info. I add it to computer startup script GPO and linked it to the OU that has computers But the script still didn't run.
One to address whether the script did not run because it could not, use a bat type wrapper to trigger the power shell run.
Did the GPO refresh before system boot?
CAN YOU CONFIRM THAT RUNNING THE command as you outline in an elevated cmd window does what you expect?
Did the GPO refresh before system boot?
CAN YOU CONFIRM THAT RUNNING THE command as you outline in an elevated cmd window does what you expect?
Deploy the PowerShell to computer with GPO file preference
Create the Scheduled task with GPO schedule task preference (using NT Authority\SYSTEM as user)
Both of these actions int here
https://www.experts-exchange.com/articles/31583/Active-Directory-Securely-Set-Local-Account-Passwords.html
In Scheduled task use
Command: PowerShell.exe
Argument: -ExecutionPolicy Bypass -File "PathToYourPowerShell\Powe rShellFile .ps1"
Remember the F3 shortcut in preference to access environmental variables
Create the Scheduled task with GPO schedule task preference (using NT Authority\SYSTEM as user)
Both of these actions int here
https://www.experts-exchange.com/articles/31583/Active-Directory-Securely-Set-Local-Account-Passwords.html
In Scheduled task use
Command: PowerShell.exe
Argument: -ExecutionPolicy Bypass -File "PathToYourPowerShell\Powe
Remember the F3 shortcut in preference to access environmental variables
ASKER
Thank you all,
PowerShell is not working for me so I just used a simple batch and add it to start up GPO.
MsiExec.exe /x {ProductID} /qn
PowerShell is not working for me so I just used a simple batch and add it to start up GPO.
MsiExec.exe /x {ProductID} /qn
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
The command you provided must be saved into .PS1 file.