I have a PS script that when I launch interactively/manually, it runs perfectly 
fine from the NETLOGON share.  But When I add it into the GPO computer 
logon/start up script, it doesn't work??

Do I need to some services started before I can run this PS script to uninstall 
MS Updates?

Thanks in advanced,
Jerry

Jerry Lai
Systems Engineer, Desktop Management
Herbert Smith Freehills

T  +61 3 9288 1780  M  +61 4198 9461  F  +61 3 9288 1567
www.herbertsmithfreehills.com<http://www.herbertsmithfreehills.com/>
linkedin.com/in/JerryLaiHSF<http://www.linkedin.com/in/jerrylaihsf>


Herbert Smith Freehills LLP and its subsidiaries and Herbert Smith Freehills, 
an Australian Partnership, are separate member firms of the international legal 
practice known as Herbert Smith Freehills.

This message is confidential and may be covered by legal professional 
privilege. If you are not the intended recipient you must not disclose or use 
the information contained in it. If you have received this email in error 
please notify us immediately by return email or by calling our main switchboard 
on +612 9225 5000 and delete the email.

Further information is available from www.herbertsmithfreehills.com.



$PatchList = 
@("KB2553154","KB2899519","KB2910902","KB3008923","KB3012176","KB3013126")

function Remove-Update
{
        $HotFixes = Get-HotFix
        
        foreach ($HotFix in $HotFixes)
        {
                foreach ($KBID in $PatchList)
                {
                        if ($KBID -eq $HotFix.HotfixId)
                        {
                                "Inside first if"
                                $KBID = $HotFix.HotfixId.Replace("KB", "") 
                                $RemovalCommand = "wusa.exe /uninstall 
/kb:$KBID /quiet /norestart"
                                Write-Host "Removing $KBID from the target."
                                Invoke-Expression $RemovalCommand
                                break
                        }                       
                        if ($KBID -match "All")
                        {
                                $KBNumber = $HotFix.HotfixId.Replace("KB", "")
                                $RemovalCommand = "wusa.exe /uninstall 
/kb:$KBNumber /quiet /norestart"
                                Write-Host "Removing update $KBNumber from the 
target."
                                Invoke-Expression $RemovalCommand
                        }                       
                        if ($KBID -match "Security")
                        {
                                if ($HotFix.Description -match "Security")
                                {
                                
                                        $KBSecurity = 
$HotFix.HotfixId.Replace("KB", "")
                                        $RemovalCommand = "wusa.exe /uninstall 
/kb:$KBSecurity /quiet /norestart"
                                        Write-Host "Removing Security Update 
$KBSecurity from the target."
                                        Invoke-Expression $RemovalCommand
                                }
                        }
                        while (@(Get-Process wusa -ErrorAction 
SilentlyContinue).Count -ne 0)
                        {
                                Start-Sleep 3
                                Write-Host "Waiting for update removal to 
finish ..."
                        }
                }
        }

}

Remove-Update

Reply via email to