Giter Club home page Giter Club logo

pas-module's Introduction

Powershell Profiles

Links

PaS-Module Structure

PaS-Module\
    |- Functions\
    |   |- Get-User.ps1
    |   |- Get-WindowsBuild.ps1
    |   |- <FunctionFile>.ps1
    |- PaS-Module.psm1
    |- PaS-Module.psd1

A module is a .psm1 file. To Import it's usually: Import-Module .\PaS-Module.psm1 It's Best Practice to name .psd1 and .psm1 the same as the folder

If you do it like that, you can just use: Import-Module .\PaS-Module

If placed in one of the path's as defined in $env:PSModulePath you can simply do it like this: Import-Module PaS-Module

PaS-Module.psd1

@{
    ModuleVersion = '1.0'
    GUID = '55db66c7-37e0-4a80-9d41-7e5136282c2c'
    Author = 'Pascal Schoofs'
    Description = 'Useful Functions'
    PowerShellVersion = '7.x'
    FunctionsToExport = @('Get-User', 'Get-WindowsBuild')
    RootModule = 'PaS-Module.psm1'
    CompatiblePSEditions = @('Desktop')
    AliasesToExport = @()
    CmdletsToExport = @()
    VariablesToExport = @()
    PrivateData = @{
        PSData = @{
            Tags = @('PowerShell', 'Module', 'Utilities')
            ReleaseNotes = 'Initial release as module'
        }
    }
}

Quote from Reddit regarding Functions and psm1 file

Personally I keep my function files separate, and I just loop through them with get-content and write to my PSM1 file, and update the manifest as necessary. That way I have a psm1 that's fully self-contained, and I can update function files individually. Otherwise it just seems like you're locked into the same version of everything for the life of your code.

You can add plenty of bells and whistles, but at its core, my process it just this:

get-childitem <functions directory> | get-content | set-content <module.ps1>

I iterate through the files to get function names, perform some syntax checks, and check the contents of the psm1 before and after to see if I need to increment the version number, but all that isn't necessary to just get started.

F7History

Install with:

  • Install-Module -Name "F7History"

Import with (Put it in $profile):

  • Import-Module -Name "F7History" -ArgumentList @{Key = "F7"; AllKey = "F8"}

F7 opens History of Session F8 opens complete History (including Timestamps)

Out-ConsoleGridView

Install with:

  • Install-Module microsoft.powershell.consoleguitools

Usage Example:

  • Get-Service | Out-ConsoleGridView

  • $SERVICES=Get-Service | Out-ConsoleGridView

This stores multiple items in a variable

Lists

  • Aufräumen
  • Schlafen
  • Nix tun
  • GARNICHTS TUN
  • verschlafen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.