Solved

powershell add description Text + blank + databasename

Posted on 2014-09-16
5
177 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 13

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 13

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

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

13 Experts available now in Live!

Get 1:1 Help Now