So I'm trying to remotely uninstall the application SysTrack using:
wmic product where "description='Systems Management Agent' " uninstall
but for some reason it can't find the product. Doing a
product get name
from the wmic:root console, I don't see it listed. I'm wondering why the wmic can't get all the list of installed programs? It shows up on programs and features list, but now when I run that wmi command. I am a domain admin so the credentials should be a problem (the folder in the Program Files(x86) folder for SysTrack does have a lock on it though, but I can access)
Side note: I really wish there was a way to remotely just view that programs and features menu. Would be incredibly handy for the tasks I've been doing lately.
try;
wmic product where "name like 'Systems Management Agent'" call uninstall /nointeractive
it should work.
Try this in powershell ise. It will take a list of hostnames from a text file and uninstall the application. Edit the path for your local directory and text file name.
This script is 2 lines. Everything before $app.Uninstall() is on one line and then $app.Uninstall() is the 2nd line.
$app = Get-WmiObject -Class Win32_Product -ComputerName (Get-Content -Path "C:\Users\MYUSERNAME\Documents\PowerShell\servers.txt") | Where-Object {$_.Name -match “Systems Management Agent”}
$app.Uninstall()
Related
CCleaner contains a tool to list and then uninstall programs on your PC. This list seems to include applications in a more comprehensive way than a walk through the uninstall registry keys. One example of this, is Atom (the Open Source text editor). This program does not appear in the uninstall registry, and is installed in the AppData folder of the user (I'm not aware of a way to install this for all users without building a custom package).
I wrote a script that installs and updates certain software packages on a regular basis. This makes it easy for me to keep them up to date without visiting a dozen or so websites every week or building a custom installer every time I want to update them (they don't auto-update like Chrome or Firefox). Therefore, I need a list that I can create dynamically and use to check for updates and if I need to execute the installer.
So my question is: How do I emulate what CCleaner does when it creates its list of programs for uninstalling -- programmatically? I can execute the GUI and navigate to the uninstall tool and click "save to text file" but that isn't dynamic. Any answer that allows me to capture (in a Powershell script) the same list of applications that CCleaner generates in the uninstall tool will be acceptable.
You can use Get-Package to list installed programs as well. It will list Atom. You may need to combine the registry approach with Get-Package in the case it doesn't show all.
Get-Package | Where-Object name -like *atom*
Name Version Source ProviderName
---- ------- ------ ------------
Atom 1.53.0 Programs
What you are asking for used to be done with Get-CimInstance, but that comes at a cost and as you pointed out is no longer accurate. It used to be a WMI command. Now CIM. It is not a fast command, more on that later.
Get-CimInstance win32_product
The cost is Get-CimInstance can return incomplete data. It also runs a consistency check on all applications and performs automatic and silent repairs. Yes, when you run this command, it automatically runs a consistency check on all applications and performs automatic and silent repairs. That is why this simple command is so slow to report back.
Microsoft's documentation on this: Link Here
So we do not use that anymore, now what? What you are looking for is gathering the information from both 32 and 64 bit installers that looks like this and must be done, I do it first, always.
$installedApplications = #()
$installedApplications+= Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" # 32 Bit
$installedApplications+= Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" # 64 Bit
One caveat to the above is that the above method will return a ton more elements than the Win32_Product command does. It will have things such as Service Packs, Office Updates, Language Packs, etc. You will most likely need to filter out things you aren’t interested in, though you shouldn't have an issue using PowerShell to filter results.
To complete the answer to your question, how do you quantify data from installers regardless of their install location? Specifically finding the userprofile\AppData install information. The good news is these applications have their installation information documented in the registry as well, under HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE. What this means is every user's install location information is sitting in the registry hive under their profile, for instance c:\users\inet\NTUSER.DAT.
What else needs to be said about this;
If a user is logged in this can be accessed by any other admin user on the system by using the HKEY_USERS\$ACCOUNT_SID key.
If a user is not logged in, the hive can be manually mounted using REG LOAD
If a user's registry hive is already loaded it cannot be loaded a second time and will give you the obligatory "this file is being used by another process."
So how do we get what you are asking for, which is to replicate the "full install data" for the device, and not just what's in the 32 and 64bit directories?
This is what I use, if one so chooses you can pipe the info to CSV/HTML/etc...
$installedApplications = #()
$installedApplications+= Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedApplications+= Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
$32BitPath = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$64BitPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
$tigerStripes= Get-CimInstance Win32_UserProfile | Select LocalPath, SID, Loaded, Special | Where {$_.SID -like "S-1-5-21-*"}
$unavailableProfiles = $tigerStripes| Where {$_.Loaded -eq $true}
$availableProfiles = $tigerStripes| Where {$_.Loaded -eq $false}
#Mounted
$unavailableProfiles | % {
$installedApplications += Get-ItemProperty -Path "Registry::\HKEY_USERS\$($_.SID)\$32BitPath"
$installedApplications += Get-ItemProperty -Path "Registry::\HKEY_USERS\$($_.SID)\$64BitPath"
}
#Unmounted
$availableProfiles | % {
#Mount Hive
$Hive = "$($_.LocalPath)\NTUSER.DAT"
if (Test-Path $Hive) {
REG LOAD HKU\temp $Hive
$installedApplications += Get-ItemProperty -Path "Registry::\HKEY_USERS\temp\$32BitPath"
$installedApplications += Get-ItemProperty -Path "Registry::\HKEY_USERS\temp\$64BitPath"
#This lets the hive be unmounted, using a manual Get-Content
[GC]::Collect()
[GC]::WaitForPendingFinalizers()
REG UNLOAD HKU\temp
} else {
Write-Warning "Unable to access registry at $Hive"
}
}
$installedApplications
I'd like a simple command to copy a shortcut for Devices and Printer.lnk to All Users Profile Start Menu so that I can pin this shortcut to every users start menu that logs in to the Windows 10 PC at logon.
I've exported my start menu but having read up on it doesn't seem possible to pin the Devices and Printers shortcut in the normal fashion. This is why I've uploaded the shortcut to a network location that all users have access to, if I can copy this to a location on the PC that all users have access to then I can adjust my startmenu script so that it appears as a tile.
I can copy the shortcut to a basic location (the logged on user) but not to all users folder?
I thought that the following would work but doesn't:
Copy-Item -Path "\\Server\Share\*.lnk" -Destination "$env:allusersprofile\APPDATA\Microsoft\Windows\Start Menu\Programs"
Appreciate your help.
Edit: I have resolved the above issue however, it's lead me on to a follow on issue. I apply this script when a user logs in to Windows 10 but I then want to run a separate task (that is a part of the same ps1 file) which removes a whole host of Bloatware from the OS.
I've tried to add a ; and additionally and but they both still require the user to login twice to complete both tasks. My full script at the moment is:
Copy-Item -Path "\\Server\Share\*.lnk" -Destination "$env:APPDATA\Microsoft\Windows\Start Menu\Programs"; $AppList = #( "*Microsoft.3dbuilder*" etc etc*" ) foreach ($App in $AppList) { Get-AppxPackage -Name $App | Remove-AppxPackage -ErrorAction SilentlyContinue }
I've added "etc etc" as there's a load of commands below that I won't include that remove the bloatware.
You need to remove APPDATA from Destination and it should work. Use following code:
Copy-Item -Path "\\Server\Share\*.lnk" -Destination "$env:ALLUSERSPROFILE\Microsoft\Windows\Start Menu\Programs"
I'm terrible at scripting, so I would like some help with a script which does the following:
a wmic query:
wmic computersystem get model
Latitude E7450
creates a folder in the root using the query output without spaces:
Latitude_E7450
Then run double driver to backup all the drivers and storing them in the newly created folder:
ddc b /source:"c:\Windows" /target:"c:\Latitude_E7450"
You can get name for the target folder from the WMI Model using powershell, assuming WMI returns this (some OEM units don't),
$dirName = (Get-WmiObject -Class win32_computersystem).Model
Then you can call Double Driver,
& ddc.exe b /source:"C:\Windows" /target:"C:\$dirName"
For a pure powershell solution, see for example this post from Mikael Nyström, "PowerShell is King – Export drivers from Windows"
Export-WindowsDriver -Destination "C:\Drivers\$((Get-WmiObject -Class win32_computersystem).Model)" -Online
This requires Windows 6.3 at least (8.1 or 2012 R2), so use Double Driver for Win 7, if you can still find it. For even more bells and whistles, see "Building Configuration Manager Driver Packages for Windows 7 with PowerShell and Double Driver".
I am trying to write a script in windows command prompt (windows 8), to find out the directory location of services running. For example
net start // gives all the running services. I want to know the location of those services
Help required!
The following command is using PowerShell in order to display what you want:
powershell.exe -noexit "Get-WmiObject win32_service | select Name, DisplayName, State, PathName"
Just copy and paste it into a "cmd" window.
It will display you the service name, the display name, the state and the path to the executable.
Is there any command in windows which can give full path of the process running
tasklist does not give full paths. I do not want to use task manager
The tlist tool is not distributed with the Windows Resource Kit anymore (it's been superseded by tasklist), but is able to list the full path of each process.
You can fetch a copy from the download center.
Now can do it using powershell:
PS C:\> gwmi win32_process | select CommandLine | select-string -pattern "process-name"