Building PowerShell Module - how to organise your source files and build with ease

preview_player
Показать описание
Organising all files, scripts and functions required to build a module might give one a headache. PowerShell doesn't come with native way of building the module, which doesn't make our job easier.

Hence, we're going to use ModuleBuilder from PowerShell community so that the way we organise the code is predictable and used widely across other PowerShell projects.

In this video I'll walk you through the process of preparing, organising and finally building the module.

00:00 BEGIN
00:31 ABOUT VIDEO
01:56 Module Builder
02:48 Sample files for today
03:56 Files organisation
04:11 Install Requirements
05:17 Start Module Build
05:55 Source directory
06:10 Module manifest
08:20 Debugging source files
10:45 Building module
13:03 Making functions public/private
18:25 Summary

◼️◼️◼️
Рекомендации по теме
Комментарии
Автор

Thank you for your Today's session 😊

bharathsimha
Автор

Hi, thanks for the video (and I can see, taking the time to respond to comments!). For me, the main thing I wanted to understand was *how to organise the files* -- for example...

[1] I have my own module, some co-workers put the source code for all their functions in the .psm1 file, but I prefer to use 1 file per function (I think like you do), which way is correct/best?...

[2] Do I need to use a public and private folder (currently I do not)?...

[3] When to split modules, for example as my module has grown it has functions for different things, currently I have subfolders like "manage-files", "pnp" (for SharePoint online), "utility" (for little UI, helper scripts, etc) -- is using sub folders like this OK, or should I make 3 separate modules? - a "manage-files" module, a pnp one a utility one, etc.

Thanks again for the video and (hopefully) your help! 👍🏼

martinzima.
Автор

Great introduction...
Question: Can ModuleBuilder be used to define a class in a module that can then be used from a different module?

larspedersen
Автор

@Kamil Pro great video
Question : How do you use config files with modules, to store configs for a given module

doper
Автор

Do you know how VariablesToExport is populated? I have several constants that are used by multiple functions, but must also be exported to the PowerShell session that imports the module.

ESPViper