Solved

Powershell Read used Exchange Databasename from AD and add to Description

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
To show how to generate a certificate request 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 Servers >> Certificates…
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

729 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