Solved

powershell add description Text + blank + databasename

Posted on 2014-09-16
5
181 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_
[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
  • 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 40

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
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…

726 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