Replace test in array

Welcome Forums General PowerShell Q&A Replace test in array

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
8 months, 1 week ago.

  • Author
    Posts
  • #96003

    Participant
    Points: 20
    Rank: Member

    so i have an array of users around 17,000.

    there are lots of columns but for this i will stick with 2

    $users
    
    Name               Lastlogontimestamp
    User1              131648355872511827
    User2              131652816687365046
    User3              131653273083137594
    
    

    i want to replace the $users.laslogontimestamp with the $userts entry
    what i have so far is producing the date but im struggling to get it back into the original $users

    
    
    
    foreach ($user in $users)
    {
        $userts = [DateTime]::FromFileTime($user.lastlogontimestamp)
        $userts -replace $user.lastLogonTimestamp
    }
    
    
    
    
    		
    	
  • #96005

    Participant
    Points: 155
    Helping Hand
    Rank: Participant

    Wouldn't be something like this enough?

    $user.lastlogontimestamp = [DateTime]::FromFileTime($user.lastlogontimestamp)
  • #96009

    Participant
    Points: 20
    Rank: Member

    Many thanks Olaf, again think i was trying to overthink it 🙂

The topic ‘Replace test in array’ is closed to new replies.