Script Add bulk user with CSV, and set expiration date

After importing the AD module, the line:
Set-ADAccountExpiration -identity JohnDoe -timespan "365"
Works just fine, but how would you automate this with a script that would read a csv-file. The -identity cmd dosen't seem to like my $SAM setup. Perhaps it's a better way to get-aduser and pipe it to set-accountexpiration. Is there a swift way to add the
expire date to the user I just created with my CSV-file?
Thanks!

Thank You!
You're very welcome.
-AccountExpirationDate parameter of New-ADUser only seem to work with -DateTime, a specific date, while -TimeSpan is optimal for this solution.
You can use Get-Date's AddDays method to generate a datetime object for use in this situation, see the code I'm posting below for an example.
Now on to the next challange to warn me when they reach "32" days before expiration. Was thinking of running a Task Scheduled bath file that could collect number of days left and report it if below the mentioned days.
Here's one method you can use for finding these users:
$cutoffDate = (Get-Date).AddDays(32)
Get-ADUser -Filter * -SearchBase 'OU=Users - TEST,DC=domain,DC=com' -Properties AccountExpirationDate |
Where { $_.AccountExpirationDate -and $_.AccountExpirationDate -lt $cutoffDate }
Just so you're aware, we generally try to keep threads to a single question.
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing)

Similar Messages

  • Can the Terminal add a user(with all options) on a single line?

    Howdy All,
    Can the Mac Terminal add a user, with all options desired, on a single line?    If so, can I get an example of this single terminal line to work from?
    Thanks

    Thanks Drew!   You have some great thoughts there. Perhaps I should provide a clearer environment of each high school(4). All classrooms have a lock down Windows environment. (There are no Macs any where in any classrooms.) The mini-tower will be the only Mac on each high school campus. we're in Dell country. The desktops are locked in such a way that only the ghosted/installed software on each hard drive works and no other software can be installed. USB sticks can't run any exe, jar, or other executable file. Even the other drives on the network can't run them. This has been setup to prevent students from bringing games into the environment and running them. Only the single classroom in each high school, where Web Tech is taught, has a ftp tool installed. Students cannot bring and use their own laptops either. So there really isn't any stray ftp activity happening. You cannot "ftp" out of the network! And there is only the one Mac available per campus.  All this makes it certainly easier to maintain for sure. I am the only user in the school district they let run a personal laptop...mine has Ubuntu (tweaked).  My knowledge of Linux has led them to assign this project to me. They are MS based entirely and so is their knowledge base.
    I've got to teach the other 4 teachers how to manage the mini-tower.  Basically it is this:
         Start and stop Apache2,
         Start and stop vsftp,
         Add ftp users(students will only have directory:           /Library/Server/Web/Data/Sites/Default/studentlastname.firstname  )  Students will not log on to the min-   tower directly as any normal user would, but only through ftp. (I.E. no /home directory) ,
         Remove/delete students as needed
         (I'll pre-install cgi-bin scripts on these to keep it simpler on the other teachers and myself.)
    With this in mind, you can see why a basic script or single command line to install these students would be great! I want to keep it simple to avoid mistakes the teachers might make adding users. Once I understand adding a user (in a terminal) better on a Mac, I may write a script to make it happen for them.
    I'd also like to understand removing/deleting a student/user better to insure everything is gone when executed.
    I hope this clear things up. Any help is much appreciated.    THANKS!!!

  • How can i create bulk users with system Administrator responsibility in EBS

    Hi Gurus
    I want to create or Load Bulk users with System Administrator Responsibility in Oracle EBS using simple steps (Concurrent,API,OI,Back end). Is it Possible to create user with system Administrator Responsibility using concurrent/API/OI. Kindly help me in creating users with following details.
    Username     User Description     Employee Name     E-Mail ID     
    Das A R     GM     Mr. Arup R.Das     [email protected]     
    sandeep.n     Sr. Manager - Works     Mr.sandeep.Naik     [email protected]     
    sandeep     Asst. Manager - Excise Mr.Sandeep Bhosale     [email protected]     
    Thanks in Advance
    Hemanth.C

    Login to to the Ebiz database with user/paswad app/app and verify the detiled parameter for below DB procedures which are being used to create, update user and responsibility related work
    Create User FND_USER_PKG.CreateUser
    Disable user FND_USER_PKG.DisableUser
    Update USer FND_USER_PKG.UpdateUser
    Enable User FND_USER_PKG.EnableUser
    Add Responsibility FND_USER_PKG.AddResp
    Update Responsibility FND_USER_PKG.AddResp
    Remove Responsibility FND_USER_PKG.DelResp
    In your case call two method
    1.CreateUser pass all parameter
    2. add responsibility - for responsibility check the KEY/ID value for System administrator in FND_RESPONSIBILITY table. while calling method pass this ID/KEY
    Better put this in EBIZ forum.

  • How to map the bulk users with the required  roles in portal at one time

    Hi,
    Would anyone tell me how to map the bulk users with the required roles in portal at one time?

    Thanks for all the reply.
    <b>I need to assign 1 or 2 group to n((eg) 1000)number of users</b>
    I tried the first option like
    [group]
    gid=
    gdesc=
    user=
    Thr problem with this is I could n't put more no of users in the notepad.
    I would be able to put only 150 users in the single line of notepad. If it goes to next line it is not working.
    I tried creating seperate notepad but in Import it says "exists"
    I'm not sure about LDAP. Would anyone explain me the best approach to do this.

  • How do you Enable/Disable a user's ScreenSaver and set it's time

    How do you Enable/Disable a user's ScreenSaver and set it's "Start Screen Saver" time.
    I am writting an application in java which uses JNI and a screen saver to lock users out of the computer unless they enter the correct username and password.
    If they enter the correct password I need to Enable the ScreenSaver at a specific about of time (time can be changed remotely) so I can "log out" the user.
    I need to disable the screen saver after the screen saver runs so that it doesn't run while the java login program is running.
    I have this working already on Windows XP but can't find any way to program this on Mac OS X.
    Thank you for any help!

    http://forums.macosxhints.com/showthread.php?t=61525
    Disable
    defaults -currentHost write com.apple.screensaver idleTime 0
    Enable for 180 seconds
    defaults -currentHost write com.apple.screensaver idleTime 180

  • Send Email for manager of the user with Login and Password the user.

    Hello everyone,
    I need to send an email to the manager of the user with login and password when it is created in AD.
    I already have a mail server configured in the IT Resource. It has some component of the IDM that solve this issue?
    Anyone you help me with the next steps?
    Thank you.

    Thank you for your attention.
    It did not work, I did another test to send email notifying you when the User change password.
    The following error message appears in oim_server1-diagnostic.log:
    [2011-08-08T19:21:30.865-03:00] [oim_server1] [NOTIFICATION] [] [oracle.iam.passwordmgmt.impl] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 88a924181f586e03:-25ab9c82:131aa884464:-8000-0000000000008862,0] [APP: oim#11.1.1.3.0] Resetting password
    [2011-08-08T19:21:30.936-03:00] [oim_server1] [NOTIFICATION] [IAM-0080013] [oracle.iam.platform.kernel.impl] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 88a924181f586e03:-25ab9c82:131aa884464:-8000-0000000000008862,0] [APP: oim#11.1.1.3.0] Kernel executing default validation with process id, event id, entity and operation 59,612.0.User.RESET_PASSWORD
    [2011-08-08T19:21:31.155-03:00] [oim_server1] [NOTIFICATION] [IAM-3050013] [oracle.iam.identity.usermgmt.impl] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 88a924181f586e03:-25ab9c82:131aa884464:-8000-0000000000008862,0] [APP: oim#11.1.1.3.0] Searching for users with the specified criteria.
    [2011-08-08T19:21:32.018-03:00] [oim_server1] [WARNING] [] [oracle.iam.passwordmgmt.impl] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 88a924181f586e03:-25ab9c82:131aa884464:-8000-0000000000008862,0] [APP: oim#11.1.1.3.0] Sending Reset Password Notification is not successful
    [2011-08-08T19:21:32.639-03:00] [oim_server1] [NOTIFICATION] [IAM-0080046] [oracle.iam.platform.kernel.impl] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 88a924181f586e03:-25ab9c82:131aa884464:-8000-0000000000008862,0] [APP: oim#11.1.1.3.0] Completed orchestration with action result - oracle.iam.platform.kernel.vo.EventResult@4fe0d018
    [2011-08-08T19:21:32.642-03:00] [oim_server1] [NOTIFICATION] [IAM-0080011] [oracle.iam.platform.kernel.impl] [tid: [ACTIVE].ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: oiminternal] [ecid: 88a924181f586e03:-25ab9c82:131aa884464:-8000-0000000000008862,0] [APP: oim#11.1.1.3.0] Orchestration process with id 59,612 started running in a new thread.
    Edited by: Piza on 08/08/2011 15:24
    Edited by: Piza on 08/08/2011 15:26

  • How to retrieve users logging-in and logging-out date and times in SharePoint

    At the moment I am using SherePoint 2013 with a few tenants.
    I am going to have access to the users logging-in and logging-out dates and times.
    For instance, I would like to know the detail of the dates and times which a particular user of a tenant has logged-in and logged-out during the past few months.
    Any idea?

    You can retrieve that info from the IIS log files. Maybe you can use a free IIS reporting tool that I've built and adjust it to your own needs, you can get it here:
    http://gallery.technet.microsoft.com/office/The-SharePoint-Flavored-5b03f323
    Btw, in a web environment usually there is no such thing as the log-out date and time because the end user just stops making requests. So, you've got to take a look at the last request and by default, after 20 minutes the session times out and you can assume
    the session has ended.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • How to plot a log graph using grapher with a given set of data

    hi there,
    im just wondering is it possible to plot a log graph in the grapher software with a given set of data, and also give an error bar and a best-fit line for it?
    so here is the set of data,
    Concentration of BCh (M)
    Mean % Specific Binding (%)
    Standard Deviation
    3 ×10⁻⁹
    71.52
    9.52
    1 ×10⁻⁸
    57.30
    8.56
    3 ×10⁻⁸
    39.15
    9.40
    1 ×10⁻⁷
    24.13
    10.15
    3 ×10⁻⁷
    14.77
    3.31
    1 ×10⁻⁶
    7.22
    2.02
    hope someone could help

    Try these:
    http://y.barois.free.fr/grapher/Bienvenue.html
    http://homepage.mac.com/tlindywizdumb/math/Grapher_index.htm
    http://homepage.mac.com/tlindywizdumb/math/Grapher/Grapher_HowTo.pdf

  • Export Billing Configuration with CIN and Foreign Trade Data

    Hi,
    I need detail configuration of Export billing with CIN and foreign trade data for my understnading the configuration process for export billing process.
    Thanks in advance

    Dear Tarun
    I feel you need detailed configuration of CIN.
    Two diffrent CIN configurations supported bySAP
    TAXINJ & TAXINN. First is formula based & second is conditions based
    Search in SDN you will get many threads.
    Regards
    Deepu Pilla

  • OMJ5(set expiration date chk) there is no plant code that i am created

    Hello. guys
    I'm doing IMG...
    But, there is problem.
    in IMG - Logistic general - Batch Management - Shelf Life expiration Date
    - Set Expiration Date Check (OMJ5).
    there is only one plant code. (that code is 0001.)
    why there are my plant code that i made. (Actually, I create 2 plant code. (copy as from 0001)
    what is wrong??
    plz, help me~ thanks!
    Edited by: KeunChan Lee on Jun 15, 2010 1:41 PM

    You can maintain the same as under:
    IMG>Materials Management>Inventory Management and Physical Inventory-->Plant Parameters
    Create New entries here or you can copy the same from already existing entries. Herein tick the BBD/Prod. Date for enabling SLED.
    Hope this helps you out.
    Enjoy SAP,
    ParagM

  • Powershell Script to Remove and Add the user with same permission

    Hi,
    I need to remove all users within all site collection of a web application and add them back with same permission level. We have a siteminder based custom trusted identity token issuer configured in our farm. The name of the issuer will be changed
    due to some architectural decissions , hence all users which are there before will be unidentified, hence need to be removed and added again.
    Currently each user looks like :                       c:0ǹ.t|Identity Token Issuer1|user1
    Post the change the user will look like:          c:0ǹ.t|Identity Token Issuer New|user1
    I am looking for a powershell script which can handle this operation.
    Thanks, Bivsworld

    Bivsworld,
    Below link should give you a start.
    http://www.sptechlearn.com/2014/10/delete-users-from-user-information-list.html

  • Add Bulk Users to Project Server 2010 site using a Script

    I have 100 users that I need to add to a Project Server 2010 site. Add these through server settings would take a week to do. Is there a way to add users in bulk like with a script or something that can pull from an CSV
    Thank you for your help!

    Hi,
    I am not sure if I got your question?
    If you want to add these users to a site of a specific project, just add them as team members to this project. This will provide read access to them. If you assign them to a task within this project, they will alos get write access in this site.
    If you want to add this users as Project Server resources and users and just have a list of them, you can use copy/paste. Go to Resource Center and click on Open. Project client will start with checked out Enterprise Resources. Add columns Windows User Account,
    Email Address, and all other fields you want to fill. Make sure that the columns and the sequence of columns does match the columns in your file. Use copy/paste to insert all users into Project. Save and Close. Use Option Bulk Edit, if you want to define
    eg Timesheet Manager. As a last step go to Server Settings - Manage Groups and add them to the appropriate groups.
    Does this answer your question?
    Barbara

  • Export AD users to csv and import them to Exchange using shell

    I'm implementing Exchange 2013 on a Windows server 2012R@ network.
    Now i want to import the users from the AD on the server into the Exchange server.
    I've created a csv from the AD users, but there begins the problem.
    I can't seem to get past some isseus..... The following script is where i'm at at the moment.
    C:\Windows\system32> $list=import-csv "C:\users......." |foreach {new-mailbox $_.emailaddresss}
    when i run this script in the shell of exchange i'm missing some parameters.
    I need a password and a userprincipalname.
    Can i include this in my script? And which password do i need?

    Are you implementing Exchange 2013 into an existing AD environment or are you trying to import users that exist in a separate AD forest into your environment?
    If you are implementing Exchange into an existing AD forest where the AD user accounts already exist, do use the Enable-Mailbox cmdlet instead as this adds a mailbox for an existing AD user.  The New-Mailbox cmlet will create a new AD user account,
    which would be a problem if the accounts already exist.
    If you are trying to bulk create mailboxes in a new AD environment where these AD accounts do not already exist, then you will need to create a password to assign to all the new accounts being created.
    This link has information on creating new mailboxes using an input CSV and assigning passwords via the EMS.
    http://exchangepedia.com/2006/11/exchange-server-2007-bulk-creation-of-mailboxes-using-exchange-management-shell.html

  • Windows Server 2008 R2: Script create multi users with Windows Powershell

    Dear All,
    I have windows server 2008 R2 Active Directory Domain Service. I want to create multi users by using Windows PowerShell.
    Could you guide?
    BR,
    Khemarin Set
    [email protected]

    Dear Awinish,
    Your link very my solution. but i'm very basic with Powershell and I never have experience with it.
    This is the link original script that you are provide:
    function Select-FileDialog 
    param([string]$Title,[string]$Directory,[string]$Filter="CSV Files (*.csv)|*.csv")
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
    $objForm = New-Object System.Windows.Forms.OpenFileDialog
    $objForm.InitialDirectory = $Directory
    $objForm.Filter = $Filter
    $objForm.Title = $Title
    $objForm.ShowHelp = $true
    $Show = $objForm.ShowDialog()
    If ($Show -eq "OK")
    Return $objForm.FileName
    Else
    Exit
    $FileName = Select-FileDialog -Title "Import an CSV file" -Directory "C:"
    $ExchangeUsersOU = "OU=ExchangeUsers" # I don understand, I have all users are store in all-users ou
    $domain = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
    $DomainDN = (([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).Domains | ? {$_.Name -eq $domain}).GetDirectoryEntry().distinguishedName
    $final = "LDAP://$DomainDN"
    $DomainPath = [ADSI]"$final"
    $cOU = $DomainPath.Create("OrganizationalUnit",$ExchangeUsersOU)
    $cOU.SetInfo()
    $UserInformation = Import-Csv $FileName
    $OUPath = "LDAP://$ExchangeUsersOU,$DomainDN" # I don understand
    $UserPath = [ADSI]"$OUPath"
    Write-Host "---------------------------------------------------------------"
    Write-Host "Creating LAB Users"
    Write-Host ""
    Write-Host "---------------------------------------------------------------"
    Foreach ($User in $UserInformation){
    $CN = $User.samAccountName
    $SN = $User.Surname
    $Given = $User.givenName
    $samAccountName = $User.samAccountName
    $Display = $User.DisplayName
    $LABUser = $UserPath.Create("User","CN=$CN")
    Write-Host "Creating User: $User.samAccountName"
    $LABUser.Put("samAccountName",$samAccountName)
    $LABUser.Put("sn",$SN)
    $LABUser.Put("givenName",$Given)
    $LABUser.Put("displayName",$Display)
    $LABUser.Put("mail","$samAccountName@$domain")
    $LABUser.Put("description", "Lab User - created via Script")
    $LABUser.Put("userPrincipalName","$samAccountName@$domain")
    $LABUser.SetInfo()
    $Pwrd = $User.Password
    $LABUser.psbase.invoke("setPassword",$Pwrd)
    $LABUser.psbase.invokeSet("AccountDisabled",$False)
    $LABUser.psbase.CommitChanges()
    Write-Host "Script Completed"
    If posible, could you help to correct script as: I have domain name: hello.net. All user are store in all-users ou.
    BR,
    Khemarin Set
    [email protected]

  • How to add text in .ai file and  set position, font, size and colour

    I want to place multiple lines of of text (individually) into .ai file and set size, font, colour and position for each.
    Preferably text should have origin in a single point (rather than be framed)
    Hope anyone can help me out.
    Thank you in advance.

    Here's what's in the Scripting Reference
    Creating and modifying text frames
    // Creates a document with text frames displaying path, area and point
    // text, changes the content of each frame then deletes the 2nd frame
    // create a new document
    var docRef = documents.add();
    // create 3 new textFrames (area, line, point)
    // Area Text
    var rectRef = docRef.pathItems.rectangle(700, 50, 100, 100);
    var areaTextRef = docRef.textFrames.areaText(rectRef);
    areaTextRef.contents = "TextFrame #1";
    areaTextRef.selected = true;
    // Line Text
    var lineRef = docRef.pathItems.add();
    lineRef.setEntirePath( Array(Array(200, 700), Array(300, 550) ) );
    var pathTextRef = docRef.textFrames.pathText(lineRef);
    pathTextRef.contents = "TextFrame #2";
    pathTextRef.selected = true;
    // Point Text
    var pointTextRef = docRef.textFrames.add();
    pointTextRef.contents = "TextFrame #3";
    pointTextRef.top = 700;
    pointTextRef.left = 400;
    pointTextRef.selected = true;
    redraw();
    // count the TextFrames
    var iCount = docRef.textFrames.length;
    var sText = "There are " + iCount + " TextFrames.\r"
    sText += "Changing contents of each TextFrame.";
    // change the content of each
    docRef.textFrames[0].contents = "Area TextFrame.";
    docRef.textFrames[1].contents = "Path TextFrame.";
    docRef.textFrames[2].contents = "Point TextFrame.";
    redraw();
    docRef.textFrames[1].remove();
    redraw();
    // count again
    var iCount = docRef.textFrames.length;
    Your are looking stuff with the pointTextRef.

Maybe you are looking for

  • Problems when importing multiple files into key frames

    I'm creating an interactive flash application that uses hundreds of individual renders from a 3d modelling app.  The image file size is 800 x 600.  Each sequence that i import to the stage is around 120 images and each gets put into a separate key fr

  • Web Page composer : new layout does not display Page Header Links Manager

    Hello, I am currently working with Web Page Composer, and this is my issue : when using original layout, the header are displayed with "Add to favorites", "Print", "E-mail" etc... and all chosen links via the "Select Page links" link. But whith my cu

  • Dynamic ALV Table Ouput

    Hi Experts, I have one final table(assume it contains 25 fields)  for final output in ALV report. I've 5 different radiobuttons on my selection-screen. Depending upon the radiobutton selected , user needs 5 different report outputs from this one tabl

  • Where to put system, samples, audiofiles, if 4 harddiscs available?

    I´m sure this has been posted, but my search result was too big and I could figure out, just to look for thread-titles: I´m looking for the best way to organize my G5 2 Ghz dual with 2 internal harddiscs, 1 external SATA-drive for 2 harddiscs and 1 f

  • Oracle Report 10g crashes immediatly after opening.

    Hi All, I have installed Oracle Reports Developer in my local system and it always crashes immediately after the oracle welcome screen. I have all system Admin privilege to my system and having enough privilege to TEMP folder. Kindly help me in getti