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
Solved

powershell add description Text + blank + databasename

Posted on 2014-09-16
5
180 Views
Last Modified: 2014-09-16
hi

to add database to user description i've the code below. Now i like to include a text before and blank.
The result sould be "text DB001"

$db = (Get-Mailbox -Identity S12345 | Select-Object Database);set-aduser -identity S12345  -description $db

$db = (Get-Mailbox -Identity S12345 | Select-Object Database);set-aduser -identity S12345  -description $db

Open in new window

0
Comment
Question by:Mandy_
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:frankhelk
ID: 40325089
Havn't tested that, but how about

$db = (Get-Mailbox -Identity S12345 | Select-Object Database);set-aduser -identity S12345  -description "text $db"

Open in new window

0
 
LVL 2

Author Comment

by:Mandy_
ID: 40325146
The result is "text @{Database=DB0001}"  How can i remove @{Database=] ?
0
 
LVL 14

Assisted Solution

by:frankhelk
frankhelk earned 100 total points
ID: 40325437
Add a subsequent code line:

$db = (Get-Mailbox -Identity S12345 | Select-Object Database);set-aduser -identity S12345  -description "text $db"
$db = $db.Replace("@{Database=","").Replace("}","")

Open in new window

0
 
LVL 39

Accepted Solution

by:
footech earned 400 total points
ID: 40325808
Better to change like this.
$db = (Get-Mailbox -Identity S12345 | Select-Object -expand Database);set-aduser -identity S12345  -description "text $db"

Open in new window

0
 
LVL 2

Author Closing Comment

by:Mandy_
ID: 40325940
@frankhelk
Thank you for your assistent. Your suggestion does not work. Getting error with replace. I changed to

$db = (Get-Mailbox -Identity S12345 | Select-Object Database) -replace "@{Database="," ";set-aduser -identity S12345 -description "text $db"

Open in new window


Thats working only leaving the ].  ;)

But the best solution is from footech. Thank you so much,
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
Set OWA language and time zone in Exchange for individuals, all users or per database.

766 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