Solved

powershell add description Text + blank + databasename

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This article will help you understand what HashTables are and how to use them in PowerShell.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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