How do I correctly append/prepend a description for an AD user?

I'm still a little new to PowerShell, but experienced enough to be able to search the net and formulate my own script, but I've been stuck on this one part for an entire day now.  Here's what I'm trying to accomplish using PowerShell 4:
I've already run the following script to produce a list of users in our domain that have not logged into the network for more than 90 days (This is done as a separate requirement of the business):
search-adaccount -accountinactive -usersonly -timespan "105" | Export-Csv "k:\Inactive90 $(get-date -f yyyy-MM-dd).csv"
So I have a csv file with the following headers (and data below it, but removed for business privacy):
AccountExpirationDate Enabled LastLogonDate LockedOut Name ObjectClass ObjectGUID PasswordExpired PasswordNeverExpires UserPrincipalName
I need to pre-pend the date of disable within the description of the AD user.  The problem that I'm experiencing is that the resultant description that I'm receiving is that the first part of the description is what I expect, where it says
Last login more than 90 days, Disabled on WHATEVERDATE, but the second part of the description, where I'd expect to see the original description of the AD user, I see this:
@{Description=PREVIOUS DESCRIPTION TEXT HERE}, so from what I can gather, the original description is getting read as an array, and is thus being output as an array.  So I tried forcing it into a string by putting [string] at the front of the
$Desc variable.  No dice.
So the resultant description that I'm currently left with is:
Last login more than 90 days, Disabled on WHATEVERDATE, @{Description=PREVIOUS DESCRIPTION TEXT HERE}
I obviously don't want the brackets and @ sign and Description= there.  I'd like it to read as:
Last login more than 90 days, Disabled on WHATEVERDATE, PREVIOUS DESCRIPTION TEXT HERE
Below is the code for a script that I've written.  Any help is much appreciated.
$cred = Get-Credential
$Date = Get-Date -UFormat %D
$InactiveUsers = Import-csv ".\test.csv"
foreach ($User in $InactiveUsers)
Disable-ADAccount -Identity $User.ObjectGUID -Credential $cred
$Desc = Get-ADUser -Identity $User.ObjectGUID -Properties Description -Credential $cred | Select-Object -Property Description
Set-ADUser -Identity $User.ObjectGUID -Credential $cred -Description "Last login more than 90 days, Disabled on $Date, $Desc"

This should work:
$cred = Get-Credential
$Date = Get-Date -UFormat %D
$InactiveUsers = Import-csv ".\test.csv"
foreach ($User in $InactiveUsers)
Disable-ADAccount -Identity $User.ObjectGUID -Credential $cred
$Desc = Get-ADUser -Identity $User.ObjectGUID -Properties Description -Credential $cred | Select-Object -ExpandProperty Description
Set-ADUser -Identity $User.ObjectGUID -Credential $cred -Description "Last login more than 90 days, Disabled on $Date, $Desc"
Instead of
Select -Property Description
use
Select -ExpandProperty Description
that will give you the actual data of the property instead of what is called a NoteProperty that gives you the brackets.
I hope this post has helped!

Similar Messages

  • HT5622 How can I correct my rescue email address for my security questions. This email address is currently showing a typo.

    How can I correct my rescue email address for my security questions (when I am logged in with my Apple ID)?. This email address is currently showing a typo.

    You won't be able to change your rescue email address until you can answer your questions, if you don't know the password for that email account and you can't get it reset then you will need to contact Support in the country where you and your iTunes account to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can then use the steps half-way down this page to update your rescue email address for potential future use : http://support.apple.com/kb/HT5312

  • How do I correct General Printer error 0X610000f6 for a HP Officejet 6500

    The printer keeps throwing this erro message out.  How can I correct it.

    Hi,
    Here is an all encompassing 0x error document that contains several of the documents for 0x depending on your error message along with it.  Look within the first 3 bullets in the document.
    0x error on front panel
    I suspect it is the 3rd bulleted section
    Say Thanks by clicking the Kudos Star in the post that helped you. Please mark the post that solves your problem as Accepted Solution.
    I am employed by HP

  • How do i increase my key ID +1 for every new user

    what iam trying to do is that for every new user that register on my app will get a key id.. that is +1 higher then the old highest id.. i have done this i JavaDB but in mysql i get an exception
    here is my sql Q:
    sql = "insert into " + mytest_TABLE + "(" + mytest_ID + ", " + mytest_NAME
    + ") values ((case when (select max(" + mytest_ID + ") from " + mytest_TABLE + ")"
    + "IS NULL then 1 else (select max(" + mytest_ID + ") from " + mytest_TABLE + ")+1 end), "
    + encodeSQL(firstName) + ")";
    here is my exception:
    by the way mytest is my table..
    java.sql.SQLException: You can't specify target table 'mytest' for update in FROM clause
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3250)
    at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1355)
    at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1270)
    at cont.tt.updateContact(tt.java:49)
    at cont.tt.jButton3ActionPerformed(tt.java:179)
    at cont.tt.access$200(tt.java:6)
    at cont.tt$3.actionPerformed(tt.java:140)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6038)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
    at java.awt.Component.processEvent(Component.java:5803)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4410)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.java:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    sry for my bad english..
    really hope someone can help me out

    You need an 'Identity' column. In MySQL, you need to enable autoincrement and don't insert a value in the column while adding records; MySQL will auto increment the value.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • How can I see the Query view created for a different user

    Hi All,
    How can a user see the View of a query created for a different user??
    I would like some info about how to give access ( if it is a access problem) or tell me the steps to do that.
    Regards, Federico

    Hi all,
    Maybe I didn't explain me as i should or maybe you dont know what is a Query View. Lets try again, showing you the steps to open a "Query view".
    This way is from Bex Analyzer (Excel)
    I open the Bex Analyzer and connect to the system -> Open query -> Under "Type" choose "Query View"...this is just a different view of the original query (more or least columns/rows).
    This way is from Bex Web:
    Once you open/execute the query, you have a ComboBox to choose the view (previously saved)
    The problem that we have is that the views created for a user, can NOT be found by other user. The only user who can is the owner.
    Could it be an authorization problem? or is ther any configuration possible to see it?
    Thanks in advance, Federico

  • How does one install Firefox on Windows 7 for just one user, so separate users can have completely independent Firefox installations?

    I'd like to create a new user, and install firefox for that user completely separate in all respects from the existing user's installation, so that there is no interaction at all between the two installations, with separate copies of the program files as well as separate Firefox profiles.

    I was asking about how to have multiple Windows user accounts, and how to install Firefox independently for different Windows user accounts.
    Firefox does not ask if you want to install it for everyone or just the current user, unlike many programs.
    I tried switching to the newly created Windows user account, which was able to use the Firefox installed by the other user account, and installing Firefox, and although there's no indication that it's installing a user specific copy of Firefox, it is. Now the original user account sees it's installation of Firefox and the second user account sees it's installation of Firefox and no longer runs the first users installation of Firefox.
    Creating separate Firefox profiles is what I was trying to say I didn't want to do. That's why I mentioned wanting completely separate copies of the program files, not one copy of the program files running two instances simultaneously.

  • How to hide the page ribbon and quichlaunch for non admin users

    HI
    1 ) how to hide the ribbon in a page in sharepoint 2010 for non administrator users  
    2) how to hide quicklaunch also for non admin users
    in quick lanuch i want to hide links for all site content also.
    i used Document Center Template to create my web application.
    adil

    HI
    i did not get how i use this control 
    <Sharepoint:SPSecurityTrimmedControl
    runat="server"
    PermissionsString="FullMask">
    2
      <div>
    3
        <SharePoint:SPLinkButton
    id="idNavLinkViewAll"
    runat="server"
    NavigateUrl="~site/_layouts/viewlsts.aspx"
    Text="<%$Resources:wss,quiklnch_allcontent%>" AccessKey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
    4
      </div>
    5
    </SharePoint:SPSecurityTrimmedControl>
    adil

  • How do I correct files apple has renamed, for example: EIEX.m4a

    How do I rename music files that apple has changed to, for example: EIEX.m4a

    I believe those files are the ones the iPod uses, not intended for use by you.
    What are you trying to achieve?

  • HT201359 How do we correct being billed three times for the same album purchase?

    Does anyone know how to fix this?

    Welcome to the Apple Community.
    Select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History on your computer.

  • How do I correct a Windows Vista error for HP Officejet 6500 E709n wireless?

    I continue to get a Windows Vista error when trying to install the printer software ...now it does print, but only the bottom half of a page..???

    Dave, I would recommend completely uninstalling the printer from Programs and Features (after unplugging the USB cord if you are using one), and removing the printer from both Device Manager and Devices and Printer.
    We are going to reinstall the printer from one of the downloads that HP makes available, but first I will have to know if your printer is the 6500A or the 6500. Also is your Win Vista machine running 64bit software or 32bit software?
    If you can give me a complete product name and the information on your system, I will link you to the appropriate download.
    Let me know!

  • How to get correct HP Photosmart B010 driver for Macbook Air?

    I used the HP Photosmart Printer/Scanner on my 13" MBP with the extended HP drivers (incl. enhanced Scanning driver/software). After migrating my User Data to the MBA 13" I am not able to get that driver/software from HP because HP references to the Mac Appstore. Any idea?
    Thx.

    I see.  Unfortunately you are right, there is no additional software for this printer in OS X 10.8.  Image Capture and Preview are the built in options.  You can try using Vuescan if you would like, but it is not free.  I'm very sorry for the inconvenience.
    I am a printer tech for HP.

  • How do i create a separate media library for a different user with the same software and i pod?

    i currently have i tunes with my preferred music. my family member has a completely different taste of music. i set up an account name for that family member however we are sharing the software. how do i create a separate library. my library automatically appears under her account?

    this support article should help:
    How to use multiple iPods, iPads, or iPhones with one computer

  • How to hide Summary Tab of Production Order for a Particular User

    Hello Experts,
    My customer doesn't want that all users are able to see the Summary Tab information in Production Order, as it contains Cost information, which is very confidential in their case.
    Does anybody has idea how to achieve it ?
    Best Regards,
    Samir Gandhi

    Hi Samir...
    This you have to do through SDK as there is no provision to hide it through any authorisation or any additional authorization.....
    Regards,
    Rahul

  • How can I set the default home page for all new users in Firefox 4

    I'm trying to deploy FF 4.0rc1 in a corporate environment but I can't find a way to set the default home page or any other settings for that matter.
    Is there a way to set the default home page for all new users and lock it so that the users can't change home page?
    Best regards
    Jonas

    In Firefox 4 the template folder for new profiles (C:\Program Files\Mozilla Firefox\defaults\profile\
    ) doesn't exist. You can create that \defaults\profile\ folder and place a file user.js in it with the prefs that you want to initialize.
    See:
    *http://www-archive.mozilla.org/catalog/end-user/customizing/briefprefs.html
    You can also use a mozilla.cfg file to set the default value for prefs.<br />
    See: http://kb.mozillazine.org/Locking_preferences
    defaultPref(); // set new default value
    pref(); // set pref, but allow changes
    lockPref(); // lock pref, disallow changes

  • How to get the list of collaboration rooms for a particular user??

    Hello Experts,
    I have a requirement to get the list of all the collaboration rooms for a given user. I have started developing the Web Dynpro application by reusing necessary jars required to the web dynpro application.
    on some action I am trying to execute the below code:
    IRooms roomsAPI = (IRooms) PortalRuntime.getRuntimeResources().getService(IRooms.PORTAL_SERVICE_ID);
    which I have got from help.sap.com
    But, there's some exception being raised and not able to retrieve the list of rooms.
    Could somebody tell me what am I doing wrong.
    Regards,
    Raghu.

    Hi,
    the below is the code that I have used to get the list of rooms. But I'm getting into the NullPointerException .
    I have added the catch block for time being, but could you please let me know the reason for NullPointerException?
    public void onActiongetRooms(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActiongetRooms(ServerEvent)
         IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
         try{
              IService service = PortalRuntime.getRuntimeResources().getService(IRooms.KM_SERVICE_ID);
              IRooms roomsAPI = (IRooms) service;
              String roomID = "00bd6231-fdca-2c10-919c-97bf74054b7d";
              IRoom room = roomsAPI.getRoom(roomID);
              String roomname = room.getName();
              msgMgr.reportSuccess(roomname);
         } catch (NullPointerException e) {
              // TODO: handle exception
              msgMgr.reportException("Null Error:"+e.getMessage(), true);
         catch (RoomInstantiationException e) {
              // TODO: handle exception
              msgMgr.reportException("Error :"+e.getMessage(), true);
        //@@end
    Any thoughts are much appreciated.
    Thanks in advance.
    Raghu

Maybe you are looking for

  • How to get the filename of the opened Illustrator document

    Hi All, I'm using Adobe Illustrator CS2, i have problem in getting the file name of the document opened. i have succesfully got the document reference(of opened document) but from that reference i'm not able to find the method which gives me the file

  • Manipulating .doc (word) files in Flex 4

    Hi, I'd like to open a .doc (word) file in Flex 4 and do many things with it. First of all, i want to know the number of pages that it has got and the amount of blank space in the last page (a percentage). Is there any API or library that helps me to

  • Calcualtion of Material cost  for custom  program

    Hello all For a particular cost estimate we need to calacualte only the material cost in that particular material and thi swe required for all the material i had checked all the costing related table but not able to do tha kindly help anil

  • HT5262 I phone 5 frozen please help

    I updated my iphone 5 with the newest update in the middle of the update the screen went black and wont do anything. If I try to turn it on it has a music button and says itunes with a plug/cord. What do I do? Thanks!

  • Got new computer and can't change any info or music to iphone

    got a new mac book.  i plug my iphone into the computer and i can't do anything with it.  it acknowledges my phone but i can't delete or add music or apps.  please help