How to change the format of a column in format-table

Welcome Forums General PowerShell Q&A How to change the format of a column in format-table

Viewing 2 reply threads
  • Author
    Posts
    • #230011
      Participant
      Topics: 1
      Replies: 1
      Points: -7
      Rank: Member

      HI All

      I have created a script that only pulls the last-modified date/time in my folder see below:

      Get-ChildItem $env:c:\folder | Measure-Object LastWriteTime -Maximum | Format-table -HideTableHeaders maximum

      I then run the get-date -format “dd/MM/yyyy” to get the current system date.

      I then need to be able to compare the two to see if a backup has been created in the location (it will be a zip file) and then our system will log a ticket if there is not one.

      that is the story the question I have is how do I get the maximum value to change from datetime to just date?

      I have ability to create variables from the results of powershell commands in my Connectwise Automate RMM so as long as I can get the results in the same format comparing shouldn’t be a problem.

      Thanks

      Ben

    • #230032
      Participant
      Topics: 48
      Replies: 194
      Points: 767
      Helping Hand
      Rank: Major Contributor

      How about this

      
      (Get-ChildItem $env:c:\folder| Sort LastWriteTime -Desc | Select -ExpandProperty LastWriteTime -First 1).ToShortDateString()
      
      
    • #230038
      Participant
      Topics: 1
      Replies: 1
      Points: -7
      Rank: Member

      That works perfectly

      Thank you so much.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.