I am making a small script for uninstalling the 7 Zip software from my servers, for that I have to find the 7 Zip software and un-install using the script.
On some windows servers I am able to find the software however on many of them I am unable to find them although they are installed as I can see it from the appwiz.cpl.
I cannot use Get-ItemProperty
remotely, as WinRM is not configured correctly in the environment. So being too lazy I am trying create a powershell script to find the 7 Zip software and uninstall it.
$servers= Get-Content "C:\Server.txt"
Foreach($server in $servers)
{
$ZipSoft= get-wmiobject win32_Product | where {$_.Name -like "*7-Zip*"}
$ZipSoft.Uninstall()
}
I have tried to find individually on those servers however it does not gives me the output even no errors, other installed software I can find using the above. Any idea about this why I am not able to find it on those servers?
The wmi class win32_product is slow and incomplete. It may only list msi installs. It also verifies every msi when it runs.
get-package 7-zip* # powershell 5 only
Name Version Source ProviderName
---- ------- ------ ------------
7-Zip 19.00 (x64) 19.00 Programs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.