header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Sort-Object
Last Post 12 Aug 2010 03:00 AM by Terry2win. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Terry2winUser is Offline
New Member
New Member
Posts:39
Avatar

--
10 Aug 2010 01:28 AM
    Below you will see a script I have made which finds out when computers last were logged on to the domain. This information is written to a TXT file. Now to the "problem": I want the information to be sorted from oldest logon to latest logon. What must I do acchieve this?

    $PCer = GET-QADCOMPUTER -IncludeAllProperties
    $fil = "\\server\lastLogonPCer.txt"

    ForEach ($i in $PCer)
    {
        $pcNavn = $i.computername
        $lastLogon =  $i.lastlogon
        
        Add-Content $fil "$lastLogon " + "$pcNavn"
    }
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    10 Aug 2010 02:00 AM
    Get-Content \\server\lastLogonPCer.txt | Get-QADComputer -IncludedProperties LastLogon | Select-Object Name,LastLogon | Sort-Object LastLogon | Out-File \\server\lastLogonPCerSorted.txt

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    Terry2winUser is Offline
    New Member
    New Member
    Posts:39
    Avatar

    --
    12 Aug 2010 03:00 AM
    Thank you Shay
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer