locked
Win10 Accessed denied to netadaper functions RRS feed

  • Question

  • Hi Guys,

    I am trying to run a Client script file on Win10 under powershell 5.0/1/17134/48 which calls the NIC to reset the speed on the fly. Code section below

    'rem pick up network attachment data'
    $NIC=Get-Netadapter 
    'rem strip the ethernet connection name '
    $NIC1=$NIC.name[1]
    'rem speed variables. OUTPUT SPEED IS DEPENENT ON NETWORK SPEED> USE 1.0 Gbps switch/hub'
    $speed1="10 Mbps Full Duplex"
    $speed2="100 Mbps Full Duplex"
    $speed3="1.0 Gbps Full Duplex"
    $speed4="1.0 Gbps Half Duplex"
    $speed5="100 Mbps Half Duplex"
    $speed6="10 Mbps Half Duplex"

    'rem CHANGE SET LINE TO VARY SPEED'
    $i=1
    'rem LOOP CONTROL cntrl C to exit'

    Do
    {
    Set-NetAdapterAdvancedProperty -name $NIC1 -displayname "Speed & Duplex" -DisplayValue $speed1
    Get-NetAdapter
    CD\

    }

    :-------------------------------------------------------------------------------------------------------------

    At Set-NetAdapterAdvancedProperty I am getting Access is denied :Windows System Error 5

    Also disable-netadapter -name "Ethernet" also gives denied access.

    Any ideas please.???

    Additional:- 1) $Speed4 does not exist.

    2) Code works fine under POWERSHELL ISE single step

     3) Code fails when run on desktop "bat like file".

    4) User rites at administrator level.

    5)Window10 at desktop level only has run at "power shell" and not run at "power shell admin level."

    Still stuck.?????

    • Edited by BURDON55 Tuesday, June 5, 2018 2:31 PM
    Tuesday, June 5, 2018 11:01 AM

Answers

  • Hi Bill,

              Thank you for the reply, correct. A bat type file need elevation before running under windows 10 Client.  No simple route . But the following code at the front of the bat file kicks it into life.

     ....https://www.petri.com/run-powershell-scripts-with-administrative-privileges......

    It error on prams and makes a fuss on second opening pass . But runs the script. Go to to love Windows 10.Thank You. 

    • Marked as answer by BURDON55 Tuesday, June 5, 2018 4:12 PM
    Tuesday, June 5, 2018 4:11 PM

All replies

  • Access denied means just what it says - the user running the command does not have permission to make that change.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by BURDON55 Tuesday, June 5, 2018 3:58 PM
    • Unmarked as answer by BURDON55 Tuesday, June 5, 2018 3:58 PM
    Tuesday, June 5, 2018 2:24 PM
  • Hi Bill,

              Thank you for the reply, correct. A bat type file need elevation before running under windows 10 Client.  No simple route . But the following code at the front of the bat file kicks it into life.

     ....https://www.petri.com/run-powershell-scripts-with-administrative-privileges......

    It error on prams and makes a fuss on second opening pass . But runs the script. Go to to love Windows 10.Thank You. 

    • Marked as answer by BURDON55 Tuesday, June 5, 2018 4:12 PM
    Tuesday, June 5, 2018 4:11 PM