Recursive select?

I have a table like following
CRN Service_Code
25 SM
25 SP
25 SN
26 SP
26 SM
I want result like
25 SM,SP,SN
26 SP,SM
I have a query for this like:
Select CRN,
max(case when service_code='SP' then service_code else null end) ||','||
max(case when service_code='SM' then service_code else null end) ||','||
max(case when service_code='SN' then service_code else null end)
from Table1
group by CRN;
Is there any efficient way to acheive this rather than hardcoding the service codes???

Hallo,
SELECT crn,
       MAX(substr(SYS_CONNECT_BY_PATH(service_code,','),2))
FROM   (SELECT crn, service_code,
               ROW_NUMBER() OVER (PARTITION BY crn ORDER BY service_code) curr
        FROM   scott.tbl_crn)
GROUP BY crn
CONNECT BY curr = PRIOR curr + 1 AND crn = PRIOR crn
START WITH curr = 1;CRN MAX(SUBSTR(SYS_CONNECT_BY_PATH
25      SM,SN,SP
26      SM,SP
But only from Oracle 9i!
Regards
Dmytro

Similar Messages

  • Recursive select in user_constraints

    I have 5 tables (or more) in master detail relation (five levels). Is possible to write recursive select cross user_constraints table to get all this levels from select?
    my wrong try:
    select table_name,R_CONSTRAINT_NAME,CONSTRAINT_NAME from user_constraints a
    where a.R_CONSTRAINT_NAME is not null
    connect by prior a.CONSTRAINT_NAME=a.r_CONSTRAINT_NAME start with a.R_CONSTRAINT_NAME='ZMPTDOPO_PK';

    Something like this ?
    SQL> select table_name,constraint_name, r_constraint_name
      2  from user_constraints
      3* order by table_name
    SQL> /
    TABLE_NAME                     CONSTRAINT_NAME                R_CONSTRAINT_NAME
    TABLE1                         TABLE1_PK
    TABLE2                         TABLE2_PK
    TABLE2                         TABLE2_FK                      TABLE1_PK
    TABLE3                         TABLE3_PK
    TABLE3                         TABLE3_FK                      TABLE2_PK
    TABLE4                         TABLE4_PK
    TABLE4                         TABLE4_FK                      TABLE3_PK
    TABLE5                         TABLE5_PK
    TABLE5                         TABLE5_FK                      TABLE4_PK
    9 rows selected.
    SQL> col lev for a10
    SQL> select lpad(level,level,' ') lev, parent_table, child_table
      2  from (select a.table_name child_table, b.table_name parent_table
      3  from user_constraints a, user_constraints b
      4  where a.r_constraint_name = b.constraint_name)
      5  start with parent_table = 'TABLE1'
      6* connect by prior child_table = parent_table
    SQL> /
    LEV        PARENT_TABLE                   CHILD_TABLE
    1          TABLE1                         TABLE2
    2         TABLE2                         TABLE3
      3        TABLE3                         TABLE4
       4       TABLE4                         TABLE5
    SQL>                                                                                           

  • Recursive selection sort stack overflow

    hi, first time posting here.
    i have to write a java method that implements a selection sort. This method must be recursive. ok not a problem. i have come up with this so far
        public int findMin(int index) {
            int min = index - 1;
            if (index < num.length - 1) min = findMin(index + 1);
            if (num[index] < num[min]) min = index;
            return min;
        public void selectionSort(int left) {
            if (left < num.length - 1) {
                swap(left, findMin(left));
                selectionSort(left + 1);
        public void swap(int index1, int index2) {
            int temp = num[index1];
            num[index1] = num[index2];
            num[index2] = temp;
        }which works fine until i toss in a lot of values into the array. this creates a stack overflow, and ive been told that i need to use the divide and conquer method of resolving this issue. I guess this means to split the array up and sort each half seperatly, again and agin, or so im told.
    My question is how do i go about doing this, i am at a loss. Any help at all would be great.
    thank you
    lance

    i get this when i push the array passed about 5500 in sizeI got no problem. Post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html and http://www.yoda.arachsys.com/java/newsgroups.html
    It is silly to implement selection sort with recursion, double-silly if you use double-recursion as your current code.
    /* silly but no OOME when used against 5500 element array */
    import java.util.*;
    public class RecursiveSelectionSort{
      static int[] num;
      public static int findMin(int index) {
        int min = index; // your code had a bug here
        if (index < num.length - 1){
          min = findMin(index + 1);
        if (num[index] < num[min]){
          min = index;
        return min;
      public static void selectionSort(int left) {
        if (left < num.length - 1) {
          swap(left, findMin(left));
          selectionSort(left + 1);
      public static void swap(int index1, int index2) {
        int temp = num[index1];
        num[index1] = num[index2];
        num[index2] = temp;
      public static void main(String[] args){
        Random rand = new Random();
        int n = 10;
        if (args.length > 0){
          n = Integer.parseInt(args[0]);
        num = new int[n];
        for (int i = 0; i < num.length; ++i){
          num[i] = rand.nextInt(10000);
        selectionSort(0);
        for (int in : num){
          System.out.print(in + " ");
        System.out.println();
    }

  • How to write a recursive select procedure to read hierarchial data?

    Hi!
    I have a database where two tables are of interest to me.
    TABLE1
    ITEM_ID
    TABLE2
    PARENT_ID
    CHILD_ID
    There is a constrant between the tables so parent_id and child_id must exist in TABLE1 (they are actually same objects as those defined in TABLE1 using PK ITEM_ID)
    This table design is used to create tree structures. But I ahve hit a bump in the road on how to create a procedure that give me the entire structure as a recordset.
    Basically I just want to execute the procedure and I should be able to see the hierarchy, pergaps by appending pipe characters... like
    |Node1
    ||Node11
    |||Node111
    ||Node12
    |||Node121
    |Node2
    Later in my web app I will create a word like document using this information. But first I just need to list the structure from a specific parent.
    Do you perhaps have an idea how to create such a procedure? It should have at least 1 input parameter and that is the start parent. Then it should perhaps work in a recursive manner.
    Im very sure this has been done before, but I have not found a good example using the table design as stated above.
    kind regards
    Henrik

    Please read about [url http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/queries4a.htm#2053937]Hierarchical Queries in the manual.

  • Procedure with recursive query working in 11g compiles with error in 10g

    Hi, All,
    I have a procedure that recursively selects tree-like table (with ID-ParentID relationship). Query itself works perfectly and exactly like I need in 11g and procedure containing it compiles well. But when I try to create the same procedure in 10g then I get a message that procedure compiled with error. I have no other suspicions but on the WITH part of the procedure.
    The exact query is here (destination_tariff_zones is the tree-like table which refers to itself by parent_destination_tariff_zone_id):
    + open dtzl_cur FOR
    with dtree (nm, iid, alevel, wldcard, dtzindex)
    as (select dtz.iname, dtz.iid, 0, dtz.wildcard, rcdi.iindex
    from destination_tariff_zones dtz, rating_cube_dimension_indices rcdi, rating_cube_dimensions rcd
    where dtz.parent_tariff_zone_id is null and
    dtz."rc_dimension_index_id" = rcdi.iid and
    rcdi."rc_dimension_id" = rcd.iid and
    rcd.rating_cube_id = rc_id and
    rcd.dimension_type_id = dim_type
    union all
    select dtz.iname, dtz.iid, dtree.alevel + 1,
    cast ((dtree.wldcard || dtz.wildcard) as varchar2(20)), rcdi.iindex
    from dtree, destination_tariff_zones dtz, rating_cube_dimension_indices rcdi, rating_cube_dimensions rcd
    where dtree.iid = dtz.parent_tariff_zone_id and
    dtz."rc_dimension_index_id" = rcdi.iid and
    rcdi."rc_dimension_id" = rcd.iid and
    rcd.rating_cube_id = rc_id and
    rcd.dimension_type_id = dim_type)
    select iid, nm, wldcard, dtzindex
    from dtree
    order by wldcard;+
    Is there any difference between how 11g and 10g handle WITH statements?
    Please advise.
    Thank you very much in advance,
    Max

    Max Afanasiev wrote:
    then is there any alternative to implement what I need?You can look at using CONNECT BY to emulate a recursive query. If you can post the following we may be able to help:
    1. Sample data in the form of CREATE / INSERT statements.
    2. Expected output
    3. Explanation of expected output (A.K.A. "business logic")
    4. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Get-ADGroupMember -recursive Show Groupnames

    I'm new to Powershell and im trying to get a list of the Members of some AD-Groups. Each Group is related to two other Groups for Read and Change permissions. Like FS101_EXAMPLE has two members wich are FS101_EXAMPLE_C and FS101_EXAMPLE_R
    So far I've got the following Code:
    import-module ActiveDirectory
    $GRP = "Groupname"
    Get-ADGroupMember $GRP -recursive | select objectclass,name | export-csv C:\Scripts\Exports\$(get-date -f yyyy-MM-dd-hh-mm-ss)-$GRP.txt –NoTypeInformation -Encoding UTF8
    If i scan on "FS101_EXAMPLE" it works and i get a list of all Members of FS101_EXAMPLE_C and FS101_EXAMPLE_R but i should know how's in wich group.
    How can I get a List with the Groupnames on it?

    If I understand you correctly, it sounds like you're getting the list of members from FS101_EXAMPLE, and recursively returning the members of groups within this first group. Your output lists the users but doesn't distinguish from which group they belong.
    I'm looking at Get-ADGroupMember and I see this behavior as well. I have ADPrincipal objects but there's not way on the surface to see their group membership.
    There are likely a number of ways to reach your goal, here is one way using a recursive function.
    function Get-ADGroupMembers {
    param(
    [string]$GroupName
    $objects = @()
    $members = Get-ADGroupMember -Identity $GroupName
    foreach ($member in $members) {
    if ($member.objectClass -eq "group") {
    $objects += Get-AdGroupMembers -GroupName $member.Name
    $objects += @{
    "objectclass" = $member.objectClass;
    "name" = $member.Name;
    "group" = $GroupName
    } # foreach
    return $objects
    } # Get-AdGroupMembers
    Import-Module ActiveDirectory
    $GRP = "Groupname"
    $AllMembers = Get-ADGroupMembers -GroupName $GRP
    $AllMembers | Foreach-Object {New-Object psobject -Property $_ } | Export-Csv C:\Scripts\Exports\$(get-date -f yyyy-MM-dd-hh-mm-ss)-$GRP.txt –NoTypeInformation -Encoding UTF8
    What I'm doing here is I've created a recursive function Get-ADGroupMembers (maybe not the best name) that calls Get-ADGroupMember against the given group. It then gets the members, collects the properties we want and adds them to an array which the function
    returns. If there is a group in the group, it will call the function again with this subgroup. 
    I'm storing the properties you want, objectClass, and Name, as well as the name of the group in a hashtable. The function returns the array of hashtables which I then convert to an object and export to CSV (HT powershell
    convert array of hastables into csv).
    Jason Warren
    @jaspnwarren
    jasonwarren.ca
    habaneroconsulting.com/Insights

  • How do I search a spreadsheet for a list of URL's | then search those URL's for keywords | save the output? (Oh yeah..., and schedule it)

    Fist, I should mention I am not a programmer but am eagerly learning powershell!
    I am looking for an automated solution to accomplish what I am currently doing manually.  I need a script that would combine the following:
    Reach out to a list of websites (probably a loop of some sort since the list will come out of a spreadsheet which could contain 1 or 100 different sites)
    Search each page for a specific word or words (not contained in the spreadsheet though that may make it more scalable)
    Save the URL of the site(s) that contained the keywords to one text file (versus the multiple .html files I am creating today)
    Have the output contain which words it found on which site.
    If not overly complicated, I would like to schedule this to recur once a week.
    A working script would be ideal, but even the resources that show me how to incorporate each element would suffice.
    I have had success pulling down the full content of the listed pages and saving them to a directory, which requires manual intervention.
    So far this works, but it's not scalable:
         Set-ExecutionPolicy RemoteSigned
         $web = New-Object Net.WebClient
         $web.DownloadString("http://sosomesite/54321.com") | Out-File "C:\savestuffhere\54321.html"
         $web.DownloadString("http://sosomesite/54321.com") | Out-File "C:\savestuffhere\65432.html"
         Get-ChildItem -Path "C:\savestuffhere\" -Include *.html -Recurse | Select-String -Pattern "Keyword 1"
    In otherwords, I have to manually replace the "http://sosomesite/54321.com" and "C:\savestuffhere\54321.html" when the URL changes to .\65432.com and the output name to match.  That works fine when it's a couple sites, but again,
    is not scalable.  
    Then, to see if any of the saved file's contain the keyword(s), I have to search the directory for the keyword which I am using:
    Get-ChildItem -Path "C:\savestuffhere\54321.html" -Include *.html -Recurse | Select-String -Pattern "Keyword 1"

    Hi Sure-man,
    Sorry for the delay reply.
    To automatically Reach out to all urls, you can list all urls in a txt file "d:\urls.txt" like this:
    http://sosomesite/54321.com
    http://sosomesite/65432.com
    Then please try the script below to save the URL of the site(s) that contained the keywords to one text file "d:\outputurls.txt":
    $urls = get-content d:\urls.txt
    foreach($url in $urls){
    $results = $web.DownloadString("$url")
    $matches = $results | Select-String -Pattern "keyword1","keyword2"
    #Extract the text of the messages, which are contained in segments that look like keyword1 or keyword2.
    if ($matches.Matches){
    $Object = New-Object PSObject
    $Object | add-member Noteproperty keyword $matches.Matches.value
    $Object | add-member Noteproperty URL $url
    $output+=$Object}
    $output|Out-File d:\outputurls.txt
    If you want to schduled this script in Task Scheduler once a week, please save the script above as .ps1 file, and follow this article:
    Weekend Scripter: Use the Windows Task Scheduler to Run a Windows PowerShell Script
    If I have any misunderstanding, please let me know.
    I hope this helps.

  • How to list the Cert Issuer for all servers in a Domain

    Hello,
    The objective is to list the Server name and Cert Issuer for any Cert found in the LocalMachine\My store on all servers in a Domain.
    Once I'd get to a server, probably by PS remoting, I'd issue the following:
    dir cert:\localmachine\my -recurse | ? Issuer -like '*'
    However, the output is Thumbprint and Subject, but I really need to see the Issuer, or what is displayed in the Certificates MMC under the 'Issued By' column.  What I need in my output is the following:
    ComputerName       Issuer
    Srv1                       Acme Cert Auth
    Srv2                       Host1.Acme.Com
    Any suggestions would be appreciated.
    Thanks for your help! SdeDot

    As you might suspect it is even easier than that:
    $omputers |
    ForEach-Object{
    invoke-command -ComputerName $_ -ScriptBlock {dir cert:\localmachine\my -recurse}
    } |
    select PSComputerName, Issuer
    ¯\_(ツ)_/¯
    Indeed.
    =]
    Both work great!
    Thanks for the response and help Mike and Jrv!
    Thanks for your help! SdeDot
    Cheers, you're very welcome.
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • Enumerate the users that have access to a particular directory

    Hi, my name is Jennifer and I have been searching for an answer to my problem through several blogs. The problem is that I have a Directory of which I want to not only retrieve the users\groups that have access to it but also enumerate through the groups
    to list actual users. The groups part is the main issue here. If I use get-acl, I can return any number of particular Active Directory groups that have access, however, I need to list the users inside this group and get-acl will not output an object I can
    work with. I thought I could do something like this (which I may have seen on this forum before):
    get-acl "C:\NestedGroupTest" | %{$_.access} \ ft -property identityreference
    This will return the groups\users that have access. Example:
    Domain\OU
    NT Authority\system
    Builtin\users
    ETC...
    I have tried exporting this output to a file and then trying to use get-adgroupmember (which obviously will not work on the non-AD groups) but the objects are of the wrong type so basically nothing in the Active Directory module will work...
    This seems like such a simple issue but it is causing me grief to no end...please help

    I can't guarantee that this will work in all cases, but it seems to work on my test domain. Warning: it's very slow and inefficient. It requires
    this module (get the 3.0 test version), but you can modify the foreach block's code somewhat to get it to work with Get-Acl. 
    Get-Item C:\NestedGroupTest | Get-AccessControlEntry | ForEach-Object { $PropertyNames = $null }{
    if (-not $PropertyNames) {
    # We need to copy the property. This will get a list
    # of the properties on each ACE when it encounters
    # the first ACE (since the rest of this is so ineffecient,
    # we can feel good that we saved some work by doing this)
    $PropertyNames = $_ | Get-Member -MemberType Properties | select -exp Name
    # Create a new hashtable that will be used to create a PSObject
    $NewObjectProps = @{}
    foreach ($CurrentProperty in $PropertyNames) {
    $NewObjectProps.$CurrentProperty = $_.$CurrentProperty
    # Check to see if this SID belongs to an AD group
    Write-Verbose ("Current principal: {0}" -f $_.Principal)
    try {
    $Group = Get-ADGroup -Filter { SID -eq $_.SecurityIdentifier } -ErrorAction Stop
    catch {
    # Write a warning or something?
    if ($Group) {
    Write-Verbose " -> Group, so looking up members"
    $Users = $Group | Get-ADGroupMember -Recursive | select @{N="Principal"; E={$_.SID.Translate([System.Security.Principal.NTAccount])}}, @{N="SecurityIdentifier"; E={$_.SID}}
    else {
    Write-Verbose " -> Not an AD group"
    $Users = $_ | select Principal, SecurityIdentifier
    # Go through each user/non-translated group, modify two
    # hashtable properties, and create the new PSObject
    $Users | ForEach-Object {
    $NewObjectProps.SecurityIdentifier = $_.SecurityIdentifier
    $NewObjectProps.Principal = $_.Principal
    $NewObject = New-Object PSObject -Property $NewObjectProps
    # This will make the new object show the module's custom formatting:
    $NewObject.pstypenames.Insert(0, "PowerShellAccessControl.Types.AdaptedAce")
    $NewObject
    That should resemble the output that Get-AccessControlEntry would give you, but AD groups have been translated to users. If you pipe that to Export-CSV, you'd have plenty of information for each ACE, including the path, principal, security identifier, access
    mask, etc. You could also pipe that to Select-Object and just ask for certain properties (try it with these properties: Path, Principal, AccessMask, AccessMaskDisplay, AppliesTo).
    You can also use the Get-AccessControlEntry function's parameters to do some filtering on the ACEs that are returned (maybe you only want ACEs with FullControl, or ACEs that were not inherited...)
    Give it a shot and let me know if it works for you. If you need more explanation of what's going on in the foreach-object process block, let me know and I'll try to help. It can be modified to work with version 2.1 of my module, and with Get-Acl.

  • Find & Move files based on csv headers

    Hi Everyone,
    Basically, I am trying to find locations for those files listed in a csv file. Content of the csv file is shown below:
    Name,
    filename1.xlsx,
    filename2.xlsx,
    filename3.xlsx,
    And this is my code but I couldn't get it to work!!
    $csv=import-csv c:\input.csv
    Get-ChildItem -Recurse | Select-Object name, PSPath | where {$_.name -match $cvs.name} | Export-csv c:\output.csv
    This code will find files if I replace $cvs.name with a string, I am not very at scripting and hoping anyone who is experienced in PowerShell could provide some advices! Any opinion is appreciated!! Thank you!!

    Try this:
    $csv = (Import-Csv "c:\input.csv").name
    Get-ChildItem -Path ".\*" -Recurse -Force -File -Include $csv |
    Select-Object Name, FullName |
    Export-csv "c:\output.csv" -NoTypeInformation
    Changed items from posted code:
    Quoted file path in Import-Csv and Export-Csv statements - best practice
    Selected .name property at the $csv assignment line
    Use additional paramters in the Get-ChilItem cmdlet to filter on the file names in the $csv variable
    Picked FullName instead of PSPath in the Select statement
    Variable name was misspelled in the Where statement, but the entire statement has been removed
    Removed Type Information from Export-Csv statement
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
    Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

  • Column values to row

    plz help me to print column values into row values.
    for eg.
    1
    2
    output will be 1,2

    Check this out.. might be useful
    recursive select?

  • Members of a group

    Im looking for a small script that when ran, will prompt for a group, any group in AD.  After the group is manually supplied the script will extract all group members to csv.
    Thanks in advance

    Get-ADGroupMember -Identity (Read-Host 'Group name') -Recursive |
    Select Name,SamAccountName |
    Export-Csv .\groupMembers.csv -NoTypeInformation
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Get-ADGroupMember runing issue

    Hi guys
    I am just trying some basic AD scripts, but got some problem with Get-ADGroupMember
    I am trying to get a list of users in a group, including every subgroup in that group. Then I want to display samaccountname, Full Name and group they are in.
    Tried to run some basic command 
    import-module activedirectory
    Get-ADGroupMember "Domain Admins" -recursive | Select-Object Name,samaccountname
    When executed, I get this:
    Get-AdGroupMember : A parameter cannot be found that matches parameter name 'recursive'.
    At E:\scripts\testAD.ps1:2 char:35
    + Get-ADGroupMember "Domain Admins" -recursive | Select-Object Name,samaccountname
    +                                  
    ~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-AdGroupMember], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Get-AdGroupMember
    How do I get it to work? Using PS 3

    Hi,
    I'm not getting the error you do, but you can try the Quest AD powershell module.
    http://www.quest.com/powershell/activeroles-server.aspx
    if((get-pssnapin "Quest.ActiveRoles.ADManagement" -erroraction SilentlyContinue) -eq $null)
      {add-pssnapin "Quest.ActiveRoles.ADManagement"}
    Get-qadgroupmember "domain admins" -indirect | select-object name,samaccountname
    Hope this helps.
    Regards,
    Calin

  • Filter Get-ChildItem on TargetPath?

    With Get-ChildItem is it possible to filter on a shortcut's TargetPath? I did a Get-Member on a shortcut and I don't see anything there that looks promising, so I am filtering to just get shortcuts, then looping and evaluating 
    if (($Shell.CreateShortcut($Shortcut.FullName)).TargetPath -eq $Document)
    where $Document is the TargetPath I am looking for. And it works. But I wonder if there is a pipeline way to do it, rather than the loop?

    Hi Gordon,
    I'm afraid not, because the "$Shell.CreateShortcut" doesn't accept array, and we also can't find the targetpath information with the cmdlet "Get-Childitem", so the foreach seems a good way:
    Get-ChildItem d:\*lnk -Recurse|Select-Object -ExpandProperty fullname|foreach{
    $Shortcut = New-Object -COM WScript.Shell
    $Shortcut.CreateShortcut($_).TargetPath}
    Best Regards,
    Anna Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Get AD Group Member Information

    Hi BT
    I started editing a PS script in PowerGUI and I wouldn't mind a second opinion before  investing too much time on this.... I have a load of sp content rollup that needs to be done today but would like to come back to this ;-(
    Get the AD groups in the OU
    for each AD Group
    Find each Member
    For each Member well get their details as before e.g. LastLoginDate
    pipe to CSV and hand to very grateful boss!
    I think I am going to struggle in the nesting below.. and I don't have powergui on the AD machine.
    $OU = 'OU=StormTroopersl,DC=DeathStar,DC=global'
    Get-ADGroup -ldapfilter "(cn=*)" -SearchBase $OU -searchscope subtree -properties members | foreach {
    $GroupName = $_.name
    Get-ADGroupMember $_.DistinguishedName -recursive |
    Select SamAccountName,@{n="GroupName";e={$GroupName}},@{n='TimeStamp';e={$TimeStamp}}}| foreach {
    $SamAccountName = $_.samaccountname
    Get-ADUser -Filter $SamAccountName -Properties emailaddress,description, company, LastLogonDate -SearchBase $OU | `
    Select-Object name, emailaddress, description, company, LastLogonDate | Export-Csv -Path StormTroopersInGroupLastLogon.csv -NoTypeInformation
    Regards
    Daniel

    Forgive the following, as you may consider it off-topic and a bit of a rant. There is no LastLogonDate attribute in AD. Just as there is no FirstName, LastName, or EmailAddress attribute (and lots of other things exposed by PowerShell). I have
    been searching for documentation on these "properties" and have found little yet. I believe these are what I would call property methods. They are methods that calculate values based on actual AD attributes. For example, the AccountExpirationDate property
    method converts the accountExpires attribute (a large integer) into the equivalent date in the local time zone. In that case, a lot of code must be involved and it is very useful. Some cases are easy to understand. The FirstName "property" exposed by the DirectoryEntry
    class is clearly the value of the givenName attribute. The LastName property method displays the value of the sn attribute. But I cannot find documentation on what LastLogonDate is. By testing I conclude that it is the value of the lastLogonTimeStamp
    attribute converted into a date. In the interests of being "user friendly", Microsoft has obscured things so nobody knows whats going on. New admins will think users are identified by "Name", and they have FirstName and LastName attributes. If I
    am correct that the LastLogonDate property method is the date equivalent of the lastLogonTimeStamp attribute (a large integer), then it will be accurate to within 14 days (in most cases). Assuming Windows 2003 functional level or above, the value of the lastLogonTimeStamp
    is updated during logon only if the old value is more than 14 days in the past, then the new value is replicated to all other DC's. If instead LastLogonDate is based on the lastLogon attribute, then it is undoubtedly the value on only one DC. The
    lastLogon attribute is always updated during logon, but only on the DC that authenticates the user, and the value is not replicated.
    If someone has seen documentation on LastLogonDate as exposed by Get-ADUser, could you supply a link?
    Richard Mueller - MVP Directory Services
    ConvertDNWithBinaryToString CodeMethod
    ConvertLargeIntegerToInt64  CodeMethod
    accountExpires              Property
    badPasswordTime             Property
    badPwdCount                 Property
    cn                          Property
    codePage                    Property
    countryCode                 Property
    description                 Property
    distinguishedName           Property
    dNSHostName                 Property
    dSCorePropagationData       Property
    instanceType                Property
    isCriticalSystemObject      Property
    lastLogoff                  Property
    lastLogon                   Property
    The code is in error. There is no LastLogonDate.
     This works:
    Get-ADUser -Filter * -Properties mail,description, company, LastLogon
    The whole question is hokey.  It appears to be a fishing trip to get a solution.
    Grant has the answer as best it can be offered for the lameness of the question.
    jv

Maybe you are looking for

  • List of materials with total PR, PO qty, and stock

    Dear All, Is there any std report to check the list of materials along with total PR qty, PO qty and Current stock. This is to check, what is the total requirement of the materials and whether Purchase team has raised the PO or not ? Please advise. R

  • Dunning letter option

    when i try to acces to dunning letter through Customer Receivables Ageing Form don't appear the columns Letter and Level. how can i put those columns on to have the possibility to print dunnings letters? regards,

  • How do I correct a build error while saving "Calculate Color Index Array.vi"?

    I have an application that takes some data and then periodically generates a nifty 3d graph.  When trying to compile this application to run on a stand-alone machine, i get an error message that crashes the build.  This is the information that is gen

  • Reciever func.module, check func.module and receiver type func

    Hi Experts, what is the purpose of reciever func.module, check func.module and receiver type func.module in Event Linkage. Give some Examples which helps. Thanks In Advance.

  • Guitar Rig 3 problems :(

    I am using an iMac with 2Gb RAM and 1.83 dual Intel processors that hasn't had any problems before, and now when using GR3 (Rig Kontrol edition) on a number of tracks in Logic Pro 8, for no apparent reason, I am getting loads of pops, clicks, etc. wh