IT Management Suite

Expand all | Collapse all

Powershell script - runs successfully on PC but does not do changes

  • 1.  Powershell script - runs successfully on PC but does not do changes

    Posted Aug 26, 2013 06:03 AM
      |   view attached

    Hello

    So I have a powershell script (that I  got online) to change the Lync2010 registry's key "AutoRunWhenLogonToWindows" to 1 so lync starts up automatically when user Logs in.

    Problem: Script runs successful (task status shows successful) but the registry key to not changed, it remains "0". The same script executed locally via powershell successfully modifies the registry key.

    The Executionpolicy on the test machine is already set to unrestricted.

    I read in a post and they adviced to add the comment #powershell before my script, did that but still same problem.

     

    Thank you all in advance for your assistance

     



  • 2.  RE: Powershell script - runs successfully on PC but does not do changes
    Best Answer

    Posted Aug 26, 2013 08:15 AM

    Its a user setting(currentuser). Did you set run as current user under the Advanced settings of the task? Else it will try to change it for the System or application identity.

    You will need to run the task for every user that logs on. Maybe better to create a dummy software package and a policy. As detection rule check for the registry key you create with the script. Then schedule it to run whenever a user logs on



  • 3.  RE: Powershell script - runs successfully on PC but does not do changes

    Posted Aug 27, 2013 03:39 AM

    hi SaschaH

    thank you for your reply.  I will try that


    Regards



  • 4.  RE: Powershell script - runs successfully on PC but does not do changes
    Best Answer

    Posted Aug 28, 2013 10:46 AM

    I would recommend changing the script to the following:

    Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Communicator -Name "AutoRunWhenLogonToWindows" -Value '1'

    Delete everything you have in it, and just run the above command.



  • 5.  RE: Powershell script - runs successfully on PC but does not do changes

    Posted Aug 28, 2013 08:43 PM

    thank you Derek, I will try that

    regards



  • 6.  RE: Powershell script - runs successfully on PC but does not do changes

    Posted Aug 28, 2013 09:40 PM

    Hello Derek,

    The script worked, ie the "AutoRunWhenLogonToWindows" entry was created with the value "1" but Lync did not start up automatically when I logged into my test PC. The option in Lync to start when user logs in was not checked also.

    regards



  • 7.  RE: Powershell script - runs successfully on PC but does not do changes

    Posted Aug 28, 2013 10:19 PM

    Hi Derek,

    I modified the script to change the type to DWord (as the existing key under HKCU:\Software\Microsoft\Communicator "AutoRunWhenLogonToWindows" is of type DWord. When I did not specify the type, it puts REG_SZ (string) by default

    Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Communicator" -Name AutoRunWhenLogonToWindows -Value 1 -Type DWord

    this successfully created the new entry but Lync2010 still does not open automatically when I login

    Maybe it works only under the HKCU?

    thanks



  • 8.  RE: Powershell script - runs successfully on PC but does not do changes

    Posted Aug 29, 2013 03:00 AM

    As far as I know its only set on by user base, so Lync doesn't care if you set it in HKLM.

    Try it with the original HKCU.



  • 9.  RE: Powershell script - runs successfully on PC but does not do changes
    Best Answer

    Posted Aug 29, 2013 05:32 AM

    Hi SaschaH

    Yes i set it back to HKCU and it works well.

    My script Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Communicator" -Name AutoRunWhenLogonToWindows -Value 1
     

    As you adviced in your previous post, I will make a detection rule to check if Lync2010 and if this key is set to 1.

    So I have my software delivery to install Lync2010+latest update+MUI+set autorunwhenLogon registry.

    On first installation, Lync does not automatically start, so I will have to notify user to start it manually. But on next login, Lync does automatically start.

    Thank you SashaH et Derek for your replies

    regards



  • 10.  RE: Powershell script - runs successfully on PC but does not do changes

    Posted Aug 29, 2013 09:11 AM

    Glad you got it working.  I do not know anything about your software Lync so I'm glad to see you figured it out.  I just know about PowerShell.