/build/static/layout/Breadcrumb_cap_w.png
05/09/2019 116 views

Hi,  I am trying to disable / remove the check mark on "allow the computer to turn off this device to save power" on all usb hubs.  I have a power shell script that works if ran as administrator however when I use it on standard user workstations using the k1000 to run the script with the setting "run as specific user" and set the domain administrator credentials it wont work, it says it ran but it never changes.  If I run it as the local logged in user then they do not have rights to modify that setting so I'm stuck.  I'm not smart enough to script it but if I had a vb script to do it I belive I could run it as "specific user" and use the domain admin.  so really I'm looking for help on this one.  scripts, ideas etc.   here is the ps that I'm using that works (i coppied it from the internet)if ran in ps as administrator but wont work if running from kbox

any help is very much appreciated  could this be converted to a vb script?


$hubs = Get-WmiObject Win32_USBHub
$powerMgmt = Get-WmiObject MSPower_DeviceEnable -Namespace root\wmi
foreach ($p in $powerMgmt)
{
  $IN = $p.InstanceName.ToUpper()
  foreach ($h in $hubs)
  {
    $PNPDI = $h.PNPDeviceID
                if ($IN -like "*$PNPDI*")
                {
                    $p.enable = $False
                    $p.psbase.put()
                }
  }
}


Answer Summary:
2 Comments   [ + ] Show comments

Comments

  • can you post your kscript also
  • here you go

    <?xml version="1.0" encoding="utf-8" ?>
    <kbots xmlns="http://kace.com/Kbots.xsd">
    <kbot>

    <config name="Silver Lake Teller Capture install" type="policy" id="374" version="1557429123" description="testing right now do not use">

    <dependencies>
    <dependency name="/packages/kbots/374/usbhubpower.ps1" checksum="144fa392af5b261433062c35803babdb" />
    </dependencies>

    <execute disconnected="false" logged_off="false">
    </execute>

    </config>

    <compliance>

    <verify on_failure="break" attempts="1">


    <on_verify_success>
    <set_registry_key key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" />
    <set_registry_value key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" name="ExecutionPolicy" type="REG_SZ" newValue="unrestricted" />
    <launch_program path="%SystemRoot%\system32\WindowsPowerShell\v1.0\" program="powershell.exe" wait="false" parms="-executionpolicy remotesigned -file $(KACE_DEPENDENCY_DIR)\usbhubpower.ps1" />
    </on_verify_success>

    <on_verify_failure>

    <on_remediation_success>
    </on_remediation_success>

    <on_remediation_failure>
    </on_remediation_failure>

    </on_verify_failure>

    </verify>

    <verify on_failure="break" attempts="1">


    <on_verify_success>
    <set_registry_key key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" />
    <set_registry_value key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" name="ExecutionPolicy" type="REG_SZ" newValue="restricted" />
    </on_verify_success>

    <on_verify_failure>

    <on_remediation_success>
    </on_remediation_success>

    <on_remediation_failure>
    </on_remediation_failure>

    </on_verify_failure>

    </verify>

    </compliance>

    </kbot>
    </kbots>

Answer Chosen by the Author

0

i just now got it to work.  running it as "local system" did the trick.  script ran and disabled power management on all usb root hubs for me.

thank you


Answered 05/10/2019 by: werowance
Senior Yellow Belt

All Answers

0

If these are 64 bit machines it is most likely a sys native problem. The client is 32bit and there is no powershell structure under the syswow64 folder.

Try:

<launch_program path="%SystemRoot%\sysnative\WindowsPowerShell\v1.0\" program="powershell.exe" wait="false" parms="-executionpolicy remotesigned -file $(KACE_DEPENDENCY_DIR)\usbhubpower.ps1" />

also see if your registry changes are going to the 64bit registry or the 32bit (WOW6432Node)


Answered 05/10/2019 by: SMal.tmcc
Red Belt