?
Solved

powershell add description Text + blank + databasename

Posted on 2014-09-16
5
Medium Priority
?
184 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 400 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 1600 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

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