Solved

Powershell Read used Exchange Databasename from AD and add to Description

Posted on 2013-05-20
1
218 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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
In this video we show how to create a Contact 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 Recipients >> Contact ta…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

772 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

11 Experts available now in Live!

Get 1:1 Help Now