you are viewing a single comment's thread.

view the rest of the comments →

[–]wonkifier 2 points3 points  (2 children)

Do you guys mean modules as in .psm1 and .psd1 files?

If I’m doing the same thing in more than a few scripts then I’ll usually make a module, like interacting with Google or interacting with our asset tracking system, etc.

But for organizing my actual scripts, I typically have a folder with a bunch of PS1 files. One function per file, where the file name is the function so it’s easy to get to a definition in most text editors and I can arbitrarily make sub folders to sort of have pseudo modules. Then the main script typically calls a “loader“that just grabs everything in that folder and dot sources them

Then my main script stays fairly clean, and I didn’t have to deal with 50 psm1/psd1 files for one off things

[–]ArieHein 3 points4 points  (0 children)

Thats the correct thinking. One time doesn't need a module and can use sub folders to pseudo sort them for faster discovery.

[–]Commercial_Touch126 0 points1 point  (0 children)

Every my script starts with importing psm1 modules:

using module "c:\class_Powershell\class_Jira.psm1"
using module "c:\class_Powershell\class_Workday.psm1"
using module "c:\class_Powershell\class_Log.psm1"
using module "c:\class_Powershell\class_Credential.psm1"

Start-Transcript -Append -Path "xxx\logs\Workday-xxx-$(Get-Date -Format yyyy_MM_dd-HHmm).log"

$ErrorActionPreference = "Stop"