Solved

Powershell Read used Exchange Databasename from AD and add to Description

Posted on 2013-05-20
1
231 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_
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

Make managing Office 365 email signatures a breeze

Are you using Office 365? Having trouble trying to set up email signatures for your users? Getting stressed out managing multiple signatures? Need an easier way to manage? We have a solution for you, try the most-user friendly and powerful signature management tool on the market.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

911 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

19 Experts available now in Live!

Get 1:1 Help Now