(13.2) Mass Deployment (COMPUTERNAME+USERNAME)

mts-arkil
mts-arkil Posts: 20
edited May 2023 in General questions

Hello.

When installing the bat.file I want to add clients to a group. And in that group I want the clients name to contain both Computername and Username.

I have tried using the parameter in assignoptions --alias %COMPUTERNAME+USERNAME% Result: PCxxxx+yyy (incorrect way)

Can I use a variable, something like "COMPUTERNAME" + " " + "USERNAME" = %NAME%

Comments

  • NigeNZ
    NigeNZ Posts: 8 ✭✭

    @mts-arkil Did you get anywhere with this, i need this function also

  • mts-arkil
    mts-arkil Posts: 20

    No not yet, I've been away from work for 10 weeks. Just got back.

    I just add them manually afterwards, which I find to much time consuming. But at least we dont hire new staff so often, but I would really like to have this completly automated. 

  • NigeNZ
    NigeNZ Posts: 8 ✭✭

    They advised username is not currently available as an option =(

  • TimOlsen
    TimOlsen Posts: 3 ✭✭
    edited March 2022

    This might be an old thread, but I have the second best solution.

    Use this in a Batch script to grab username while under SYSTEM account. It finds the username of the running explorer.exe, which should always belong to an actual user (only works if a user is logged in, but might be unreliable if more than 1 user is logged in).

    Code below:


    :: Getting username for running explorer.exe process.

    :: Will return empty string if no user is logged in (unreliable if more than 1 user is logged in)

    for /F "tokens=8" %%i in ('tasklist /V /FI "IMAGENAME eq explorer.exe" ^| findstr "explorer.exe"') do set usern=%%i

    for /f "tokens=2 delims=\" %%a in ("%usern%") do set usern=%%a

    set compuser=%COMPUTERNAME% - %usern%


    Now you've got the combined computername and username in %compuser% that you can paste in the parameter "--alias" 😊