disable power managment on usb hubs k1000
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()
}
}
}
Answers (2)
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)
<?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> - werowance 5 years ago