locked
powershell Get-Counter -ListSet * return Null value in script launch in task manager at startup. RRS feed

  • Question

  • I did a script to ger network usage when i am not logged, based on get-counter.

    It working in my session, but if I launch it with task manager in startup of the computer, the script work, it not working.

    I test the following command in debug.ps1

    -------------------------------------------------------

    # task manager parameters

    # run if user not log

    # at startup

    # program : powershell.exe

    # argument : -noprofile -executionpolicy RemoteSigned -file C:\Users\myuser\debug.ps1 

    $dirlocation="C:\users\$env:USERNAME"

    $debugFile="$dirlocation\debug.txt"

    write-output  "test get-counter" | out-file $debugFile

    Get-Counter -ListSet * | out-file $debugFile  -Append

    write-output  "end test" | out-file $debugFile  -Append

    -------------------------------------------------------------------

    I have in debut.txt all Listset if I run script in my session

    But I have the following if A start it with task manager

    C:\users\MyUser   > Get-Content .\debug.txt
    test get-counter
    end test
    C:\users\MyUser> 

    Can someone explain how get %network used in program launch by task manager if get-counter not work ?



    • Edited by Moatwork Friday, December 8, 2017 4:24 PM
    Thursday, December 7, 2017 4:08 PM

All replies

  • You need to run the script under your account I task manager,


    \_(ツ)_/

    Thursday, December 7, 2017 4:47 PM
  • it's already what I did

    But I find the solution.

    It work only if I check the box : run with maximal persission

    • Proposed as answer by I.T Delinquent Monday, December 11, 2017 11:48 AM
    Friday, December 8, 2017 4:34 PM
  • Hi,

    Good to hear that you have solved this issue by yourself. In addition, thanks for sharing your solution in the forum as it would be helpful to anyone who encounters similar issues.

    If there is anything else we can do for you, please feel free to post in the forum.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, December 11, 2017 11:04 AM