From the course: Complete Guide to PowerShell 7
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Function libraries and modules - PowerShell Tutorial
From the course: Complete Guide to PowerShell 7
Function libraries and modules
- [Narrator] So, so far we've talked about creating basic functions, adding parameters, advanced handling, validation, reusable functions, and obviously formatting the return data. Now what we're going to talk about now is actually packaging all of this up together. So the first thing I've got is three functions, so Get-Greeting, Add-Numbers, and Get-CurrentTime. These functions are not available to me at the moment 'cause I haven't executed these, but I want to copy these and put these into my functions and put them into a separate ps1 file. What I can then do is just simply load that. So use dot and then the path to the file. I'm going to say run selection, and then I can use those functions in the bottom section. So sure enough, it says hello. If I add the numbers, it'll add the numbers. If I do current time, it will do the current time. So fairly straightforward. Now if I wanted to package this up even further, then I'll want to create it as a module. Now the first task I'm going…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Introduction to functions6m 4s
-
(Locked)
Creating simple functions3m 20s
-
(Locked)
Using parameters in functions6m 28s
-
(Locked)
Advanced parameter handling6m 16s
-
(Locked)
Validating parameters5m 57s
-
(Locked)
Returning values from functions2m 34s
-
(Locked)
Creating reusable functions8m 33s
-
(Locked)
Function libraries and modules4m 30s
-
(Locked)
-
-
-
-
-
-
-