Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $machineName = Read-host "Enter a Machine Name:"
- $userName = Read-Host "Enter your admin account:"
- $password = Read-Host -AsSecureString "Enter your admin password"
- $appName = Read-host "Enter an Application Name:"
- $Creds = new-object System.Management.Automation.PSCredential -argumentlist $userName,$password
- $app = Get-WmiObject -Class Win32_Product -computerName $machineName -Credential $Creds | Where-Object {$_.Name -Like $appName}
- if(($app | Measure-Object).count -eq 0)
- {
- Write-Warning "No application called $appName found"
- }
- Elseif(($app | Measure-Object).count -eq 1)
- {
- Write-Host "Application $appname Found, uninstalling...."
- $app.uninstall()
- }
- Else
- {
- Write-Warning "Multiple applications found, please review the list in '$app'"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement