• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

format Variable in string in Powershell

I am trying to create a script to remove specific users from groups.

The following works just fine:
$group.remove("WinNT://"+$env:COMPUTERNAME+"/Bad_User,user")

However I want to use a variable for the account name and I can't ge t it to work.  Something a long the line of:

$BU = "Bad_User"
$group.remove("WinNT://"+$env:COMPUTERNAME+"/"$BU",user")

Please,
How do I format this string, and what should i have googled to figure it out?
0
brittonv
Asked:
brittonv
  • 2
2 Solutions
 
x-menIT super heroCommented:
$group.remove("WinNT://$env:COMPUTERNAME/$BU",user")

0
 
x-menIT super heroCommented:
ups...

$group.remove("WinNT://$env:COMPUTERNAME/$BU,user")

0
 
Dale HarrisProfessional Services EngineerCommented:
Google: formatting strings in powershell

Click on second link:
http://technet.microsoft.com/en-us/library/ee692790.aspx

HTH,

Dale Harris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now