0

With a batch script to set variable from For and Tokens and remove the first char:

for /f "tokens=1,2,3,4,5,6,7,8" %A in (
 'net user %username% /domain ^| 
 find "Global Group memberships"' 
) 
do set groupname=%D:~1%

The groupname is like *Groupname and I need to delete the * char.

I check the variable using echo %groupname% the output is *Groupname:~1%

How can I get the desired result?

Greg Askew
  • 35,880
  • 5
  • 54
  • 82
  • Can you please explain what it is you are trying to do? – uSlackr Aug 11 '23 at 12:03
  • I strongly recommend you use Powershell for this. For a couple reasons - 1) The net user command returns truncated group names and 2) powershell provides so much more capability with variable and string handling. 3) you are investing in a future proofed skill. – uSlackr Aug 11 '23 at 12:17
  • If you can load the AD module try this: `get-aduser $env:username -Properties memberof |select -expandproperty memberof|get-adgroup|select name` – uSlackr Aug 11 '23 at 12:27

0 Answers0