Questions tagged [powershell-module]

Powershell Modules are sets of related Windows PowerShell functionalities that can be dynamic or persist on disk. Modules can contain cmdlets, providers, functions, variables, aliases and PowerShell drives.

A Powershell Module is a set of related Windows PowerShell functionalities that can be dynamic or persist on disk. Modules that persist on disk are referenced, loaded, and persisted as script modules, binary modules, or manifest modules.

Related Cmdlets

  • ImportSystemModules
  • New-Module
  • Import-Module
  • Export-ModuleMember
  • Get-Module
  • Remove-Module
  • New-ModuleManifest
  • Test-ModuleManifest
203 questions
8
votes
1 answer

PowerShell module design - Export-ModuleMember

I am building a module that exports a cmdlet that I would like to make available through my profile. The implementation of this cmdlet is spread across multiple implementation files that contain implementation functions I don't want to make publicly…
Matthew S
  • 900
  • 3
  • 12
  • 26
7
votes
0 answers

Getting "InvalidOperation: Cannot run a document in the middle of a pipeline:" error when building powershell module in Visual Studio Code

Problem Description When I select Run Without Debugging in Visual Studio Code 1.58.2 on the module SampleModule.psm1 function ConvertTo-PascalCase([String []] $words) { [String] $pascalCaseString = [String]::Empty foreach ($word in $words)…
Banji
  • 81
  • 1
  • 5
7
votes
2 answers

How to manage dependencies between scripts in multi-file Powershell Module?

I have a large amount of powershell code that I've written over the course of a long project; these scripts perform a wide variety of functions, and most of them depend in some way on others within the scope of the project. Right now, the work is…
bwerks
  • 8,651
  • 14
  • 68
  • 100
7
votes
4 answers

How to import Chocolatey function, core and extension to PowerShell sessions?

I find many Chocolatey helper functions: C:\ProgramData\chocolatey\helpers\functions and extension functions C:\ProgramData\chocolatey\extensions\chocolatey-core are very useful when you develop even non Chocolatey packages. Is there any way to…
Dilshad Abduwali
  • 1,388
  • 7
  • 26
  • 47
7
votes
1 answer

Difference between `PowerShellVersion` and `PowerShellHostVersion`

Summary What's the difference between the PowerShell Module Manifest values PowerShellVersion and PowerShellHostVersion? Long Version When creating a new module manifest there are settings for both the minimum version of PowerShell required by this…
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
7
votes
2 answers

Is there any way for a powershell module to get at its caller's scope?

I have a collection of utility functions and other code that I dot-source into every powershell file I write. Having gotten bit by caller scope variables influencing it, I started looking into changing it into a powershell module. I ran into…
aggieNick02
  • 2,557
  • 2
  • 23
  • 36
6
votes
2 answers

Cannot bind argument to parameter because it is an empty string

I am getting this error when calling a function from a module that I have created and imported into my main script: Run-RemoteScript : Cannot bind argument to parameter 'Targets' because it is an empty string. At C:\Scripts\Script.ps1:114…
Tobias KKS
  • 130
  • 1
  • 4
  • 17
6
votes
2 answers

Install-Package & NuGet Package install location - where installed to?

> nuget nuget : The term 'nuget' is not recognized as the name of a cmdlet, function, script file, or operable program. ... > find-package…
HankCa
  • 9,129
  • 8
  • 62
  • 83
6
votes
1 answer

Does #Requires work in module scripts?

Consider the following module script: MyWebApp.psm1: #Requires -Version 4 #Requires -Modules WebAdministration function Test-MyWebApp() { return ((Get-WebApplication 'myapp') -ne $null) } (Export-ModuleMember omitted for simplicity. The script…
jpmc26
  • 28,463
  • 14
  • 94
  • 146
6
votes
1 answer

PowerShell Use third party module without installing it

I am sure this would be possible but can't find anything useful. I have written a lan scanner script. To automate things as much as possible, I don't rely on any input from user. The script checks the local interface IP address and uses Indented…
Junaid
  • 583
  • 6
  • 19
6
votes
2 answers

Powershell not importing functions from module

I'm trying to setup a NuGet Feed here, and that worked ok. I installed a module from my feed via Install-Module -Name MyCmdlets -Repository $RepoName -Scope CurrentUser -Force Import-Module -Name MyCmdlets However when I run Get-Module, I get no…
5
votes
2 answers

How to cause Install-Module to also install any required modules?

I am working on a PS module, which depends on SqlServer. Here is the module manifest file: @{ ModuleVersion = "1.0.19103.11" GUID = "59bc8fa6-b480-4226-9bcc-ec243102f3cc" Author = "..." CompanyName = "..." Copyright = "..." …
mark
  • 59,016
  • 79
  • 296
  • 580
5
votes
3 answers

PowerShell project, where to put global settings?

We are building a bigger project with PowerShell (a collection of scripts/functions that helps us setup some SharePoint environments/tenants). A lot of the functions should reuse settings that are stored in a single, central place. I couldn't find a…
5
votes
1 answer

Powershell Binary Module not found but installed

I've created a Binary Powershell Module called ODBCManager. After installing from a feed, I am able to use it's functions successfully, but Get-Module does not find it by name (Get-Module -Name ODBCManager returns null). Get-Module -ListAvailable…
HyTC
  • 63
  • 2
  • 6
5
votes
1 answer

Can I package a CSV file as a module resource

I have a custom PowerShell module with a corresponding module manifest. In one command in my module I have a hard-coded array of hash tables. This was fine at first but occasionally I have to go back and add new hash tables to this hard-coded…
Jason Boyd
  • 6,839
  • 4
  • 29
  • 47
1
2
3
13 14