Learn PowerShell: Episode 4, Types + Methods + Casting

Ғылым және технология

As we know very well by now, objects are the most central part of PowerShell, everything is built around them, and as such, there's quite a bit to them! In this video we're going to take a deeper look at objects than we have before, digging into some more of the smaller parts (members) they're made up of and much more!
Please note that I was a little sick while recording this so things definitely sound a little off in comparison to the previous videos, but shouldn't take too much away!
The video starts by continuing from the "cliffhanger" question of the last episode: How can we shorten down the process of adding note properties to an object? Well, we take a look at some aliases that can be used, some special parameters on the "Add-Member" command and more that help us shorten it down!
After that, the video dives into and takes a look at types, this is a key part of how the whole object system provided by .NET in PowerShell works and helps provide a very solid understanding of how properties and methods are dispatched to objects and how objects are grouped up within PowerShell.
We then take a look at how you can get the details of a type by its name, taking advantage of the special square bracket syntax within PowerShell to help us get a hold of specific details about a type, such as its full name, what properties it defines and much more.
Once we're learnt the square bracket syntax, we then link it to something we learnt in the last video, about how to convert from one type to another. We learn that doing this is called "casting", as well as some of the rules that apply to casting and what casts are most likely valid and what casts most likely aren't.
The idea of casting is a lot clearer when we have knowledge of the central type system that objects follow within PowerShell, as we gain earlier in this video.
In this video, we also take a closer look at all of the smaller kinds of members you can get on objects. We go over note properties and properties, as we already covered in the last video, as well as briefly mentioning some of the other types, such as "ScriptProperty" and "CodeProperty". However, we then use this to take a look at the new, and final member we need to know about across this series.
This member is called a "Method" (also known as 'function' as you may have heard of), and it plays a very different role to properties, as shown in the video. Properties allow objects to store data and are the key pieces for allowing an object to represent a specific thing. However, in addition to storing data, different types of objects also have code attached to them, and this code is organised into blocks (single actions) called methods. Methods are actions you can perform and when you run them, they will perform a specific action.
We take a look at everything to do with methods, how they're run, whether they have parameters, whether they can give things back, their difference between commands, and how technically small it is and much more.
In addition, in this video, we also take a look at the type limiting that occurs very often within PowerShell, across properties, parameters, "return types" (explained in the video) and much more!
Hope you enjoy it!
Chapters:
0:00 Shortening Commands
5:00 Types
7:25 Casting In-Depth
9:00 Properties In-Depth
10:52 Methods
13:45 Auto Casting
18:00 Calling Methods
23:37 Type Analysis
26:35 Commands vs Methods
Thanks for watching my video, before are some general ABMedia links if you are interested:
Website ► abco.live/
Discord ► abco.live/discord
The Discord server is a place to chat with the creator of this video, as well as anyone who contributed to its development and has helped support ABWorld over the years.
A huge thank you goes to @ndumiphotos (on Instagram) for the graphics used in the intro.
#learnpowershell #powershell

Пікірлер: 34

  • @ABCo-ABMedia
    @ABCo-ABMedia3 жыл бұрын

    Episode 5 coming out this week! Stay tuned!

  • @noelwilson5253

    @noelwilson5253

    3 жыл бұрын

    ep 5?

  • @ABCo-ABMedia

    @ABCo-ABMedia

    3 жыл бұрын

    @@noelwilson5253 Yes, Episode 5. The series isn't over yet!

  • @ABCo-ABMedia

    @ABCo-ABMedia

    2 жыл бұрын

    Just a few hours to go!

  • @jasonmoore4429

    @jasonmoore4429

    2 жыл бұрын

    I think something like Powershell is a great introductory course to help prime you for learning coding like python or java.

  • @ABCo-ABMedia

    @ABCo-ABMedia

    2 жыл бұрын

    @@jasonmoore4429 PowerShell is nice as a first language, yes! If you ever wanted to get into much more major programming after the series, the best language to go to after PowerShell is almost definitely C#. Because PowerShell is based on .NET, the exact same thing as C#, so there's _a_ _lot_ of stuff shared.

  • @MunnyLerner
    @MunnyLerner5 ай бұрын

    I'm thinking while watching this "his explanations of objects, methods, parameters is freaking fantastic, just enough detail and it's so well scripted to connect the dots" and right at the end he says, "I improvised that, I don't why, I just improvised..." which tells you he absolutely knows his subject backwars and forwards! And for that, I am very grateful, because this tutorial series is making for extremely efficient learning.

  • @ABCo-ABMedia

    @ABCo-ABMedia

    5 ай бұрын

    Haha, thanks. Glad you're enjoying it.

  • @noelwilson5253
    @noelwilson52533 жыл бұрын

    i appreciate the way you teach it easy too watch the whole video all the way thru

  • @ABCo-ABMedia

    @ABCo-ABMedia

    3 жыл бұрын

    Glad you like it, as I was making this video I was constantly worrying about whether the explanation was clear or not, it just didn't feel 100% to me no matter how many times I went over the script, I was a little worried about it but I'm glad to hear that it all made sense

  • @WhatsUpChuck
    @WhatsUpChuck Жыл бұрын

    These videos are clear and concise with a well-thought-out script that takes into account a beginner's perspective. I greatly appreciate the work you've done on this and can't thank you enough!

  • @ABCo-ABMedia

    @ABCo-ABMedia

    Жыл бұрын

    Happy to hear you like it :)

  • @kevinchaplin672
    @kevinchaplin672 Жыл бұрын

    These videos are so good. Thanks man. I wasted too much time elsewhere, glad I found these eventually.

  • @user-qk6jc9ld5x
    @user-qk6jc9ld5x6 ай бұрын

    you are great ! thanks a lot!

  • @bhavyah4662
    @bhavyah46622 жыл бұрын

    I like the way you explain , its so simple and clear. I started learning PoweShell today ... I some how started watching your video Episode 1 on PowerShell and now continuing ....with remaining videos...great learning & very helpful ! Thank you

  • @ABCo-ABMedia

    @ABCo-ABMedia

    2 жыл бұрын

    Glad to hear it!

  • @jam92rrki
    @jam92rrki2 жыл бұрын

    You are very good at what you do and your tutorial videos are excellent! I'm learning so much from you! Thank you!

  • @ABCo-ABMedia

    @ABCo-ABMedia

    2 жыл бұрын

    I'm glad to hear you're learning a lot from them!

  • @beansfoundhere
    @beansfoundhere Жыл бұрын

    10/10 awesome videos. I assume it's referred to as "calling a function" becuase the assembally instruction that points the instruction pointer from normal code flow to your function is named "call".

  • @ABCo-ABMedia

    @ABCo-ABMedia

    Жыл бұрын

    Thanks, glad you enjoy them! The instruction won't be the origin, that will have been named "call" _because_ that's the phrase, as opposed to the phrase coming from that. You gotta remember there is no one singular "assembly language", there are lots of different CPU architectures and they each have their own set of instructions, so while you might think "Well, assembly is the basic thing that's been there from the start, so it must be from that", the instructions in the assembly language have varied a lot over the years.

  • @Isiloron
    @Isiloron2 жыл бұрын

    As far as I know, converting types is called casting because of metalworking. You cast molten metal into a mold. You cast one type of data into another.

  • @ABCo-ABMedia

    @ABCo-ABMedia

    2 жыл бұрын

    Haha yeah I'm sure there's a logical reason why it's called that. I just thought it was funny to say "for some reason". Thanks for that fun fact though, I didn't know that!

  • @hjoseph4327
    @hjoseph4327 Жыл бұрын

    I love your courses not sure why you did not use the powershell ISE from a developer perspective instead of a sysadmin environment

  • @philsmith3529
    @philsmith35294 ай бұрын

    You use the term brackets for ( )

  • @ABCo-ABMedia

    @ABCo-ABMedia

    4 ай бұрын

    I do, yeah, it's just how I've always used the term. The actual formal definition of the term "brackets" is open to refer to _any symbols_ that sit around a piece of text, so it is _technically_ by the true definition ambiguous, but not incorrect.

  • @gergelynemeth744
    @gergelynemeth7442 жыл бұрын

    I've tried the Iport-csv for the begining of the video. When I convert the numbers to integer, got the follow error: $students = Import-Csv test.csv $students | foreach { $_.Maths = [int]$_.Maths } SetValueInvocationException: Exception setting "Maths": "The property 'Maths' cannot be found on this object. Verify that the property exists and can be set." I could get some help about it?

  • @ABCo-ABMedia

    @ABCo-ABMedia

    2 жыл бұрын

    What's in the "test.csv" file? If there's a "Maths" column then every object should have a "Maths" property on it and it shouldn't be a problem. But if there isn't a "Maths" column in the CSV file, they won't have that property on them and that would be why you have an error.

  • @gergelynemeth744

    @gergelynemeth744

    2 жыл бұрын

    @@ABCo-ABMedia I made a .csv file such in the video with "English"; "Name"; "Maths"; "Age"; columns, and fill with numbers and names.

  • @ABCo-ABMedia

    @ABCo-ABMedia

    2 жыл бұрын

    @@gergelynemeth744 Ah, did you seperate them with semicolons? By default, PS (PowerShell) is expecting there to be _commas_ between each thing. You can change that by doing "Import-Csv -Delimiter ';' " instead of just "Import-Csv"

  • @gergelynemeth744

    @gergelynemeth744

    2 жыл бұрын

    @@ABCo-ABMedia YES! It works! Thank you so much! :)

  • @hf538
    @hf538 Жыл бұрын

    the discord link doesn't work. do you have the updated link?

  • @ABCo-ABMedia

    @ABCo-ABMedia

    Жыл бұрын

    That's odd, it works fine for me. Honestly I wouldn't worry too much about it though, the Discord is unfortunately very, very dead as a lot of my attention has gone towards another, very unrelated, server

  • @fabhi
    @fabhi2 жыл бұрын

    Are types like classes in OOP?

  • @ABCo-ABMedia

    @ABCo-ABMedia

    2 жыл бұрын

    Yep, that's exactly what they are! .NET is _object-oriented_ so all this stuff you've learnt about properties and methods etc. Is all object-oriented programming in action.

Келесі