Uninstall packages (3rd party anti virus) in windows 10 using powershell - windows

I am trying to uninstall packages using the PowerShell command and script. Every time I run the command it runs and does nothing moreover can't find any logs of it. I tried Microsoft documentation https://learn.microsoft.com/en-us/powershell/module/packagemanagement/uninstall-package?view=powershell-7.1 In stack overflow similar problem Powershell: Find installed Antivirus, filtering out Windows Defender to find the installed antivirus. But When I want to uninstall it simply does nothing.
# Get-Package -Provider Programs -IncludeWindowsInstaller
$appToRemove = Get-Package -IncludeWindowsInstaller -Name Avast
Write-Output $appToRemove
Uninstall-Package $appToRemove -Force -AllVersions -Confirm
I have tried several solutions and stuck for 1 week. Can anyone please help me? Thank you.

Related

Microsoft Deployment Workbench chocolatey problem

I am currently testing Microsoft Deployment Workbench for automated Windows installation.
I have created a workflow with Windows 11 and would like to install the various programs via chocolatey after the Windows 11 installation.
Here you can see my workflow:
chocolatey is installed with a .bat script using:
command line: cmd.exe /c "%SCRIPTROOT%\BTNHD\chocoinstall.bat"
with the following content:
#powershell -noProfile -ExecutionPolicy unrestricted -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
then we restart the computer
then the script is started with the different programs, which looks like this:
command line: cmd.exe /c "%SCRIPTROOT%\BTNHD\installtemplate.bat"
with the following content:
choco install firefox --yes
choco install vlc --yes
Unfortunately it installs only the first software in the list at step 3, in my case Firefox and after that it takes a while and aborts with these error messages:
Now I have already tried the following things:
the reboot removed unfortunately no improvement
for each program a separate script and accordingly a separate installation step
tested other programs
changed the script
unfortunately there is nothing in the chocolatey log that can help me.
If I start the script manually, but everything works fine.
I currently do not know what to do and hope someone can help me, if there is any information missing, please let me know.
Thank you!

GPUdate PS Commandlet

I'm having an issue with this script. For some reason, it was working previously and now it is not. It is now returning with:
Invoke-GPUpdate : The term 'Invoke-GPUpdate' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
Write-Host "Refreshing Group Policies on the local machine......."
Invoke-GPUpdate -Computer $computer -RandomDelayInMinutes 0 -force ForegroundColor Cyan
Start-Sleep -s 20
Invoke-GPUpdate is part of the GroupPolicy module. GroupPolicy is not available by default, but is included with RSAT Tools. What likely happened is a major update to Windows occurred and in this case, if RSAT Tools isn't installed as a Windows Feature (it is only available as a "Feature on Demand" beginning with the Windows 10 October 2018 Update, which is build 17763), it will get removed during the update and needs to be re-installed.
This technically happens with the feature as well I believe, as RSAT Tools is still linked to specific versions of Windows, but the upgrade process will re-install the feature if it was already present.
Installing GroupPolicy RSAT Tools as a feature with Windows PowerShell
If you have Windows 1809 or newer, you can install as a feature using the following command:
Get-WindowsCapability -Name 'Rsat.GroupPolicy.*' -Online | Where-Object { $_.State -ne 'Installed' } | Add-WindowsCapability -Online
You can do the same with other RSAT Tools as well (the features are modularized per their functionality). To enumerate all of them:
Get-WindowsCapability -Name RSAT*
Once again, this requires Windows 1809 or newer or the features will be unavailable. You'll have to install it by using the MSU provided by Microsoft for your Windows version.

Alternative way to install Message Queuing (MSMQ)

I have Windows 10 and "Turn Windows Features on or off" is empty.
So I can't add/install MSMQ using it.
I don't know when "Windows Features" window become this (empty) so I can't use Windows Restore (I don't know what date to choose and I've installed some programs last days so I don't want to use it anyway)
Is there an alternative way to enable MSMQ?
Run Windows PowerShell as Administrator.
To get a list of available features, Type Get-WindowsOptionalFeature -online | ft
Enable-WindowsOptionalFeature -online -FeatureName XXXXXX
Replace XXXXXX with the feature you wish to enable.
Yeah.. "Windows Features & Installed updates" empty/blank issue should be fixed anyway. Pretty easy Solution (works 100%):
download iso of your Win OS, for e.g. Windows 10 -
https://www.microsoft.com/en-us/software-download/techbench - free
to download any Win 10 from official MS servers..
just open this iso, run Setup.exe (windows explorer can easily open iso files itself, so you don't need flash device or dvd) and just update your OS:
your files, installed programs/apps will not be removed :) it just reinstalls system files
source: https://support.microsoft.com/ru-ru/kb/957310 - check
"Способ 4. Выполнить обновление на месте" - yeah it's in Russian and I don't know why English version doesn't have it...
https://support.microsoft.com/en-hk/kb/957310
p.s.
sfc /scannow or DISM.exe /Online /Cleanup-image /Restorehealth- none of this helped me, but you could try it first and see if it helps
you can also try MS "System Update Readiness" tool https://support.microsoft.com/en-hk/kb/947821 (I didn't use it but mb it also can fix it)

Chocolatey setup on USB drive

I'm trying to set up Chocolatey for the first time. My ultimate goal is to be able to install the packages on a USB drive which shows up in my computer as F: so following the directions in the Chocolatey wiki, I created a folder on the F drive called Chocolatey and set an environmental variable ChocolateyInstall to F:/Chocolatey. I followed the basic directions, by opening up a command prompt and then pasting in the following.
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
After installation I went to the PowerShell command prompt as follows and tried to install Notepad++ I got the following:
C:\Windows\system32>cinst notepadplusplus
The filename, directory name, or volume label syntax is incorrect.
How can I fix this problem?
It appears that you went to a custom location with Chocolatey's install. When it finished the install, did it say it was installed on F:/chocolatey? Is it actually installed there? If so, take a look at your path environment variable and see if that is included in the path. Also close and reopen the shell/command line. Does it work now? If the path (user PATH) has the choco location in it and the shell/command line is not proper after reloading, then reboot and see if that fixes the issue.
If all of that is good, type just chocolatey /? and see what you get. Then try cinst again. If it has issues again, try cinst pkgname -debug and see where the error happens.
NOTE: Trying to install Chocolatey to a USB drive is not a supported case. Sure you might be able to get it to work but I'm not sure what you really gain. Say you install Notepad++, now it is installed to the system (not the USB drive). What do you gain by having the choco repository on the USB drive?

powershell : has anyone tried to install powershell on windows 2000 server?

Has anyone tried installing powershell on a Windows 2000 server? I realize its not supposed to be installed on windows 2000 server and therefore not supported; however the vbscript that runs on it takes 3.5 days to complete which powershell could probably finish in lesser time. Nevertheless, I noticed it just requires .NET 2.0 to run.
thanks in advance.
If you have administrator access to the Windows 2000 server in question, you could run PowerShell on a supported machine in the same domain and use set-location to change your working directory to the remote server
cd \\remoteserver\<drive>$\path\to\folder\you\want\to\start\in
You could then run whatever PowerShell script you want on the remote directory. If the folder you are starting in is shared, it is even simpler (you won't need to access the admin share). Or you could map a drive on your machine with PowerShell that links to the target directory.
This might be a smoother option than forcing an install on a non-supported machine.
Yes. This works. Instead of installing Powershell on the server, just remotely talk to it like :-
Set-Location "\\MyServer\D$\wwwportal\MyChangedFileFolder\"
Get-ChildItem -filter *.txt -Recurse

Resources