Im new to Powershell 그리고 나는 그것으로 소프트웨어를 제거하려고합니다. 여러 웹 사이트를 검색했지만 내 컴퓨터에서 소프트웨어를 제거 할 수있는 간단한 스크립트를 찾을 수 없습니다. 누구든지 사용할 수있는 스크립트가 있습니까?powershell을 사용하여 프로그램을 제거하는 스크립트
답변
가져-WMIObject에서 -class Win32_Product와 한 번 봐는
는많은 사이 (I 응용 프로그램을 내가 만든
<#
.SYNOPSIS
Query WMI for MSI installed applications.
.DESCRIPTION
Queries WMI for applications installed by MSI by calling the Win32_Product class,
all parameters are optional and the -Computer Parameter can be piped to by name only and have multiple entries.
.PARAMETER Computername
Specifies the computer to query, can be an array of computers and can be name piped to.
Default is localhost.
.PARAMETER Software
Used to search for specific software, e.g *java* or "Java Auto Updater". Wrap strings with Double quotations (").
Default is "*" wildcard meaning all items.
.PARAMETER Uninstall
Uninstalls all found software using the Uninstall() Method.
.PARAMETER Credentials
This Switch specifies credentials for remote machines.
Just using -Credentials will prompt you to enter your credentials when executing the command.
.PARAMETER Showprogress
Shows the progress on a per machine basis(works better if you have a few machines to check on).
Default is off.
.EXAMPLE
This will query the local machine for anything installed like "Java" and return it to screen.
PS C:\> Get-SoftwareNT -Software "*java*"
This will export all Software installed in the local machine to a file called File.csv With only the Name and installed date selected.
PS C:\> Get-SoftwareNT | Select-Object -Property name,InstallDate | Export-Csv -Path C:\MyPath\File.csv -NoTypeInformation
This Searches for software on the computers in the file C:\ListofComputers.txt that match "*Java*" and return it to screen.
PS C:\> Get-SoftwareNT -Software "*java*" -Computername (Get-Content -Path C:\ListofComputers.txt)
.EXAMPLE
This will ask you for your credentials and query the machine BAD-USER and BAD-USER2 for any software that matches the term "*itunes*" and returns it to screen with a progress bar.
PS C:\> Get-SoftwareNT -Credentials -Computername BAD-USER,BAD-USER2 -Software "*iTunes*" -showprogress
This will to the same as the command above but then uninstall the software and display a return code
(0 usually means it was successful, 1603 usually means no permissions)
PS C:\> Get-SoftwareNT -Credentials -Computername BAD-USER,BAD-USER2 -Software "*iTunes*" -Uninstall
.NOTES
Please note that the Win32_Product is quite inefficient as it uses windows installer to query every application installed to gather
the information and dose a "reconfiguration" in the process, this is bad if you have disabled a service for a msi installed app because in the process it
dose a repair on the app and if there are any issues it will fix them first and then move on and this means reactivating disabled services etc.
#>
function Get-SoftwareNT {
[CmdletBinding()]
param(
[Parameter(ValueFromPipelineByPropertyName=$True,ValueFromPipeline=$True)]
[System.String[]]$Computername = "localhost",
$Software = "*",
[Switch]$Uninstall = $false,
[Switch]$Credentials = $false,
[Switch]$Showprogress = $false
)
BEGIN {
$NTErrorLog = "C:\NTErrorLogs\Get-SoftwareNT.txt"
$Path_Test = Test-Path -Path $NTErrorLog
$Encoding = "ASCII"
if (!($Path_Test)) {New-Item -Path (Split-Path $NTErrorLog -Parent) -ItemType Container -ErrorAction SilentlyContinue ; New-Item -Path (Split-Path $NTErrorLog -Parent) -Name (Split-Path $NTErrorLog -Leaf) -ItemType file -Value "Unreachable machines: `n" | Out-Null}
else {Get-Content -Path $NTErrorLog -Force | Out-File -FilePath ("$NTErrorLog" + '_') -Append -Force -Encoding $Encoding ; Clear-Content $NTErrorLog -Force | Out-Null}
if ($Credentials) { $credstore = Get-Credential }
$Count = (100/($Computername).Count -as [Decimal])
[Decimal]$Complete = "0"
}
PROCESS{
Foreach ($Computer in $Computername) {
try {
$Computer_Active = $true
$TestConnection = Test-Connection -Count 1 -ComputerName $Computer -ea Stop
} catch {
Write-Warning -Message "$computer was not reachable Logging to $NTErrorLog"
$Computer | Out-File -FilePath $NTErrorLog -Append -Encoding $Encoding -Force
$Computer_Active = $false
}
if ($Computer_Active) {
if ($Showprogress) {Write-Progress -Activity "Looking for $Software on $Computer" -CurrentOperation "Connecting to WMI on $Computer" -PercentComplete $Complete}
if ($Credentials) { $Var1 = Get-WmiObject -Credential $credstore -Class Win32_Product -ComputerName $Computer | Where-Object {$_.name -Like "$Software"} }
else { $Var1 = Get-WmiObject -Class Win32_Product -ComputerName $Computer | Where-Object {$_.name -Like "$Software"} }
Write-Output -InputObject $Var1
if ($Uninstall) { $Var1.Uninstall() }
$Complete +=$Count
}
if ($Showprogress) {Write-Progress -Activity "Finished with $Computer" -CurrentOperation "Done" -PercentComplete $Complete}
}
if ($Showprogress) {Write-Progress -Activity "Done" -Completed}
}
END{}
}
나는 당신을 인용하지 말라고 꾸짖 으려했습니다. 소스. http://community.spiceworks.com/scripts/show/2354-get-softwarent-cmdlet-updated – Matt
Win32_Product를 절대로 사용하지 마십시오. 쿼리 할 때마다 강제로 MSI 검사를 수행합니다. http://myitforum.com/cs2/blogs/gramsey/archive/2011/01/25/win32-product-is-evil.aspx –
.NOTES에서 나는 그것을 복용한다고 언급했다. 가장 효율적인 방법은 아니지만 애드혹 솔루션으로 작업을 수행합니다. 더 좋은 방법이 있습니다. 이것이 할 수있는 방법 중 하나 일뿐입니다. –
를 검색하고 제거하는 함수를 만들어
제거라는 방법이있다 기타 소프트웨어 관리 기능) Remove-Software script
당신이 묻는 것만합니다. 그러나 소프트웨어 공급 업체의 고유 한 작업으로 인해 표준 90 %를 고수하지 않아서 상황에 맞게 조정해야 할 수도 있습니다. 이 방법을 사용하면 극단적으로 닫을 수 있습니다.
이 Scrpts는 Win32_product 속성을 사용하여 ws에 설치된 소프트웨어 목록을 가져옵니다. 그런 다음 클래스 키를 사용하여 소프트웨어를 제거합니다.
$의 classkey은 "따라 IdentifyingNumber = "$($classKey1.IdentifyingNumber)"",Name=""$($classKey1.Name)"",Version=""$($classKey1.Version)
" "
# Load Windows Forms assembly
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void][System.Windows.Forms.Application]::EnableVisualStyles()
# Create a GUI
$form = New-Object System.Windows.Forms.Form
$form.text = "Software Uninstall"
$form.Size = New-Object System.Drawing.Size(920,550)
$form.BackColor='SkyBlue'
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
$dataGridView = New-Object System.Windows.Forms.DataGridView
$dataGridView.Size = New-Object System.Drawing.Size(900,400)
$dataGridView.DefaultCellStyle.BackColor = 'LightBlue'
#Button
$button = New-Object System.Windows.Forms.Button
$button.Location = New-Object System.Drawing.Size(400,420)
$button.Size = New-Object System.Drawing.Size(75,25)
$button.BackColor = "LightGreen"
$button.text = "Refresh"
$form.Controls.Add($button)
$form.Controls.Add($dataGridView)
# Note Label
$Label0 = New-Object System.Windows.Forms.Label
$Label0.Location = New-Object System.Drawing.Size(15,450)
$Label0.Size = New-Object System.Drawing.Size(880,50)
$Label0.Backcolor = [System.Drawing.Color]::Yellow
$Label0.Font = New-Object System.Drawing.Font("Calibri",14,[System.Drawing.FontStyle]::Bold)
$Label0.Text = "Note: This Script Cannot Uninstall Policy Restricted Apps such as McAfee etc. Repair option is not Available in this Version. For Reinstall of Software Kindly use SCCM."
$form.Controls.Add($Label0)
# Select appropriate columns
$dataGridView.Columns.Insert(0, (New-Object System.Windows.Forms.DataGridViewButtonColumn))
$dataGridView.ColumnCount = 8
$dataGridView.ColumnHeadersVisible = $true
#$dataGridView.HeaderText = "Uninstall"
$dataGridView.Columns[0].Name = "Uninstall"
$dataGridView.Columns[1].Name = "Description"
$dataGridView.Columns[2].Name = "IdentifyingNumber"
$dataGridView.Columns[3].Name = "Name"
$dataGridView.Columns[4].Name = "Vendor"
$dataGridView.Columns[5].Name = "Version"
$dataGridView.Columns[6].Name = "Caption"
$dataGridView.Columns[7].Name = "InstallLocation"
$dataGridView.Columns[0].width = 50
$dataGridView.Columns[1].width = 200
# Get a list of items
Get-WmiObject -Class Win32_Product | foreach {
$dataGridView.Rows.Add("Uninstall",$_.Description,$_.IdentifyingNumber,$_.Name,$_.Vendor,$_.Version,$_.Caption,$_.InstallLocation) | out-null
}
# Refresh
function gridClick(){
$rowIndex = $dataGridView.CurrentRow.Index
$columnIndex = $dataGridView.CurrentCell.ColumnIndex
If ($columnIndex -eq '0')
{
$columnIndex0 = $dataGridView.ColumnIndex+1
$columnIndex1 = $dataGridView.ColumnIndex+2
$columnIndex2 = $dataGridView.ColumnIndex+3
$columnIndex3 = $dataGridView.ColumnIndex+4
$columnIndex5 = $dataGridView.ColumnIndex+5
$IdentifyingNumber = $dataGridView.Rows[$rowIndex].Cells[$columnIndex1].value
$Name = $dataGridView.Rows[$rowIndex].Cells[$columnIndex0].value
$Version = $dataGridView.Rows[$rowIndex].Cells[$columnIndex5].value
Write-Host $dataGridView.Rows[$rowIndex].Cells[$columnIndex0].value
Write-Host $dataGridView.Rows[$rowIndex].Cells[$columnIndex1].value
Write-Host $dataGridView.Rows[$rowIndex].Cells[$columnIndex5].value
$classKey1 = New-Object PSObject -Property @{
IdentifyingNumber=$IdentifyingNumber
Name=$Name
Version=$Version
}| select IdentifyingNumber, Name, Version
# Write-Host $classKey
$classkey = "IdentifyingNumber=`"$($classKey1.IdentifyingNumber)"",Name=""$($classKey1.Name)"",Version=""$($classKey1.Version)`""
$wshell = New-Object -ComObject Wscript.Shell
$OUTPUT = [System.Windows.Forms.MessageBox]::Show("You Have Selected $Name. Do You Want to Proceed With The Uninstall", "Warning!!!", 4)
if ($OUTPUT -eq "YES"){
Try{
([wmi]”\\localhost\root\cimv2:Win32_Product.$classKey”).uninstall()
}
Catch{
Write-Warning $_
}
}
<# Else
{
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("You Have Selected No, Click Ok to Continue" ,0,"Warning!!!",0x0)
}
}#>
# Vaid Cell
<# Else
{
$wshell = New-Object -ComObject Wscript.Shell
$OUTPUT = $wshell.Popup("You Have Selected Invalid Column. Please click on Uninstall Button" ,0,"Warning!!!",0x0)
} #>
}
$button.Add_Click({
$selectedRow = $dataGridView.CurrentRow.Index
$dataGridView.Rows.Clear()
start-sleep -s 7
Get-WmiObject -Class Win32_Product | foreach {
$dataGridView.Rows.Add("Uninstall",$_.Description,$_.IdentifyingNumber,$_.Name,$_.Vendor,$_.Version,$_.Caption,$_.InstallLocation) | out-null
}
})
$Uninstall = $dataGridView.add_DoubleClick({gridClick})
# Show the form
[void]$form.ShowDialog()
답변은 항상 높이 평가되지만 실제로 코드가 어떻게 문제를 해결하는지에 대한 정보를 제공하는 것이 좋습니다. 답변을 둘러싼 배경을 제공하고 훌륭한 답변을 작성하는 방법에 대한 정보는 [도움말] (http://stackoverflow.com/help/how-to-answer)을 참조하십시오. –
의견을 보내 주셔서 감사합니다 ... 필수 정보를 추가했습니다. – Deep
- 1. powershell을 사용하여 msiexec 프로그램을 제거하십시오.
- 2. 콘솔 응용 프로그램을 사용하여 PowerShell을 통해 SQL 스크립트 파일을 실행하십시오.
- 3. Powershell을 사용하여 검색 결과의 문자를 제거하는 방법
- 4. powershell을 사용하여 자바 스크립트 드롭 다운 조작
- 5. Windows Powershell을 사용하여 SQL 스크립트 실행
- 6. powershell을 사용하여 내 공유 폴더에 액세스하는 스크립트
- 7. PowerShell을
- 8. PowerShell을 스크립트 - 파일 이름
- 9. PowerShell을 사용하여 Windows RT에서 응용 프로그램을 시작하려면 어떻게합니까?
- 10. 다중 응용 프로그램을 제거하려면 powershell을 사용 하시겠습니까?
- 11. Cywin 또는 Powershell을 사용하여 파일에서 사용자를 제거하는 방법
- 12. Powershell을 사용하여 SSRS 폴더 보안에서 사용자를 제거하는 방법
- 13. PowerShell을 사용하여 활성 디렉토리의 사용자 ID 필드를 제거하는 방법
- 14. powershell을 사용하여 webpart를 제거하는 중 오류를 잡는 방법?
- 15. powershell을 사용하여 원격 컴퓨터에서 서비스를 제거하는 방법은 무엇입니까?
- 16. PowerShell을 사용하여 applicationHost.config에서 rewriteMaps 및 GlobalRules 값을 제거하는 방법은 무엇입니까?
- 17. powershell을 사용하여 배열 추가
- 18. powershell을 사용하여 정보를 추출하려고합니다.
- 19. Appium을 사용하여 모바일 응용 프로그램을 제거하는 방법
- 20. 모든 스크립트 사용자가 Powershell을 설치해야합니까?
- 21. PowerShell을
- 22. powershell을 사용하여 csv에서 행 제거
- 23. Powershell을 사용하여 실행중인 응용 프로그램 모니터링
- 24. python 또는 (and) ruby를 사용하여 응용 프로그램을 제거하는 방법
- 25. Powershell을 사용하여 C# 코드 실행
- 26. PowerShell을
- 27. Powershell을 사용하여 디렉토리의 모든 파일에 대해 프로그램을 실행하는 방법
- 28. Powershell을 사용하여 자동으로 열리는 .net 웹 응용 프로그램을 객체로 선택하려고합니다.
- 29. Java에서 주석을 제거하는 스크립트
- 30. PowerShell을 -
. 당신은 사용할 수 있습니다 = PowerShell을 사용하여 WMI를 호출하거나 MSIExec을 사용하거나 문제의 소프트웨어에서 제공하는 제거 방법을 사용하십시오. 소프트웨어를 제거하는 한 가지 방법은 없습니다. _properly_. http://stackoverflow.com/questions/ 113542/how-can-i-uninstall-an-application-using-powershell – Matt