Solved

format Variable in string in Powershell

Posted on 2011-09-02
3
518 Views
Last Modified: 2012-08-13
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
Comment
Question by:brittonv
  • 2
3 Comments
 
LVL 18

Expert Comment

by:x-men
Comment Utility
$group.remove("WinNT://$env:COMPUTERNAME/$BU",user")

0
 
LVL 18

Accepted Solution

by:
x-men earned 250 total points
Comment Utility
ups...

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

0
 
LVL 16

Assisted Solution

by:Dale Harris
Dale Harris earned 250 total points
Comment Utility
Google: formatting strings in powershell

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

HTH,

Dale Harris
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now