Close
Skip to content

5 Comments

  1. rohit
    October 7, 2014 4:21 am @ 04:21

    it shows an error

    Import-Csv : You must specify either the -Path or -LiteralPath parameters, but not both.

    At C:Usersgdcadminscriptstest1.ps1:28 char:161

    + … n02_created} | Import-Csv | Sort-Object @{expression=”Deleted”;Descending=$true} …

    + ~~~~~~~~~~

    + CategoryInfo : InvalidData: (:) [Import-Csv], InvalidOperationException

    + FullyQualifiedErrorId : CannotSpecifyPathAndLiteralPath,Microsoft.PowerShell.Commands.ImportCsvCommand

    Reply

    • Travis Runyard
      January 22, 2015 8:14 pm @ 20:14

      Sorry it took 4 months to get back to you. Looks like the error you ran into is from changes in version 3 of Powershell. Were you able to fix it yet? From searching the net I see a fix is to pipe this | Select -expandProperty Name right before the Import-CSV in line 31 (or 28 in your case). If you did manage to fix it, please post the code changes and I will update my site.

      Reply

  2. Nitish Kumar
    July 8, 2016 11:27 am @ 11:27

    Easy to track deletions

    Below is for changes done in last 24 hours

    Get-ADObject -Filter {(isdeleted -eq $true) -and (name -ne “Deleted Objects”) -and (objectclass -eq “user”)} -includeDeletedObjects -property * | Where-Object {$_.whenChanged -gt (Get-Date).AddDays(-1)} | Sort-Object whenChanged| Select-Object @{Label=”Domain ID”;Expression={($_.SamAccountName)}}, @{Label=”User Name”;Expression={($_.Name)}}, @{Label=”Deleted on”;Expression={($_.whenChanged)}}

    In last 7 days

    Get-ADObject -Filter {(isdeleted -eq $true) -and (name -ne “Deleted Objects”) -and (objectclass -eq “user”)} -includeDeletedObjects -property * | Where-Object {$_.whenChanged -gt (Get-Date).AddDays(-1)} | Sort-Object whenChanged| Select-Object @{Label=”Domain ID”;Expression={($_.SamAccountName)}}, @{Label=”User Name”;Expression={($_.Name)}}, @{Label=”Deleted on”;Expression={($_.whenChanged)}}

    In last 180 days (Max possible data)

    Get-ADObject -Filter {(isdeleted -eq $true) -and (name -ne “Deleted Objects”) -and (objectclass -eq “user”)} -includeDeletedObjects -property * | Sort-Object whenChanged| Select-Object @{Label=”Domain ID”;Expression={($_.SamAccountName)}}, @{Label=”User Name”;Expression={($_.Name)}}, @{Label=”Deleted on”;Expression={($_.whenChanged)}}

    Reply

    • Travis Runyard
      February 14, 2019 10:34 pm @ 22:34

      3 years too late, but wanted to say thank you for contributing.

      Reply

  3. Nitish Kumar
    July 8, 2016 11:29 am @ 11:29

    Similar users created in last 24 hours

    Get-ADUser -Filter {whenCreated -ge ((Get-Date).AddDays(-1)).Date} -Properties *| select SamAccountName,EmailAddress,whenCreated

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *