none
Logoff Script Take 2-3 min

    Question

  • Hi All,

      I have create user logoff script to uninstall software. Now i have two issues.

     1. Take long to logoff

     2. How do i allow only once? 

    $ArgumentsStandard =" /quiet "
    $ArgumentsStandard +="/norestart"
    $App = Get-Content "\\server\share\un-installApp.txt"
    
    #gwmi gets the list of applications 
    # where selects just the apps im interested in removing 
    # start-process removes each app using msiexec with quiet and norestart options 
    
    Write-Host "start un-installing software from list"
    gwmi win32_product | 
    where { $App -contains $_.Name } |
    ForEach-Object {
    	Write-Host "start un-installing $_.name"
    	$Arguments =  "/uninstall "
    	$Arguments += $_.IdentifyingNumber
    	$arguments += $ArgumentsStandard 
    	Start-Process "MSIExec" -ArgumentList $Arguments -wait
    }

    Tuesday, January 20, 2015 10:45 PM

All replies

  • can you check how long does it take in terms of group policy processing?you can track at gpsvc logs. And also ensure script does not do anything else except the desires

    Regards, Prabhu

    Wednesday, January 21, 2015 1:04 PM
  • >   1. Take long to logoff
     
    Yes, win32_product is a SLOOOOW enumeration...
     
    >   2. How do i allow only once?
     
    Create a flag file (or reg value) after processing, exit at the
    beginning if this file exists.
     
    > gwmi win32_product
     
    To verify, try "measure-command { gwmi win32_product }"
     
     

    Martin

    Mal ein GUTES Buch über GPOs lesen?

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))
    Wednesday, January 21, 2015 1:57 PM
  • Hi,

    How is it going? We can follow the suggestions provided to tackle the situation. Besides, we can also ask for advice in the following scripting forum.

    The Official Scripting Guys Forum

    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG

    TechNet Subscriber Support
    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.

    Best regards,

    Frank Shen

    Monday, January 26, 2015 8:59 AM
    Moderator
  • Hi Martin,

      I don't know how to do this in PowerShell So can you help me with the if  code? 

    if exist "c:\cid3.txt" goto end

    $ArgumentsStandard =" /quiet "
    $ArgumentsStandard +="/norestart"
    $App = Get-Content "\\server\Softwareshare\un-installApp.txt"

    #gwmi gets the list of applications 
    # where selects just the apps im interested in removing 
    # start-process removes each app using msiexec with quiet and norestart options 

    Write-Host "start un-installing software from list"
    gwmi win32_product | 
    where { $App -contains $_.Name } |
    ForEach-Object {
    Write-Host "start un-installing $_.name"
    $Arguments =  "/uninstall "
    $Arguments += $_.IdentifyingNumber
    $arguments += $ArgumentsStandard 
    Start-Process "MSIExec" -ArgumentList $Arguments -wait
    }
    New-Item c:\cid3.txt -type file
    :end

    Wednesday, January 28, 2015 1:01 AM
  • >    I don't know how to do this in PowerShell So can you help me with the
    > if  code?
     
    Google/Bing can assist you in how to check for a file or create one.
     

    Martin

    Mal ein GUTES Buch über GPOs lesen?

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))
    Wednesday, January 28, 2015 10:15 AM
  • What i did wrong in this script? somehow its not working?

    If ( test-path c:\cid3.txt )
    {
    exit
    }
    else
    {
    $ArgumentsStandard =" /quiet "
    $ArgumentsStandard +="/norestart"
    $App = Get-Content "\\server\Softwareshare\un-installApp.txt"

    #gwmi gets the list of applications 
    # where selects just the apps im interested in removing 
    # start-process removes each app using msiexec with quiet and norestart options 

    Write-Host "start un-installing software from list"
    gwmi win32_product | 
    where { $App -contains $_.Name } |
    ForEach-Object {
    Write-Host "start un-installing $_.name"
    $Arguments =  "/uninstall "
    $Arguments += $_.IdentifyingNumber
    $arguments += $ArgumentsStandard 
    Start-Process "MSIExec" -ArgumentList $Arguments -wait
    }
    New-Item c:\cid3.txt -type file

    }



    • Edited by AUSSUPPORT Tuesday, February 03, 2015 6:16 AM
    Thursday, January 29, 2015 11:20 PM