Solved

Powershell Read used Exchange Databasename from AD and add to Description

Posted on 2013-05-20
1
253 Views
Last Modified: 2013-05-24
hi,
with script below i like to create, delete or reset password of new exchange user
from a csv like below. My problem is i like to add the orderid and used database
to the description of user to delete
and only the orderID to user i create.
The database used i've to read from ad attribute. The description
i like to add to existing description.
See code in ####

ForEach ($User in  Import-Csv  "c:\import.csv") {    
    If($User.Version -like "M2010") {
        If($User.Action -like "new") {
             # activate Exchange 2010 Mailbox
             Enable-Mailbox -Identity $User.UserID -Database DB0001
        } # end if create
        If($User.action -like "delete") {
             # deactivate Exchange 2010 Mailbox
             Disable-Mailbox -Identity $User.UserID 
########################################
#$descnew = $entry.OrderID	
#$desccurrent = (Get-ADUser -identity $entry.userid -Properties Description).Description
#set-aduser -identity $user.userid -description ($desccurrent+' '+$descnew+' ')
#Read used database from AD
########################################

        } # end if delete
  If($User.Action -like "reset") {
       #If($User.Version -like "reset") {
       # reset password of AD-Account
Import-Module activedirectory
$NewPassword = $user.UserId.Insert(5,"$").Insert(3,"p").Remove(0, 1).Insert(0,"C")
write-host The new password is $newpassword
Set-ADAccountPassword -Identity $user.userid -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "$newpassword" -Force)

Open in new window


CSV i'm using

UserId,OrderId,Action,Version
Z402594,151911,New,M2010   - only orderid to desc.
Z524027,151928,Delete,MSXC2010  - read DB and orderid to desc.

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
1 Comment
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39180346
here:
$db = 'DB0001'
$desccurrent = (Get-ADUser -identity $entry.userid -Properties Description).Description
$desccurrent = "{0}, OrderID: {1}, DB: {2}" -f $entry.OrderID	, $descnew, $db 
set-aduser -identity $user.userid -description $desccurrent

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A brief introduction to what I consider to be the best editor for PowerShell.
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 …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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…

730 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