Can anyone help with a powershell script using the search-adaccount cmdlet to filter out accounts that have been created in the last 90 days?

Hi,
I have the following script that is supposed to search AD for all user accounts that haven't logged into the domain in more than 90 days.  I first did not have the where-object clause because I didn't realize the search-adaccount would provide results
back of users that have never logged in, but were created less than 90 days ago.  So I tried to incorporate the logic to not include user accounts that were created in the last 90 days.
#requires -version 4
#This script creates a file of accounts that have not been logged into in the past 90 days, excluding accounts that have been created within the past 90 days since the -AccountInactive option does not factor for the whenCreated property of an AD object
$DateThreshold = ((Get-Date).AddDays(-90))
$ReportDate = Get-Date -Format yyyy-MM-dd
#Create a folder according to the current date to be used for storing the report
New-Item -Path ".\$ReportDate" -ItemType Directory
$InactiveUsers = Search-ADAccount -UsersOnly -AccountInactive -TimeSpan "90" -SearchBase "OU=XXXX,DC=XXXX,DC=XXXX,DC=XXXX" | Where-Object {$_.whenCreated -gt $DateThreshold} | Export-Csv ".\$ReportDate\Inactive90_$ReportDate.csv"
However, I can't ever get the whenCreated field to populate with data.  What gives?

Hi,
Search-ADAccount doesn't return a whenCreated property. If you want that, you'll need to use Get-ADUser as well. Here's a basic example you can build from:
$dateThreshold = (Get-Date).AddDays(-90)
Search-ADAccount -UsersOnly -SearchBase 'OU=Users,DC=domain,DC=com' -AccountDisabled | ForEach {
$whenCreated = (Get-ADUser -Identity $_.SamAccountName -Properties whenCreated).whenCreated
If ($whenCreated -gt $dateThreshold) {
$_
Don't retire TechNet! -
(Don't give up yet - 12,950+ strong and growing)

Similar Messages

  • Can anyone help with facetime? im getting missed calls but it doesnt actually tell me i have an incoming call....and the person im trying to contact gets exactly the same.....just missed calls?

    can anyone help with facetime? im getting missed calls but it doesnt actually come up with an incoming call.....the person im trying to contact just gets missed calls also?

    I've noticed that once you miss a call on FaceTime on a desktop Mac, it won't work properly again until you restart the machine.
    I sent in Feedback so we'll see how that goes.

  • When a single-page form expands to more than one page, can you reference the new individual "pages" that have been created by the expanding table?

    Don't think this is possible but would love to be wrong.
    Bullet Points:
    1) In my demo form (simple hierarchy: form1.page1.table1.row1), 8 occurrences  (instance "0" through instance "7") of the repeating row1 can be visible
         before it causes a page break and adds another "page".  No issues there.
    2) I'm thinking about trying to control the end-users navigation abilities to only on-screen "previous page" and "next page" buttons.
         (So no scrolling from page to page; keep them where we want them.) Only way I can see making this work is if the form is designed
         and coded to only allow one page to be visible at a time --- nesting things correctly in a parent object then hide all necessary subforms
         and only make the appropriate subform visible.
    3) But when working with tables,  when occurrence 9 gets added (aka instance 8), it triggers an on screen "Page 2" to be added.
         End user can now scroll between Page 1 and Page 2. 
    4) Once Page 2 has been added, is there a way to reference Page 1 (as we see it on screen) and set it to be hidden?
    5) Is what we are seeing on screen as "Page 1" and "Page 2"  actually this.resolveNode("page1[0]") and this.resolveNode("page1[1]") ?
         Tried messing around with referencing it this way but didn't seem to work.  Maybe I had a typo but if we never set the subform named "page1"
         to allow multiple instances, I'm guessing it's not referenced this way.
    Any thoughts would be great.  Thanks so much to this community.
    Brian

    If you're looking at learning a bit more about database design (looking at your description of what you've done in creating a separate table for each category of item sold sounds like you're approaching it as though it was a flat-file rather than a relational database), there's a few books that I could direct you to:
    Beginning Database Design (ISBN 978-1590597699)
    Database Design for Mere Mortals (ISBN 978-0201694710)
    Databases Demystified (ISBN 978-0072253641)
    Absolute Beginner's Guide to Databases (ISBN 978-0789725691)
    I've also got an older book that's always sitting by my desk called Dreamweaver MX Databases (ISBN 978-0782141481), which I still reference regularly - chapter 3 on coding practices and chapter 5 on database design provide very good overviews of the subject.
    There's also a Database Development for Dummies, but I'm not a huge fan of the series where they're tackling technical subjects.
    Without knowing the data you're modeling, it's quite difficult to make generalisations, but I'd probably be looking at a single table called 'Product' (which contains all the product records), and which had in it a boolean for 'new item' and for 'on sale' (you could then use SQL to filter out new and/or sale items when you create your recordset). I'd then have a look up table called 'Categories' which held the values 'necklace', 'handbag', 'belt', and 'purse' which the Product table could then reference to identify.
    Breaking your data down into a logical structure like this is called 'normalisation' (see http://en.wikipedia.org/wiki/Database_normalization) - although it's a bit technical. There's a simpler practical explanation of a similar query to yours at TechRepublic (http://articles.techrepublic.com.com/5100-10878_11-5288500.html), which uses MS Access, but don't worry about that as it's teaching a concept which is applicable no matter what the database server.

  • Can anyone help with problem updating iphone5s cant get anything only apple on screen sometimes screen flashes blue

    can anyone help with problem updating iphone5s cant get anything only apple on screen sometimes screen flashes blue

    Hey damien555,
    Thanks for the question, I understand how frustrating this may be. It sounds like the update process may have been interrupted, and to resolve the issue, we’ll need to restore your device in recovery mode with iTunes:
    If you can't update or restore your iOS device
    http://support.apple.com/kb/HT1808
    Thanks,
    Matt M.

  • Please can anyone help me to download some apps for my iphone .. i am simply not able to log in to the itunes store , when i enter my apple id it says that it has not yet been used with the itunes store

    please can anyone help me to download some apps for my iphone .. i am simply not able to log in to the itunes store , when i enter my apple id it says that it has not yet been used with the itunes store

    Ok, you should generally only get this when you are converting your ID to an iTS account for the first time.
    Sign into iTunes with your Apple ID and you should get this.... IRC once you agree or accept it's now an iTS account and you wont get that again.

  • Since updating to FF 8 I can no longer use Multirow book marks, can anyone help with this issue?

    Since updating to FF 8 I can no longer use Multi-row book marks, can anyone help with this issue? the one I used is here http://multirowbookmarkstoolbar.com/

    Try the support site:
    *http://multirowbookmarkstoolbar.com/forum
    *Multirow Bookmarks Toolbar Plus: https://addons.mozilla.org/firefox/addon/multirow-bookmarks-toolbarplus/

  • I downloaded the icloud software on my computer in order to sync calendars and contacts using Windows 2007, but I keep getting an error message when trying to sync my icloud and Outlook calenders - can anyone help with this?

    I downloaded the icloud software on my computer in order to sync calenders and contacts using Windows 2007, but I keep getting an error message when trying to sync my icloud and Outlook calendars.  I downloaded it for the first time a month ago and  had it working but it stopped syncing, so I deinstalled the iCloud software and reinstalled, but keep getting the error message "Your setup couldn't be started because of an unexpected error.  What do I do now?  Can anyone help with this?

    Hello easbda,
    Thank you for providing the details of the calendar issue you are experiencing with your iPhone.  I recommend following the steps in the section titled "Troubleshooting on Microsoft Windows (Microsoft Outlook)" in the following article to assist with syncing your calendar events between your devices:
    iCloud: Troubleshooting iCloud Calendar
    http://support.apple.com/kb/ts3999
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Can anyone help with iPlayer and Sky Mobile?

    Ok, I'm so close to giving up with this useless phone. There are 3 apps on my N97 which give me a constant headache.
    BBC iPlayer
    Sky Mobile*
    YouTube
    *I should point out that I only use Sky Mobile to set recordings on my Sky+. I do not use it for, nor have any desire to use it for actually watching Mobile TV.
    All of these apps work absolutely fine over my home WiFi network. It's when I try to use them over 3G (my Vodafone Live! connection) that I start running in to trouble.
    All 3 give me connection problems, errors, and simply refuse to load half the time when on 3G. I got so annoyed I just did a hard reset the other week, and magically all three started working again. However, now 2 of them are failing me again. YouTube (touch wood) is working fine at the moment, but iPlayer and Sky Mobile just aren't.
    iPlayer sometimes works. But sometimes I get script errors (unable to load content), and sometimes it says something about checking my connection settings. I wouldn't mind but it's not actually possible to access any options for the iPlayer. Even in application settings there are no options you're able to set.
    Sky Mobile simply flat out refuses to work ever on 3G. But it did after I did a hard reset for a couple of weeks, now it just stopped working! It wont even load. It just gives the error message 'Unable to connect to network - please check connection settings" or something along those lines.
    I've tried so many different things. Tried setting my internet connections to 'always ask', tried setting it to default to Vodafone Live! all the time, tried setting my video streaming settings to WAP, all sorts. Every combination I can think of.
    I just can't wait to get rid of this phone. I've put so many people off buying one. They see it and think it's all swish and cool, and I just say 'Don't. You'll regret it'. I can't wait for my contract to be up so I can upgrade to an iPhone now Vodafone have got them.
    Can anyone help with these problems? Thanks in advance, but I don't hold out much hope...

    About iPlayer.
    Have a chat with Vodaphone. Streaming iPlayer over 3G IS allowed on Vodaphone contract, unlike my O2 contract. As long as your contract allows it, and you have the correct AP address, it should be fine. Vodaphone should be able to give you the setting.
    Mine only works over Wlan.
    FWIW, "... streaming over 3G is not currently available on iPhone handsets on any mobile network".
    p.s. Just to be clear. You say  "Tried setting my internet connections to 'always ask', tried setting it to default to Vodafone Live!".
    iPlayer uses the Nokia browser "Web". So that's where you should make the setting "Ask when needed". It should then offer you the choice of whatever you've set in Destinations> Internet> then select whatever you've chosen as your GPRS connection.(as advised, or sent to you by Vodaphone).

  • Can anyone help me write a script that would click "get info" and then "enter" on each movie in my itunes library? I am asking because my itunes 11 repeatedly loses the artwork to my movies in my itunes library.

    Can anyone help me write a script that would click "get info" and then "enter" on each movie in my itunes library? I am asking because my itunes 11 repeatedly loses the artwork to my movies in my itunes library. I can restore the artwork (and make my apple tv see the movie exists as well) by going into the movie library and clicking on each movie by hand, slecting get info, and then selecting enter. Now doing this 10 times in 20 days was fun and all BUT I would really like to automate the process so everytime itunes screws it up I can fix it easier.
    I saw this example of an itunes script that restores artwork for music
    tell application "iTunes" set theSelection to selection repeat with i from 1 to count of theSelection tell (item i of theSelection) set artworkCount to count of artwork repeat artworkCount times set theArtwork to data of artwork 1 delete artwork 1 set data of artwork artworkCount to theArtwork end repeat end tell end repeat end tell
    but I need to tweak this to fit my needs for simply clicking the "get info" button and "enter" in the movie library rather than all the stuff this guy has listed. Any ideas or help on writing this? Thanks.

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • My calendar will no longer let me add new event or delete them, it comes up with an error saying "cannot save event, no end date set" or "event does not belong to that event store". can anyone help with this?

    my calendar will no longer let me add new event or delete them, it comes up with an error saying "cannot save event, no end date set" or "event does not belong to that event store". can anyone help with this?

    Hi,
    To configure your ODBC DataSource, go to Control Panel ---> DataSources(ODBC) (If you are in a Windows environment).
    Select the tab System DSN. If you have not added your data source, then do so by clicking on the Add button. If you have added the datasource, click on the Configure button to configure it.
    Give the datasource name, then the database name.
    You have to give the hostname, service name and server name. I guess, in most cases, the datasource name and host name will be the same, service name and server name will be the same. If you are using TCP/IP, the protocol will be onsoctcp.
    There will be a file named Services under C:\WINNT\system32\drivers\etc where you have to give the port number for accessing this server.
    It will be like this <service name> <portnumber>/tcp
    Hope this helps...
    best wishes,
    Nish

  • HT1365 Hi can anyone help with this issue regarding my wireless magic mouse? When im on google chrome and scrolling down the page i always have youtube running in the background but the audio cuts/spits/pops can anyone help me with this?

    Hi can anyone help with this issue regarding my wireless magic mouse? When im on google chrome and scrolling down the page i always have youtube running in the background but the audio cuts/spits/pops can anyone help me with this?

    The figures you mention only make sense on your intranet.  Are you still using the same wireless router.  The verizon one is somewhat limited as far as max wireless-n performace.  For one thing it only has a 2.4 radio.   I like many people who wanted wireless-n performance before they even added a wireless-n gigabit router, have my own handling my wireless-n network.

  • Hi there. Can anyone help with restoring my Mac to it's origin white, it has got very grubby. Thanking you.

    Hi there. Can anyone help with restoring my Mac to it's origin white, it has got very grubby. Thanking you.

    From here:
    http://forums.macrumors.com/archive/index.php/t-863188.html
    "You can use the Magic Eraser to clean the white plastic."
    "thanks for the Magic Eraser tip, I willtry that..so far I've been using disinfectant wipes, which work pretty well, too because of the alcohol in them"

  • Can anyone help with Ibook previously downloaded on ipad now somehow sitting in icloud and unable to open in IBOOK. it is greyed out.

    Can anyone help with Ibook previously downloaded on ipad now somehow sitting in icloud and unable to open on ipad . it is greyed out.

    I Have this problem as well on my iPad using ios8. I found it only happened after I downloaded the some free books from the bookstore. I have tried to reset all settings but nothing seems to have worked. any ideas??

  • Can anyone help with email in my old G4 17"  ??

    My G4 17", bought December 2004, is considered an antique by Apple, and no longer supported. (I now mostly use my early 2011 MacBookPro.)
    But the big screen on by G4 is very useful for Sibelius 4, the music program I mostly use (Sibelius 7 in the MacBookPro - but much too fussy for me.)
    Sibelius 4 in the G4 continues to work flawlessly.
    But my email account recently sort of died. It's  POP account (whatever that means). I can no longer receive messages, BUT I can still create and
    send new messages, and of course forward any saved message to myself in the MacBookPro.
    ALSO:  if I have to shut down the G4, it usually reopens with a horizontally divided display, and it usually takes many restarts before it will open
    will a full screen display (seems to reopen correctly more often if left in a cool place overnight.)
    Can anyone help with one or both these issues? I want to keep the G4 going as long as I can.  BTW, I don't use it for browsing anyone, Safari installed,
    because it is now so slow. The MacBookPro handles all that for me.
    Thanks very much, James Johnson in Plattsburgh NY (where it is still cold and wintry, o f--k)

    To RCCHARLES: THANKS !!!!  I did the safe boot start, following the link you provided, then waited, and waited, and waited, and ---
    Well that is interesting. Amoung other things safe boot does:
    -- check and fixes up your file system.  The files system allows you to keep files on your harddrive.
    -- Does all video rendering in software.
    You could have a one time glitch or harddrive is slowly failing.  If you never replaced the harddrive, it is time for a new one.
    You may want to consider getting a new harddrive.  The easiest way is to get an external drive.  No disassembly of the machine is required.
    You need an external Firewire drive to boot a PowerPC Mac computer [ a few G5's will boot from USB ].
    I recommend you do a google search on any external harddrive you are looking at.
    I bought a low cost external drive enclosure. When I started having trouble with it, I did a google search and found a lot of complaints about the drive enclosure. I ended up buying a new drive enclosure. On my second go around, I decided to buy a drive enclosure with a good history of working with Macs. The chip set seems to be the key ingredient. The Oxford line of chips seems to be good. I got the Oxford 911.
    I'd give OWC a call. 1-815-338-8685.
    FireWire 800 + USB 3, + eSATA
    save a little money interface:
    FireWire 400 + USB 2.0
    This web page lists both external harddrive types. You may need to scroll to the right to see both.
    http://eshop.macsales.com/shop/firewire/1394/USB/EliteAL/eSATA_FW800_FW400_USB
         (2) FireWire 800/400 Ports (Up to 100MB/s / 50MB/s)
         (1) USB 3.0 Port (Up to 500MB/s / 60MB/s)
         (1) eSATA Port (Up to 300MB/s)
    Has a combo firewire 800/400 port.  Not sure what this is.  Looks like you will  need 400 cable.
    http://eshop.macsales.com/shop/ministack

  • Can anyone help with AirPrint

    Can anyone help with this. I recently purchased an Airport Express unit to connect to my Canon MP 640 via USB. I was advised to download the airport utility app for both my iPad and iPhone, which I did. I also downloaded it on my pc. I have connected the Airport Express to my Orange router via wired LAN and my printer is connected to Airport Express via USB. A new wireless network has now been setup via the Airport so I can connect my iPad, iPhone and Apple TV. The printer is showing in the airport utility on my pc but I cannot print anything from my iPad and phone. The both connect to the Airport Express but cannot find the printer. They both come back with " no AirPrint printer found". Can anyone help with this.

    Thanks for that guys. I can stop tearing my hair out now. I have the Printcentral app on both devices and there are several options I can use from this, but not direct print to my printer. The Pages and Numbers apps need to update with a 'send to' option I think. Canon have an app for printing photos which works well on both iPhone and iPad, may be they need to update to include docs too. I don't realy want to spend any more money on a new printer as my Canon MP640 does a good job on my photos. Oh well, back to iCloud. Thanks again for your help.

Maybe you are looking for