none
Anyone know a reliable PS to disable "Allow this pc to turn off ### to save power"

    Question

  • This is to uncheck: Power Management, Allow the computer to turn off this device to save power.

    I have a PS which disables all USB Root Hub devices (except the Intel USB 30 eXtensible).

    That's doable for now. I'm also looking for a PS to do the same for our Sierra Wireless WWAN device.
    It's listed as Sierra Wireless EM74558 Qualcomm Snapdragon X7 LTE-A.

    One I found disables the WIFI adapter but I can't find anything for WWAN. Being not so PS savvy, I don't know how to modify either PS. Both are below:

    USB: (all but 3.0 eXtensible)

    $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()
                    }
     }
    }

    and WIFI:

    ##############################################################################################################
    #
    # Name        : DisablePowerSavingForWLAN.ps1
    # Author      : Ingmar Verheij - http://www.ingmarverheij.com
    # Version     : 1.0, 1 may 2014
    #               - Initial release
    #
    # Description : Prevents Windows from saving power by disabling the WiFi adapter
    #
    # Dependencies : (none)
    #
    # Usage        : The script runs without parameter but requires elevated privileges, this is enforced by the script.
    #               
    #               
    ##############################################################################################################

    # ------------------------------ Functions --------------------------------------
    function Use-RunAs {   
        # Check if script is running as Adminstrator and if not use RunAs
        # Use Check Switch to check if admin
        # http://gallery.technet.microsoft.com/scriptcenter/63fd1c0d-da57-4fb4-9645-ea52fc4f1dfb
       
        param([Switch]$Check)
        $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
        if ($Check) { return $IsAdmin }    
        if ($MyInvocation.ScriptName -ne "")
        { 
            if (-not $IsAdmin) 
            { 
                try
                { 
                    $arg = "-file `"$($MyInvocation.ScriptName)`""
                    Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop' 
                }
                catch
                {
                    Write-Warning "Error - Failed to restart script with runas" 
                    break              
                }
                exit # Quit this session of powershell
            } 
        } 
        else 
        { 
            Write-Warning "Error - Script must be saved as a .ps1 file first" 
            break 
        } 
    }
    # -------------------------------------------------------------------------------


    # Ensure the script runs with elevated priviliges
    Use-RunAs
    # -


    # Start log transcript
    Start-Transcript -Path ($MyInvocation.MyCommand.Definition -replace 'ps1','log') -Append | out-null
    # -


    #Inform user
    Write-Host -ForegroundColor White "Iterating through network adapters"
    $intNICid=0; do
    {
     #Read network adapter properties
     $objNICproperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -ErrorAction SilentlyContinue)
     
     #Determine if the Network adapter index exists
     If ($objNICproperties)
     {
      #Filter network adapters
      # * only Ethernet adapters (ifType = ieee80211(71) - http://www.iana.org/assignments/ianaiftype-mib/ianaiftype-mib)
      # * root devices are exclude (for instance "WAN Miniport*")
      # * software defined network adapters are excluded (for instance "RAS Async Adapter")
      If (($objNICproperties."*ifType" -eq 6 -or $objNICproperties."ifType" -eq 71)-and
          ($objNICproperties.DeviceInstanceID -notlike "ROOT\*") -and
       ($objNICproperties.DeviceInstanceID -notlike "SW\*")
       )
      {

       #Read hardware properties
       $objHardwareProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Enum\{0}" -f $objNICproperties.DeviceInstanceID) -ErrorAction SilentlyContinue)
       If ($objHardwareProperties.FriendlyName)
       { $strNICDisplayName = $objHardwareProperties.FriendlyName }
       else
       { $strNICDisplayName = $objNICproperties.DriverDesc }
       
       #Read Network properties
       $objNetworkProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Network\{0}\{1}\Connection" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", $objNICproperties.NetCfgInstanceId) -ErrorAction SilentlyContinue)
           
                #Inform user
       Write-Host -NoNewline -ForegroundColor White "   ID     : "; Write-Host -ForegroundColor Yellow ( "{0:D4}" -f $intNICid)
       Write-Host -NoNewline -ForegroundColor White "   Network: "; Write-Host $objNetworkProperties.Name
                Write-Host -NoNewline -ForegroundColor White "   NIC    : "; Write-Host $strNICDisplayName
                Write-Host -ForegroundColor White "   Actions:"

                #Disable power saving
                Set-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -Name "PnPCapabilities" -Value "24" -Type DWord
                Write-Host -ForegroundColor Green ("   - Power saving disabled")
                Write-Host ""
      }
     }
     
     #Next NIC ID
     $intNICid+=1
    } while ($intNICid -lt 255)


    # Request the user to reboot the machine
    Write-Host -NoNewLine -ForegroundColor White "Please "
    Write-Host -NoNewLine -ForegroundColor Yellow "reboot"
    Write-Host -ForegroundColor White " the machine for the changes to take effect."

    # Stop writing to log file
    Stop-Transcript | out-null


    Tuesday, May 15, 2018 4:55 PM

Answers

  • I modified my USBHub PS script to this below. In regard to "allow this computer to turn this device off to save power", it alone turns off ALL

    Modem Devices
    Network Apadter devices
    Port (COM & LPT)
    USB devices

    I didn't bother to change the $hubs name, it's just a vairable to use.

    $hubs = Get-WmiObject Win32_Serialport | Select-Object Name,DeviceID,Description
    $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()
                    }
     }
    }

    • Marked as answer by the1rickster Friday, May 18, 2018 3:32 PM
    Friday, May 18, 2018 3:30 PM
  • Got it. Simple miscommuniction. Try this - I added filtering for mobile broadband devices and also a safety check that bypassess Microsoft Virtual Wifi Adapter should it be present on the system. See my comments in the script for additional details. Happy testing!

    ##############################################################################################################
    # 
    # Name        : DisablePowerSavingForWLAN.ps1
    # Author      : Ingmar Verheij - http://www.ingmarverheij.com
    # Version     : 1.0, 1 may 2014
    #               - Initial release
    #
    # Description : Prevents Windows from saving power by disabling the WiFi adapter
    # 
    # Dependencies : (none)
    #
    # Usage        : The script runs without parameter but requires elevated privileges, this is enforced by the script.
    #                
    #                
    ##############################################################################################################
    
    
    
    # ------------------------------ Functions --------------------------------------
    function Use-RunAs {    
        # Check if script is running as Adminstrator and if not use RunAs 
        # Use Check Switch to check if admin 
        # http://gallery.technet.microsoft.com/scriptcenter/63fd1c0d-da57-4fb4-9645-ea52fc4f1dfb
        
        param([Switch]$Check) 
        $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") 
        if ($Check) { return $IsAdmin }     
        if ($MyInvocation.ScriptName -ne "") 
        {  
            if (-not $IsAdmin)  
            {  
                try 
                {  
                    $arg = "-file `"$($MyInvocation.ScriptName)`"" 
                    Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop'  
                } 
                catch 
                { 
                    Write-Warning "Error - Failed to restart script with runas"  
                    break               
                } 
                exit # Quit this session of powershell 
            }  
        }  
        else  
        {  
            Write-Warning "Error - Script must be saved as a .ps1 file first"  
            break  
        }  
    }
    # -------------------------------------------------------------------------------
    
    
    # Ensure the script runs with elevated priviliges
    Use-RunAs
    # -
    
    
    # Start log transcript
    Start-Transcript -Path ($MyInvocation.MyCommand.Definition -replace 'ps1','log') -Append | out-null
    # -
    
    
    #Inform user
    Write-Host -ForegroundColor White "Iterating through network adapters"
    $intNICid=0; do
    {
    	#Read network adapter properties
    	$objNICproperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -ErrorAction SilentlyContinue)
    	
    	#Determine if the Network adapter index exists 
    	If ($objNICproperties)
    	{
    		#Filter network adapters
    		# * only Ethernet adapters (ifType = ieee80211(71) - http://www.iana.org/assignments/ianaiftype-mib/ianaiftype-mib)
    		# * root devices are exclude (for instance "WAN Miniport*")
    		# * software defined network adapters are excluded (for instance "RAS Async Adapter")
            # AR: include wwanPP (243), -- 3GPP WWAN & wwanPP2 (244), -- 3GPP2 WWAN per request
            # AR: exclude Microsoft Wi-Fi Direct Virtual Adapter
    
    		If (($objNICproperties."*ifType" -eq 71 -or $objNICproperties."*ifType" -eq 243 -or $objNICproperties."*ifType" -eq 244) -and 
    		    ($objNICproperties.DeviceInstanceID -notlike "ROOT\*") -and
    			($objNICproperties.DeviceInstanceID -notlike "SW\*") -and
                ($objNICproperties.DeviceInstanceID -notlike "*vwifimp_wfd*")
    			)
    		{
                Write-Host $objNICproperties.DeviceInstanceID
    			#Read hardware properties
    			$objHardwareProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Enum\{0}" -f $objNICproperties.DeviceInstanceID) -ErrorAction SilentlyContinue)
    			If ($objHardwareProperties.FriendlyName)
    			{ $strNICDisplayName = $objHardwareProperties.FriendlyName }
    			else 
    			{ $strNICDisplayName = $objNICproperties.DriverDesc }
    			
    			#Read Network properties
    			$objNetworkProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Network\{0}\{1}\Connection" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", $objNICproperties.NetCfgInstanceId) -ErrorAction SilentlyContinue)
    		      
                #Inform user
    			Write-Host -NoNewline -ForegroundColor White "   ID     : "; Write-Host -ForegroundColor Yellow ( "{0:D4}" -f $intNICid)
    			Write-Host -NoNewline -ForegroundColor White "   Network: "; Write-Host $objNetworkProperties.Name
                Write-Host -NoNewline -ForegroundColor White "   NIC    : "; Write-Host $strNICDisplayName
                Write-Host -ForegroundColor White "   Actions:"
    
                #Disable power saving
                Set-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -Name "PnPCapabilities" -Value "24" -Type DWord
                Write-Host -ForegroundColor Green ("   - Power saving disabled")
                Write-Host ""
    		}
    	} 
    	
    	#Next NIC ID
    	$intNICid+=1
    } while ($intNICid -lt 255)
    
    
    # Request the user to reboot the machine
    Write-Host -NoNewLine -ForegroundColor White "Please "
    Write-Host -NoNewLine -ForegroundColor Yellow "reboot"
    Write-Host -ForegroundColor White " the machine for the changes to take effect."
    
    # Stop writing to log file
    Stop-Transcript | out-null


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    • Marked as answer by the1rickster Friday, May 18, 2018 1:01 PM
    Wednesday, May 16, 2018 8:58 PM

All replies

  • Try this:

    <#
     
    ************************************************************************************************************************
     
    Created:    2018-05-16
    Version:    1.0
    
    Author:     Anton Romanyuk, Login Consultants Germany GmbH (C) 2018
    
    Purpose:    Used to disable selective suspend on MBN adapters
    
    Changelog:
     
    ************************************************************************************************************************
     
    #>
    
    # Determine where to do the logging 
    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 
    $logPath = $tsenv.Value("LogPath")
    $logFile = "$logPath\$($myInvocation.MyCommand).log"
    
    $NeedReboot = "NO"
    
    # Create Logfile
    Write-Output "Create Logfile" > $logFile
     
    Function Logit($TextBlock1){
    	$TimeDate = Get-Date
    	$OutPut = "$ScriptName - $TextBlock1 - $TimeDate"
    	Write-Output $OutPut >> $logFile
    }
    
    # Start Main Code Here
    
    $ScriptName = $MyInvocation.MyCommand
    $RunningFromFolder = $MyInvocation.MyCommand.Path | Split-Path -Parent 
    . Logit “Running from $RunningFromFolder”
    
    Import-Module netadapter
    
    . Logit "Evaluating MBN configuration... "
    Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Enum" -Recurse -ErrorAction SilentlyContinue | foreach {
    $CurrentKey = (Get-ItemProperty -Path $_.PsPath)
    if ($CurrentKey.Service -eq "wmbclass") {
            $FriendlyName = $($CurrentKey.FriendlyName)
            . Logit "Mobile broadband adapter detected: " $FriendlyName
            $adapter = Get-NetAdapter | Select-Object Name,InterfaceDescription | Where-Object InterfaceDescription -eq $FriendlyName 
            . Logit "Disabling selective suspend on $($adapter.Name)"
            Disable-NetAdapterPowerManagement -Name $adapter.Name -SelectiveSuspend        
        }
    }

    The script makes following assumptions: your mobile broadband adapter is using Windows Mobile Broadband service (wmbclass). It will use adapters friendly name to find corresponding network adapter using Get-NetAdapter cmdlet and then disable selective suspend using adapters actual name.

    I tested the script on an HP notebook with a mobile broadband adapter, but your mileage may vary.


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Wednesday, May 16, 2018 11:28 AM
  • Hey Anton!

    We're in the middle of a big rollout at the moment...so my testing got put off until next week.

    Will this script just pass on if it sees no WAN on a unit? I'd prefer to just put it out there on ALL models,
    regardless...and if a unit has no WAN then ideally it would just move on without an error.

    Do you know if this is true?

    Also, since I have a script for disabling 'turning off to save power' on USB Root (except 3.0) and one script fro WLAN, I guess I could just run three scripts per machine rather than try to combine them all into one. Sound legit?

    Wednesday, May 16, 2018 12:52 PM
  • You should be able to run this on all machines - if it does not find any wmbclass adapters, it will just move on. I guess I could add Wifi config into the mix as well, but for the time being, you can run three scripts in sequence to configure various HW components... 

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Wednesday, May 16, 2018 1:00 PM
  • Thanks! I'm looking forward to testing this out and reply back. Since I'm just getting into making these power changes with scripts.....is there an easy way to modify my USB script above to include the Intel 3.0 eXtensible along with the other Root Hubs? If not, it can just be.
    Wednesday, May 16, 2018 1:03 PM
  • This is the response I get from running the PS:

    New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to
    the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
    At C:\Users\Administrator\Desktop\WANPower.ps1:19 char:10
    + $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
    +          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
        + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
     
    You cannot call a method on a null-valued expression.
    At C:\Users\Administrator\Desktop\WANPower.ps1:20 char:1
    + $logPath = $tsenv.Value("LogPath")
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
    Wednesday, May 16, 2018 4:29 PM
  • That would be because the script is geared towards running in the MDT environment - it pulls the path for the log folder from the SMSTS env. Since you ran the script outside of the TS the initialization error is expected. You will find the log file in this case in the root of your system drive (typically C:)

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Wednesday, May 16, 2018 4:40 PM
  • I did see that :)
    It seems to have run w/o issue. Checking Device Mgr I see Sierra Wireless Snapdragon X7 LTE-A WWAN Modem as I should but "Allow the computer to turn off..." is checked. Listed under Modems and Network Adapters. Am I not referencing the correct item?
    Wednesday, May 16, 2018 5:09 PM
  • What does the log file say?

    On the laptop I tested the script, the only option I had in the device manager was selective suspend, so this is what I went for when writing the script. According to the cmdlet description, the Disable-NetAdapterPowerManagement cmdlet disables specific power management features on a network adapter. If no power parameters are specified then all power management features are disabled. The selective suspend indicates that the cmdlet manages the selective suspend capability of the network adapter. The network driver interface specification (NDIS) selective suspend interface allows NDIS to suspend an idle network adapter by transitioning the adapter to a low-power state. This enables the computer to reduce the power overhead on the CPU and network adapter.

    I guess you are talking about a different power management option? Could you post a screenshot here? Then again, based on the documentation, disabling selective suspend should do the trick...


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Wednesday, May 16, 2018 5:16 PM
  • Wednesday, May 16, 2018 5:22 PM
  • The two Sierra WWAN adapters are what I am referring to.
    Wednesday, May 16, 2018 5:22 PM
  • I found that I can disable/uncheck the Qualcomm under Network Adapters, because I can run a PS:

    Get-WmiObject Win32_NetworkAdapter     and see that listed. I can't figure out how to see/list the one under Modems. Then again, I can't find the command to see items listed in the Ports section either, as those need unchecked. I have all USB ones done.
    Wednesday, May 16, 2018 8:16 PM
  • Got it. Simple miscommuniction. Try this - I added filtering for mobile broadband devices and also a safety check that bypassess Microsoft Virtual Wifi Adapter should it be present on the system. See my comments in the script for additional details. Happy testing!

    ##############################################################################################################
    # 
    # Name        : DisablePowerSavingForWLAN.ps1
    # Author      : Ingmar Verheij - http://www.ingmarverheij.com
    # Version     : 1.0, 1 may 2014
    #               - Initial release
    #
    # Description : Prevents Windows from saving power by disabling the WiFi adapter
    # 
    # Dependencies : (none)
    #
    # Usage        : The script runs without parameter but requires elevated privileges, this is enforced by the script.
    #                
    #                
    ##############################################################################################################
    
    
    
    # ------------------------------ Functions --------------------------------------
    function Use-RunAs {    
        # Check if script is running as Adminstrator and if not use RunAs 
        # Use Check Switch to check if admin 
        # http://gallery.technet.microsoft.com/scriptcenter/63fd1c0d-da57-4fb4-9645-ea52fc4f1dfb
        
        param([Switch]$Check) 
        $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") 
        if ($Check) { return $IsAdmin }     
        if ($MyInvocation.ScriptName -ne "") 
        {  
            if (-not $IsAdmin)  
            {  
                try 
                {  
                    $arg = "-file `"$($MyInvocation.ScriptName)`"" 
                    Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop'  
                } 
                catch 
                { 
                    Write-Warning "Error - Failed to restart script with runas"  
                    break               
                } 
                exit # Quit this session of powershell 
            }  
        }  
        else  
        {  
            Write-Warning "Error - Script must be saved as a .ps1 file first"  
            break  
        }  
    }
    # -------------------------------------------------------------------------------
    
    
    # Ensure the script runs with elevated priviliges
    Use-RunAs
    # -
    
    
    # Start log transcript
    Start-Transcript -Path ($MyInvocation.MyCommand.Definition -replace 'ps1','log') -Append | out-null
    # -
    
    
    #Inform user
    Write-Host -ForegroundColor White "Iterating through network adapters"
    $intNICid=0; do
    {
    	#Read network adapter properties
    	$objNICproperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -ErrorAction SilentlyContinue)
    	
    	#Determine if the Network adapter index exists 
    	If ($objNICproperties)
    	{
    		#Filter network adapters
    		# * only Ethernet adapters (ifType = ieee80211(71) - http://www.iana.org/assignments/ianaiftype-mib/ianaiftype-mib)
    		# * root devices are exclude (for instance "WAN Miniport*")
    		# * software defined network adapters are excluded (for instance "RAS Async Adapter")
            # AR: include wwanPP (243), -- 3GPP WWAN & wwanPP2 (244), -- 3GPP2 WWAN per request
            # AR: exclude Microsoft Wi-Fi Direct Virtual Adapter
    
    		If (($objNICproperties."*ifType" -eq 71 -or $objNICproperties."*ifType" -eq 243 -or $objNICproperties."*ifType" -eq 244) -and 
    		    ($objNICproperties.DeviceInstanceID -notlike "ROOT\*") -and
    			($objNICproperties.DeviceInstanceID -notlike "SW\*") -and
                ($objNICproperties.DeviceInstanceID -notlike "*vwifimp_wfd*")
    			)
    		{
                Write-Host $objNICproperties.DeviceInstanceID
    			#Read hardware properties
    			$objHardwareProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Enum\{0}" -f $objNICproperties.DeviceInstanceID) -ErrorAction SilentlyContinue)
    			If ($objHardwareProperties.FriendlyName)
    			{ $strNICDisplayName = $objHardwareProperties.FriendlyName }
    			else 
    			{ $strNICDisplayName = $objNICproperties.DriverDesc }
    			
    			#Read Network properties
    			$objNetworkProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Network\{0}\{1}\Connection" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", $objNICproperties.NetCfgInstanceId) -ErrorAction SilentlyContinue)
    		      
                #Inform user
    			Write-Host -NoNewline -ForegroundColor White "   ID     : "; Write-Host -ForegroundColor Yellow ( "{0:D4}" -f $intNICid)
    			Write-Host -NoNewline -ForegroundColor White "   Network: "; Write-Host $objNetworkProperties.Name
                Write-Host -NoNewline -ForegroundColor White "   NIC    : "; Write-Host $strNICDisplayName
                Write-Host -ForegroundColor White "   Actions:"
    
                #Disable power saving
                Set-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -Name "PnPCapabilities" -Value "24" -Type DWord
                Write-Host -ForegroundColor Green ("   - Power saving disabled")
                Write-Host ""
    		}
    	} 
    	
    	#Next NIC ID
    	$intNICid+=1
    } while ($intNICid -lt 255)
    
    
    # Request the user to reboot the machine
    Write-Host -NoNewLine -ForegroundColor White "Please "
    Write-Host -NoNewLine -ForegroundColor Yellow "reboot"
    Write-Host -ForegroundColor White " the machine for the changes to take effect."
    
    # Stop writing to log file
    Stop-Transcript | out-null


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    • Marked as answer by the1rickster Friday, May 18, 2018 1:01 PM
    Wednesday, May 16, 2018 8:58 PM
  • Ok! I will try this first thing tomorrow. What keeps stumping me is finding the PS cmd to list
    what is in Modems and what is in Ports (COM & LPT). I tried Win32_SerialPort and it shows a few things but not the WAN. I found online that using Win32_NetworkAdapter lists the WAN there and that is being turned off :)
    Just can't find the Win32_ for those two. If you know that, I can apply that to many other things!
    I'll test this tomorrow :)

    In a nutshell, anything that has a power option, they want turned off.

    Wednesday, May 16, 2018 9:01 PM
  • I am about to add this to my TS to test. You said that it bypasses the WIFI if present. Is it possible to allow this to also turn off the WIFI power-save as well as WAN? My team is hoping to get everything set to uncheck as possible. Thanks
    Thursday, May 17, 2018 4:18 PM
  • It will only ignore Microsoft‘s virtual adapter, but will disable power saving on physical devices.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Thursday, May 17, 2018 4:21 PM
  • OK. I'm setting this up now. I still have a NW Adapter PS which does turn off the WAN under Network Adapters and hopefully this one here will take care of Modem NW Adapter (Sierra Qualcomm). Then I still have one for USB which does turn off all of those. Lastly, I have the Ports (COM & LPT) to look into. I'll post back this afternoon!
    Thursday, May 17, 2018 4:28 PM
  • Couldn‘t you just provision a new power plan that uses maximum performance mode for built-in devices thus automatically disabling any power saving features.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Thursday, May 17, 2018 4:33 PM
  • I thought you could set up all settings you want on a pc, save it as a power plan, then import that via MDT.

    I ran the script above and the WAN under Modems is still enabled. Is there a way to check/uncheck all I need and then save that somehow, to import through a TS?

    Thursday, May 17, 2018 5:29 PM
  • Did you reboot after running the script? The setting comes into effect only after rebooting. I would still consider evaluating the power plan route (which has nothing to do with the device manager) instead as it is highly dynamic and does not require running various scripts to get same result.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Thursday, May 17, 2018 5:34 PM
  • I did reboot once MDT completed. Is there a power plan setting which disables Modem devices from turning off to save power? I can only find that option in Dev Mgr.
    Thursday, May 17, 2018 5:36 PM
  • Check the script output: does it find the modem? If it doesn‘t, then it is using a different device type not covered by the script. As far as power plan go - I am on the road right now with limited access my hardware - a quick Google search shows that you can configure wireless adapter settings. I am just not sure if that covers MBN devices as well.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Thursday, May 17, 2018 5:46 PM
  • The script finds the WAN under Network Adapters. It doesn't find it under Modems.
    Thursday, May 17, 2018 6:01 PM
  • Run this and post the output here - looks like the IfType property on your mobile broadband does not match the standard values I found online:

    #Inform user
    Write-Host -ForegroundColor White "Iterating through network adapters"
    $intNICid=0; do
    {
    	#Read network adapter properties
    	$objNICproperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -ErrorAction SilentlyContinue)
    	
    	#Determine if the Network adapter index exists 
    	If ($objNICproperties)
    	{
    		#Filter network adapters
    		# * only Ethernet adapters (ifType = ieee80211(71) - http://www.iana.org/assignments/ianaiftype-mib/ianaiftype-mib)
    		# * root devices are exclude (for instance "WAN Miniport*")
    		# * software defined network adapters are excluded (for instance "RAS Async Adapter")
            # AR: include wwanPP (243), -- 3GPP WWAN & wwanPP2 (244), -- 3GPP2 WWAN per request
            # AR: exclude Microsoft Wi-Fi Direct Virtual Adapter
    
    		
                #Read hardware properties
    			$objHardwareProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Enum\{0}" -f $objNICproperties.DeviceInstanceID) -ErrorAction SilentlyContinue)
    			If ($objHardwareProperties.FriendlyName)
    			{ $strNICDisplayName = $objHardwareProperties.FriendlyName }
    			else 
    			{ $strNICDisplayName = $objNICproperties.DriverDesc }
    			
    			#Read Network properties
    			$objNetworkProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Network\{0}\{1}\Connection" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", $objNICproperties.NetCfgInstanceId) -ErrorAction SilentlyContinue)
    		      
                #Inform user
    			Write-Host -NoNewline -ForegroundColor White "   ID     : "; Write-Host -ForegroundColor Yellow ( "{0:D4}" -f $intNICid)
    			Write-Host -NoNewline -ForegroundColor White "   Network: "; Write-Host $objNetworkProperties.Name
                Write-Host -NoNewline -ForegroundColor White "   NIC    : "; Write-Host $strNICDisplayName
                Write-Host -NoNewline -ForegroundColor White "   IfType: " $objNICproperties."*ifType"
    
    
    
    	} 
    	
    	#Next NIC ID
    	$intNICid+=1
    } while ($intNICid -lt 255)
    


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Thursday, May 17, 2018 8:04 PM
  • Seems to be finding the Network Adapter still, just not the modem, as in the pic I posted above.

    #Inform user
    Write-Host -ForegroundColor White "Iterating through network adapters"
    $intNICid=0; do
    {
            #Read network adapter properties
            $objNICproperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", ( "{0:D4}" -f $intNICid)) -ErrorAction SilentlyContinue)
            
            #Determine if the Network adapter index exists 
            If ($objNICproperties)
            {
                   #Filter network adapters
                   # * only Ethernet adapters (ifType = ieee80211(71) - http://www.iana.org/assignments/ianaiftype-mib/ianaiftype-mib)
                   # * root devices are exclude (for instance "WAN Miniport*")
                   # * software defined network adapters are excluded (for instance "RAS Async Adapter")
            # AR: include wwanPP (243), -- 3GPP WWAN & wwanPP2 (244), -- 3GPP2 WWAN per request
            # AR: exclude Microsoft Wi-Fi Direct Virtual Adapter
                   
                #Read hardware properties
                           $objHardwareProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Enum\{0}" -f $objNICproperties.DeviceInstanceID) -ErrorAction SilentlyContinue)
                           If ($objHardwareProperties.FriendlyName)
                           { $strNICDisplayName = $objHardwareProperties.FriendlyName }
                           else 
                           { $strNICDisplayName = $objNICproperties.DriverDesc }
                           
                           #Read Network properties
                           $objNetworkProperties = (Get-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Network\{0}\{1}\Connection" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", $objNICproperties.NetCfgInstanceId) -ErrorAction SilentlyContinue)
                         
                #Inform user
                           Write-Host -NoNewline -ForegroundColor White "   ID     : "; Write-Host -ForegroundColor Yellow ( "{0:D4}" -f $intNICid)
                           Write-Host -NoNewline -ForegroundColor White "   Network: "; Write-Host $objNetworkProperties.Name
                Write-Host -NoNewline -ForegroundColor White "   NIC    : "; Write-Host $strNICDisplayName
                Write-Host -NoNewline -ForegroundColor White "   IfType: " $objNICproperties."*ifType"
            } 
            
            #Next NIC ID
            $intNICid+=1
    } while ($intNICid -lt 255)

    Thursday, May 17, 2018 8:12 PM
  • Could you still post the output of the code I posted above? Keep in mind, that in the output the modem will carry a different name (on my machine it is being called Mobile Broadband for example)

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Thursday, May 17, 2018 8:24 PM
  • Uh, yeah....I do seem to have just posted your code!
    NW Adapter appears, just not Modem.

    Here it is:

    Iterating through network adapters
       ID     : 0000
       Network: Ethernet (Kernel Debugger)
       NIC    : Microsoft Kernel Debug Network Adapter
       IfType:  6   ID     : 0001
       Network: Local Area Connection
       NIC    : Intel(R) Ethernet Connection I219-LM
       IfType:  6   ID     : 0002
       Network: Wi-Fi
       NIC    : Intel(R) Dual Band Wireless-AC 8260
       IfType:  71   ID     : 0003
       Network: Local Area Connection* 1
       NIC    : Microsoft Wi-Fi Direct Virtual Adapter
       IfType:  71   ID     : 0004
       Network: Cellular
       NIC    : Sierra Wireless EM7455B Qualcomm® Snapdragon™ X7 LTE-A
       IfType:  243   ID     : 0005
       Network: Ethernet 2
       NIC    : Realtek USB GbE Family Controller
       IfType:  6   ID     : 0006
       Network: Bluetooth Network Connection
       NIC    : Bluetooth Device (Personal Area Network)
       IfType:  6   ID     : 0007
       Network: Local Area Connection* 2
       NIC    : Bluetooth Device (RFCOMM Protocol TDI)
       IfType:  1

    Friday, May 18, 2018 12:22 PM
  • I can clearly see the cellular modem in the list there and it is using the IfType of 243. Am I missing something here?

    Network: Cellular NIC : Sierra Wireless EM7455B Qualcomm® Snapdragon™ X7 LTE-A IfType : 243


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Friday, May 18, 2018 12:32 PM
  • The device under NW Adapters, the Sierra EM74558 Qualcomm X7 LTE-A is disabled.
    The one under Modems, the Sierra Snapdragon WWAN is not.

    Friday, May 18, 2018 12:39 PM
  • I see. I would need to do more digging, but at the moment I am afraid I won't have enough time on my hands. However, I am fairly confident you can go down power plan route and save yourself a lot of customization trouble.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Friday, May 18, 2018 12:45 PM
  • I appreciate all of your input. This is becoming frantic for me. Meaning, once I eventually do have that disabled, then I have to figure out how to address Ports (COM & LPT) devices and disable those. I have all USB devices disabled other than the Intel eXtensible 3.0, so there's that as well.

    So, I think until I have them all disabled, I will stash my scripts so far and push them out once they all are done. The techs will have some to do, then not others, and so on...this will make it easier to manually do them all as we are until we need to do none. I will keep searching...and thank you!

    Friday, May 18, 2018 12:48 PM
  • Copy that. If I find anything related to modem HW, I‘ll let you know. In the meantime, I would really appreciate it if you could mark helpful posts in this thread. While we haven‘t found all the answers yet, doing so might help others looking for a help tackling down a similar issue.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Friday, May 18, 2018 12:56 PM
  • Hey there...

    Since I already had a working Get-WmiObject Win32_USBHub powershell script, I made another one and changed it to: Get-WmiObject Win32_NetworkAdapter

    The first disables 'allow the computer to turn off...' for all USB devices (except the 3.0 eXtensible).
    The 2nd does the same for everything in Network Adapters in Dev Mgr.

    I made a 3rd and changed it to: Get-WmiObject Win32_POTSModem
    This disables that feature for my WWAN device.

    Now, I need two figure out how to combine all three into one PS. Then, I'm left with the 3.0 eXtensible USB and anything in Ports (COM & LPT). It's coming along!

    Friday, May 18, 2018 2:31 PM
  • I modified my USBHub PS script to this below. In regard to "allow this computer to turn this device off to save power", it alone turns off ALL

    Modem Devices
    Network Apadter devices
    Port (COM & LPT)
    USB devices

    I didn't bother to change the $hubs name, it's just a vairable to use.

    $hubs = Get-WmiObject Win32_Serialport | Select-Object Name,DeviceID,Description
    $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()
                    }
     }
    }

    • Marked as answer by the1rickster Friday, May 18, 2018 3:32 PM
    Friday, May 18, 2018 3:30 PM