All Projects → KirkMunro → Snippetpx

KirkMunro / Snippetpx

Licence: apache-2.0
Invocable Snippet Support in PowerShell

Programming Languages

powershell
5483 projects

Labels

Projects that are alternatives of or similar to Snippetpx

Lyo
📦 Node.js to browser - The easy way
Stars: ✭ 624 (+1912.9%)
Mutual labels:  module
Shield
A declarative, efficient, and flexible Native framework for building user interfaces.
Stars: ✭ 901 (+2806.45%)
Mutual labels:  module
Currencyviewer
Short python framework that dynamically displays and converts the cryptocurrencies in your Kraken wallet into equivalents fiat money.
Stars: ✭ 13 (-58.06%)
Mutual labels:  module
Oji
(◕‿◕) Text Emoticons Maker
Stars: ✭ 668 (+2054.84%)
Mutual labels:  module
Darkage
🎮 Darkage mod for Minetest
Stars: ✭ 6 (-80.65%)
Mutual labels:  module
Metasploit Modules
Various Metasploit Modules
Stars: ✭ 12 (-61.29%)
Mutual labels:  module
Lass
👧 Lass scaffolds a modern package boilerplate for Node.js
Stars: ✭ 615 (+1883.87%)
Mutual labels:  module
Dropwizard Jwt Cookie Authentication
Dropwizard bundle managing authentication through JWT cookies
Stars: ✭ 29 (-6.45%)
Mutual labels:  module
Infinity Dashboard Modules
Infinity Dashboard Modules
Stars: ✭ 17 (-45.16%)
Mutual labels:  module
Nginx Cleantalk Service
LUA configuration to filter any POST requests.
Stars: ✭ 13 (-58.06%)
Mutual labels:  module
React Native Shimmer Placeholder
Placeholder/ Skeleton of React Native
Stars: ✭ 679 (+2090.32%)
Mutual labels:  module
Acgclub
一款纯粹的ACG聚合类App
Stars: ✭ 829 (+2574.19%)
Mutual labels:  module
Generator Mage2
Yeoman generator for Magento 2 extensions (modules and themes)
Stars: ✭ 12 (-61.29%)
Mutual labels:  module
Elasticsuite
Smile ElasticSuite - Magento 2 merchandising and search engine built on ElasticSearch
Stars: ✭ 647 (+1987.1%)
Mutual labels:  module
Java9 Jigsaw Depvis
DepVis (Java 9 Jigsaw Dependency Visualizer)
Stars: ✭ 14 (-54.84%)
Mutual labels:  module
Resolve
Implements the node.js require.resolve() algorithm
Stars: ✭ 622 (+1906.45%)
Mutual labels:  module
Mespronos
Sport betting module for Drupal 8
Stars: ✭ 8 (-74.19%)
Mutual labels:  module
Sao Nm
Scaffold out a node module.
Stars: ✭ 30 (-3.23%)
Mutual labels:  module
Summer
Decoupled protocol for modules in Android App
Stars: ✭ 19 (-38.71%)
Mutual labels:  module
Apache24 Modules
Modules for Apache 2.4 and maybe 2.2
Stars: ✭ 12 (-61.29%)
Mutual labels:  module

SnippetPx

Overview

The SnippetPx module enhances the snippet experience in PowerShell by offering a new format for Snippets: plain, ordinary ps1 files. These snippets are not just blocks of script that could be injected into a file. They are also invocable! This enables better reuse of commonly used pieces of script that would not otherwise be placed into a PowerShell function, either because the function support in PowerShell won't allow for it to be invoked properly in the current scope, or because it isn't big enough to warrant adding another function to the function pool.

Snippets are automatically discovered based on their inclusion in the following folders (in the order in which they are listed):

  • the current user snippets folder (Documents\WindowsPowerShell\snippets);
  • the all users snippets folder (Program Files\WindowsPowerShell\snippets);
  • the snippets folder in the SnippetPx module (SnippetPx\snippets);
  • the snippets folder in all other modules, in the order in which they are discovered according to the PSModulePath environment variable;

If multiple snippets with the same name exist in different folders, only the first snippet with that name will be discovered. To guarantee uniqueness of snippets across modules, snippets specific to a module should use a snippet name prefixed with the module name. For example, a snippet to provision AD users in an ActiveDirectory module could use the filename ActiveDirectory.User.Provision.ps1.

Using spaces in snippet filenames is supported, but discouraged.

Not all snippets are appropriate for use in all situations. When in doubt, consult the documentation for the snippet to ensure it is appropriate for your use case.

Minimum requirements

  • PowerShell 3.0

License and Copyright

Copyright 2016 Kirk Munro

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Installing the SnippetPx module

You can download and install the latest version of SnippetPx using any of the following methods:

PowerShellGet

If you don't know what PowerShellGet is, it's the way of the future for PowerShell package management. If you're curious to find out more, you should read this: Package Management for PowerShell Modules with PowerShellGet

Note that these commands require that you have the PowerShellGet module installed on the system where they are invoked.

# If you don’t have SnippetPx installed already and you want to install
# it for all all users (recommended, requires elevation)
Install-Module SnippetPx

# If you don't have SnippetPx installed already and you want to install
# it for the current user only
Install-Module SnippetPx -Scope CurrentUser

# If you have SnippetPx installed and you want to update it
Update-Module

PowerShell 3.0 or Later

To install from PowerShell 3.0 or later, open a native PowerShell console (not ISE, unless you want it to take longer), and invoke one of the following commands:

# If you want to install SnippetPx for all users or update a version already
#  installed (recommended, requires elevation for new install for all users)
& ([scriptblock]::Create((iwr -uri http://bit.ly/Install-ModuleFromGitHub).Content)) -ModuleName SnippetPx

# If you want to install SnippetPx for the current user
& ([scriptblock]::Create((iwr -uri http://bit.ly/Install-ModuleFromGitHub).Content)) -ModuleName SnippetPx -Scope CurrentUser

Using the SnippetPx module

To see a list of all snippets that are available in your environment, invoke the following command:

Get-Snippet

This will return a list of all snippets that have been discovered on the local system in the snippets folders that it found. Each snippet object will include the name of the snippet, the path to the snippet file, a synopsis identifying what the snippet does, a description that describes the snippet in a little more detail, and a script block that contains the body of the snippet.

Once you have identified a snippet that you want to invoke in one of your scripts, you can invoke that snippet with a command like the following:

# Import all ps1 files in the functions folder into the current scope
Invoke-Snippet -Name ScriptFile.Import -Parameters @{
    Path = Join-Path -Path $PSModulePath -ChildPath functions
}

Some snippets are included with the SnippetsPx module, and others may be discovered in other modules or in the current user or all user snippets folders. It is important to note that invoking a snippet alone does not automatically load the module in which it is contained. The module will only be auto-loaded if the snippet itself contains a command that would trigger the auto-loading of the module. This is worth understanding for modules that include snippets that work with module content other than discoverable commands.

Command List

The SnippetPx module currently includes the following commands:

Get-Snippet
Invoke-Snippet
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].