2013-11-15 2 views
0

네트워크의 여러 클라이언트에서 특정 소프트웨어를 제거하는 데 도움이되는 스크립트를 찾고 있습니다.powershell을 사용하여 원격 클라이언트에서 소프트웨어 제거하기

지금은 목록을 통해 원격으로 클라이언트에 액세스하고 로그 아웃하고 프로세스를 반복하기 전에 내 관리자 계정으로 로그인하고 소프트웨어를 제거합니다. 이 모든 것은 수동으로 수행되므로 필자의 도움으로 필자의 도움을 받아 PowerShell 스크립트를 작성해주십시오.

발생할 수있는 몇 가지 문제 : 클라이언트에 연결할 수 없기 때문에 원격으로 로그인 할 수 없습니다. 다른 사용자가 이미 클라이언트에 로그인했을 수 있습니다. 제거 할 소프트웨어가 실제로 내 지식없이 이미 제거되었습니다.

스크립트가 실제로 도움이 될 수 있도록 약 900 명의 클라이언트가 있습니다.

또한 스크립트가 완료된 후 소프트웨어가 제거 된 클라이언트와 그렇지 않은 클라이언트의 목록을 얻을 수 있다면 가능합니다. 이 같은 기록

답변

1

질문은 ... 나는 Windows 설치 파워 쉘 모듈 Uninstall-MSIProduct를 사용하는 것이 좋습니다

유형의 응답을 '당신이 시도 무엇 이끌어 낼 가능성이 높다.

나는이 게시물에서 원격으로이 모듈을 사용하는 방법을 설명했다 : remote PCs using get-msiproductinfo,이 예제는 Get-MSIProductInfo을 사용하지만 쉽게 Uninstall-MSIProduct을 사용하도록 업데이트 될 수있다.

Uninstall-MSIProduct을 사용하도록이 기능을 빠르게 변경했지만 테스트하지는 않았습니다.

[cmdletbinding()] 
param 
(
    [parameter(Mandatory=$true,ValueFromPipeLine=$true,ValueFromPipelineByPropertyName=$true)] 
    [string] 
    $computerName, 
    [string] 
    $productCode 
) 

begin 
{ 
    write-verbose "Starting: $($MyInvocation.MyCommand)" 

    $scriptFolder = Split-Path -Parent $MyInvocation.MyCommand.Path 
    $moduleName  = "MSI" 
    $modulePath  = Join-Path -Path $scriptFolder -ChildPath $moduleName 

    $remoteScript = { 
     param($targetPath,$productCode) 

     Import-Module $targetPath 
     uninstall-msiproduct -ProductCode $productCode 
    } 

    $delayedDelete = { 
     param($path) 
     Remove-Item -Path $path -Force -Recurse 
    } 
} 
process 
{ 
    $remotePath = "\\$computerName\c$\temp\$moduleName" 

    write-verbose "Copying module to $remotePath" 
    Copy-Item -Path $modulePath -Destination $remotePath -Recurse -Container -Force 

    write-verbose "Getting installed products" 
    Invoke-Command -ComputerName $computerName -ScriptBlock $remoteScript -ArgumentList "c:\temp\$moduleName", $productCode 

    write-verbose "Starting job to delete $remotePath" 
    Start-Job -ScriptBlock $delayedDelete -ArgumentList $remotePath | Out-Null 
} 

end 
{ 
    write-verbose "Complete: $($MyInvocation.MyCommand)" 
} 
관련 문제