Work with Date & Time with PowerShell

Поділитися
Вставка
  • Опубліковано 4 січ 2025

КОМЕНТАРІ • 90

  • @keeganlee5678
    @keeganlee5678 6 років тому +11

    Great video! Just wanted to add,
    get-date $pig -UFormat %y
    This actually returns the year, it returned 17 in the case as it was 2017 at the time. %V returns the week number, the 'v' didn't work in your video because it needs to be upper case.

  • @krishnareddyketha6412
    @krishnareddyketha6412 4 роки тому +1

    Shane Young.. you made my learing easier ...I started learning PowerShell by watching your video tutorial. Thanks for the clear and informative content.

    • @ShanesCows
      @ShanesCows  4 роки тому

      Glad to help. Enjoy learning 😀

  • @tiri73
    @tiri73 6 років тому +2

    Congratulations, I'm starting with Powershell and you have the best videos and explanations I have seen about Powershell, you gave me a new approach. Good job. Thanks man!!

    • @ShanesCows
      @ShanesCows  6 років тому

      Very cool. Thanks for sharing.

  • @michaelschultz4976
    @michaelschultz4976 7 років тому +3

    Shane, I love your demonstration style. I have struggled with PowerShell, and after watching your videos, I think it is starting to click.

  • @syednawaz5748
    @syednawaz5748 6 років тому +1

    Hey Shane, as i was confused whether to opt to learn powershell or not as most of my friends has confused me that its really tough to learn after watching your series of videos i came to know its not tough, hats off to you as u made it so clear and easy to understand

    • @ShanesCows
      @ShanesCows  6 років тому

      Awesome! Glad you are learning. 😀

  • @kennethpeterson3188
    @kennethpeterson3188 4 роки тому +1

    Thanks Shane for the video. Have seen 1 & 2. Just starting with PowerShell but find it very interesting. May have to watch them again. Thanks again!

  • @franklinchaguendo4294
    @franklinchaguendo4294 7 років тому +2

    Thanks Shane! Always a pleasure to learn from you.

  • @kuldeepdeshmukh4992
    @kuldeepdeshmukh4992 6 років тому +1

    Amazing...You make Powershell learning more interesting.Thank you

  • @DarshanaHashendra
    @DarshanaHashendra 3 роки тому +1

    Brilliant content. straight to the point.

    • @ShanesCows
      @ShanesCows  3 роки тому

      Thanks. About 40 more videos to go. 😎

  • @Corrado49
    @Corrado49 3 роки тому +1

    I learn so much with your videos, thanks!

  • @AshraRai
    @AshraRai 7 років тому +2

    Brilliant lesson, specially the creation time manipulation.

  • @annazielinska9004
    @annazielinska9004 4 роки тому +2

    Excellent Tutorial. I hope you'll keep on uploading more content :)

    • @ashley7900
      @ashley7900 4 роки тому +2

      I agree

    • @ShanesCows
      @ShanesCows  4 роки тому

      Thanks. There is over 40 videos to help you. 😀

  • @PaulRamnora
    @PaulRamnora 3 роки тому +1

    Great, wonderfully informative...learned to do stuff which I never knew before. -Thanks! ;-)

  • @raymondlipin7330
    @raymondlipin7330 3 дні тому

    Great video! Thanks!!

  • @DevOpsWithPankaj
    @DevOpsWithPankaj 5 років тому +2

    Hey man... You are rocking with you videos. Great way of explanation, most important you give full justification to every topic that you have touched.
    So with word topic :) Can you make a video with regx explanation (Or Point me if you have already). Thanks in Advance

    • @ShanesCows
      @ShanesCows  5 років тому

      Glad to help. I haven’t done much with regex sorry 😐

  • @santiaguson
    @santiaguson Рік тому

    Hi Shane,
    When I use the get-date command I get:
    August 25, 2023 11:11:23 AM
    Everywhere I have searched shows the default output to be
    Friday August 25, 2023 11:11:23 AM
    What do I have to do to change the format?
    I used get-date -uformat %c but it does not change it.
    Take care,

  • @PS-er1qm
    @PS-er1qm 5 років тому +1

    Hi there, very simple one. How do you create a batch file to launch powershell in administrator mode without having to press "ok" buttons and to then set some simple environmental variables?

    • @ShanesCows
      @ShanesCows  5 років тому

      Look for my video on Task scheduler for an idea.

  • @darryvakki9807
    @darryvakki9807 2 роки тому +1

    God bless u always . Mate

    • @ShanesCows
      @ShanesCows  2 роки тому

      Thank you Darshan. Very kind of you. Have a great week! 🐶

  • @thyspretorius6918
    @thyspretorius6918 7 років тому

    Hi Shane, thanks for sharing in a very interesting way. At 16:45 into the video I noticed something peculiar. Could you perhaps explain how subtracting 9 months from 11 December 2016 gives 12 July 2016? I would think it to be around 11 or 12 March 2016. Kind regards

    • @ShanesCows
      @ShanesCows  7 років тому

      Thys I looked through the video and didn't see the part you are talking about? Can you double check your time stamp again? Thanks. Happy to clear up any confusion.

    • @ShanesCows
      @ShanesCows  7 років тому +1

      Okay I kept watching and found the confusion. It is around 15:25. You confusion comes from we are setting the value of Zebra.CreationTime = $pig.addmonths(-9). $pig was April 11 so we are subtracting 9 months from that date. The December date was the old value of CreationTime and not part of the math. Does that help?

    • @thyspretorius6918
      @thyspretorius6918 7 років тому

      Shane Young Yes that clarifies it. Thanks.

  • @Spasmaticus
    @Spasmaticus 5 років тому +1

    Hey, great set of videos, sparked an interest for Powershell... But I wonder, how come your text changes color depending on the type of input you write, while mine is always the same color? :L

    • @ShanesCows
      @ShanesCows  5 років тому

      With windows 10 there is something installed by default called psreadline. I get the question I made a video. ua-cam.com/video/3jAH92mBbRk/v-deo.html

  • @ANKITSINGH-qg3ie
    @ANKITSINGH-qg3ie 7 років тому

    Awesome video Shane! Thank you so much for your great effort. I would like to ask that i got some difference in time format in my output. I have windows10 OS. Below is the example---
    PS C:\Users\Ankit Singh> Get-Date
    15 September 2017 11:04:19
    Here Day is not present.

  • @sunset203
    @sunset203 Рік тому +1

    hi, se puede mostrar hostname and date one line command?

    • @ShanesCows
      @ShanesCows  Рік тому

      Write-Host "$(hostname) - $(Get-Date)"

  • @saiprasaddas6848
    @saiprasaddas6848 5 років тому +1

    Hi Shane,
    could you please help me to know how to keep a date constant in powershell so that it can be execute as Subtask later
    Please Help!

  • @anuragkumar-lh1zv
    @anuragkumar-lh1zv 4 роки тому +1

    i need to print like some logs from 5/2/2020 to 20/12/2020 . what will be code for that ?

  • @mrweeble63
    @mrweeble63 4 роки тому +1

    Hey Shane
    New to PS but quickly learning. Mostly thanks to your tutorials.
    I have written Create New AD User from CSV file script.
    The csv has a date presented as dd/MM/yyyyy, However Powershell pukes at that format and wants it presented as MM/dd/yyyy.
    I note i see a post about converting/changing the "culture" but it seems really complicated for just changing the format of the dta as presented.
    All other examples i find regarding manipulating DateTime is when using the Get-Date command.
    Since i already have the date, i am struggling.
    Do you or anyone have a quick and easy method to change the format of the date given to me by another department?
    Thanks for all your videos - Cheers
    Happy New Year 2021
    Mr Weeble

    • @ShanesCows
      @ShanesCows  4 роки тому

      Hey Jeff - I don't. My PowerShell for that stuff is a bit rusty. Sorry

    • @mrweeble63
      @mrweeble63 4 роки тому

      @@ShanesCows Thanks for the response Shane. I need to test, but i believe i have found the solution.
      $ProperDateFormat = [datetime]::parseexact($expire, 'dd/MM/yyyy', $null).ToString('MM/dd/yyyy')

  • @gofftershnit
    @gofftershnit 7 років тому +1

    Fun to learn, Very helpful. Thanks!

  • @robertwilliams48
    @robertwilliams48 4 роки тому +1

    The tutorial is very well done! One annoyance: after every "cls" that you do, if you are in full screen mode, the video title appears whenever you touch the mouse and obscures the stuff you're typing. If not in full screen mode, the text is too tiny to read! Seems like the easiest solution is to simply stop using cls. Other than that, I was properly educated!

    • @ShanesCows
      @ShanesCows  4 роки тому

      Awesome and sorry about the minor issues 😑

  • @nanangzulkarnain6239
    @nanangzulkarnain6239 5 років тому +1

    Great tutorial! Thanks a bunch 👍

  • @ChiragNayyar91
    @ChiragNayyar91 7 років тому +2

    superb as always

  • @EVILWez-YT
    @EVILWez-YT 6 років тому +1

    I know this video is old, just wanted to say thank you. Also could you perhaps explain to me how does one import a date from a csv file - (obviously import it into a variable) but then how does one compare it to a current date (get-date) and out put the difference between them in Days : So $a = Import-Csv "doc.csv" | $computerdate = $a.LastLogonDate | $newdate = Get-Date | $computerdate - $newdate ????? = I'm a bit lost here...

    • @ShanesCows
      @ShanesCows  6 років тому

      I think this video will teach you about importing CSV files into PowerShell. ua-cam.com/video/PXBMdIkH24I/v-deo.html
      You may then need to convert what comes in from the CSV into a date. You can use Get-Date(YourImportedObject) to convert it. Now you have a date. With the date in hand you can do all of the date functions/comparisons you want to do.

  • @sainath4277
    @sainath4277 5 років тому +1

    Hi Shane, I am returning a value from function and if I am using that return value as a date I am getting the below error.
    Cannot convert system.object () to system.datetime
    Can you please help me out with any solution?

    • @ShanesCows
      @ShanesCows  5 років тому +1

      I think you need to look at the data you are returning and its data tupe

    • @sainath4277
      @sainath4277 5 років тому

      @@ShanesCows thanks for the solution, it's an array type so am getting issue and resolved by your techniques

  • @sean2me
    @sean2me 6 років тому +1

    Thanks for your great videos, very helpful! Can Power Shell do math beyond simple algebra? Can I do trigonometry and other more advanced math?

    • @ShanesCows
      @ShanesCows  6 років тому +1

      I had never thought about this. Looking at this blog post looks like it does a lot more than I would have guessed. www.madwithpowershell.com/2013/10/math-in-powershell.html

  • @alpha_centaurus5396
    @alpha_centaurus5396 2 роки тому +1

    Thank you 😌

  • @LOOregano
    @LOOregano 2 роки тому

    Great video but wish it showed how to manipulate the date format for more than one row in the column. So close yet so far away! 🙂

  • @billanonymous8642
    @billanonymous8642 3 роки тому +1

    How did subtracting 9 months from a creation date of December 2016, become July 2016?

    • @ShanesCows
      @ShanesCows  3 роки тому +1

      I had to watch to find it. I crossed my variables and caused the confusion 😎 Whoops

  • @Jeromos9
    @Jeromos9 4 роки тому +1

    Thanks, awesome!

  • @eiji881
    @eiji881 7 років тому

    Hey Shane,
    I am trying to compare two formatted dates. Both are technically string objects, however, I would like to compare the DIFFERENCE of the dates.
    One is a Get-Date that I format to "yyyy-MM-dd hh:mm:ss"
    the other is a date in that format, which I pull from a CSV file.
    I would like the output to be an integer.
    Can you help me out?

    • @ShanesCows
      @ShanesCows  7 років тому

      Hi Mack - Email me what you have so far and the details and I will take a look and see if I can easily help. shane.young at boldzebras.com

  • @ramyagopu5286
    @ramyagopu5286 6 років тому +1

    Can you please explain ,how to write powershell script to get last patched date in windows

    • @ShanesCows
      @ShanesCows  6 років тому

      I will add patch management to the list.

  • @chill6030
    @chill6030 4 роки тому +1

    Very helpful. But can you help me increase a value of time by one click on ưindows?

    • @ShanesCows
      @ShanesCows  4 роки тому

      I haven’t done that before

  • @sisqokid7978
    @sisqokid7978 6 років тому +1

    I am getting a date time value and don't know how to convert it. How would
    Powershell Convert 19691231190000.000000 to date and time

    • @ShanesCows
      @ShanesCows  6 років тому

      Yikes. I haven't had that before. SOrry.

  • @sarahleard7358
    @sarahleard7358 7 років тому

    When does your next session start for PowerShell beginners?

    • @ShanesCows
      @ShanesCows  7 років тому

      Hi Sarah - Will you email me and we can chat about what you are looking for shane.young @ boldzebras.com

  • @burntkat
    @burntkat 5 років тому +1

    Why isn't the time incrementing on your examples around 6 minutes in?

    • @ShanesCows
      @ShanesCows  5 років тому

      Not sure. Been a long time.

  • @aslamsayyed3961
    @aslamsayyed3961 2 роки тому

    Helped me thank you

  • @PiGoElectronics
    @PiGoElectronics 7 років тому +1

    Great, thanks!!

  • @srenlarsen3148
    @srenlarsen3148 2 роки тому +1

    What about show total weeks in a year.

    • @ShanesCows
      @ShanesCows  2 роки тому

      Sorry I haven’t done that one.

    • @srenlarsen3148
      @srenlarsen3148 2 роки тому

      @@ShanesCows okay I have looked into it.
      I found the challenge, because we have leap days 52 or 53 pr. year.
      For example. 2020 that have 53 and 2022 have 52 days in Powershell language.

  • @arp-leonhardroller1958
    @arp-leonhardroller1958 3 роки тому

    How is December minus 9 months July? O.o