Get-Date Question

This topic contains 6 replies, has 3 voices, and was last updated by Profile photo of Alex Alex 7 months ago.

  • Author
    Posts
  • #38819
    Profile photo of Suresh krishnan
    Suresh krishnan
    Participant

    Dear Community

    I need your advise . If i run get-date i get the below format.

    Tuesday, 10 May 2016 3:16:22 PM

    Now i want the same format to be in produced in my monitoring report
    .But the format is changing .

    Below is the line from my script.

    "Report Generated $(get-date)"
    Report Generated 05/10/2016 15:16:48

  • #38822
    Profile photo of Alex
    Alex
    Participant

    Get-date in quotes changes this. try doing

    $date = get-date -format F
    
    "Report Generated $date"
    
    
  • #38823
    Profile photo of Christian Sandfeld
    Christian Sandfeld
    Participant

    Use the -Format parameter of Get-Date to specify the format you want:
    https://technet.microsoft.com/en-us/library/ee692801.aspx

    In your case use F to get the full date format:

    "Report Generated $(Get-Date -Format F)"
  • #38824
    Profile photo of Christian Sandfeld
    Christian Sandfeld
    Participant

    Ah ... Alex beat me to it 🙂

  • #38828
    Profile photo of Suresh krishnan
    Suresh krishnan
    Participant

    Works like a charm . You guys are awsome. Thank you Alex and Chris 🙂 Appreciate your help and time. .

  • #38830
    Profile photo of Christian Sandfeld
    Christian Sandfeld
    Participant

    Happy to help Suresh 🙂

  • #38832
    Profile photo of Alex
    Alex
    Participant

    No problem, any time 🙂

You must be logged in to reply to this topic.