Solved

format Variable in string in Powershell

Posted on 2011-09-02
3
524 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

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

0
 
LVL 18

Accepted Solution

by:
x-men earned 250 total points
ID: 36473573
ups...

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

0
 
LVL 16

Assisted Solution

by:Dale Harris
Dale Harris earned 250 total points
ID: 36474297
Google: formatting strings in powershell

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

HTH,

Dale Harris
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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