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
80
votes
7 answers

How to execute .sql file using powershell?

I have a .sql file. I am trying to pass connection string details through a Powershell script and invoke an .sql file. I was searching and came up with a cmdlet related to Invoke-sqlcmd. While I was trying to find a module corresponding to SQL, I…
Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230
78
votes
3 answers

How do I force powershell to reload a custom module?

I have created a module 'ActiveDirectory.psm1' which contains a class in powershellv5. I am importing that module in another file called 'test.ps1' and then calling a method from the class. test.ps1 contains the following: using module…
S. Mitchell
  • 783
  • 1
  • 5
  • 6
46
votes
4 answers

PowerShell 5.1 - How to uninstall module which is currently use

We are using some PowerShell modules in one deployment PowerShell script. Using following command we are installing module (i.e. XXXX) into "C:\Program Files\WindowsPowerShell\Modules". Install-Module -Name "XXXX" -AllowClobber -RequiredVersion…
mit
  • 1,763
  • 4
  • 16
  • 27
19
votes
5 answers

Export Powershell 5 enum declaration from a Module

I have an enum type defined within a module. How do I export it to be accessible from outside once the module has been loaded? enum fruits { apple pie } function new-fruit { Param( [fruits]$myfruit ) write-host…
18
votes
2 answers

How do I debug a Windows PowerShell module in Visual Studio?

I'm trying to write a PowerShell module as a VB.NET project with Visual Studio 2015. I've been able to put a few commands together, compile the class library into a DLL, import the module into a PowerShell session and call the command I created. …
DavidM
  • 207
  • 1
  • 2
  • 6
17
votes
4 answers

Passing through -Verbose status to module cmdlets

I have a PowerShell module that encapsulates a number of commonly-used business functions. It's not generally called from the console; rather, its functions are called by automated deployment and management scripts that import the module. The module…
Dan
  • 385
  • 1
  • 2
  • 11
16
votes
7 answers

Powershell Remoting: using imported module cmdlets in a remote pssession

Is there a way to use modules that were imported in a local session in a remote session? I looked at import-pssession, but I don't know how to get the local session. Here's a sample of what I want to do. import-module…
15
votes
3 answers

Installing PowerShell module persistently for all users

I'm installing a PowerShell module via Octopus Deploy onto a number of different servers. For testing purposes, I went with the guidance of Microsoft's documentation for installing PowerShell Modules. This worked fine, but as the documentation…
Mike Bailey
  • 12,479
  • 14
  • 66
  • 123
14
votes
3 answers

How to install module into Custom directory?

Currently we are installing some modules using the command below, but it installs modules in C:\Program Files\WindowsPowerShell\Modules. Install-Module -Name XXX -RequiredVersion XXX -Repository XXX -Scope AllUsers Our requirement is to install…
mit
  • 1,763
  • 4
  • 16
  • 27
13
votes
3 answers

$_ variable used in function from a module is empty (PowerShell)

One question for you is here ;) I have this function: function Set-DbFile { param( [Parameter(ValueFromPipeline=$true)] [System.IO.FileInfo[]] $InputObject, [Parameter(ValueFromPipelineByPropertyName=$true)] …
stej
  • 28,745
  • 11
  • 71
  • 104
12
votes
3 answers

PowerShell module - separate file for each cmdlet

I've been strugling with this for a while now. I intend to create new PowerShell module for my project. Aim is to package several custom cmdlets into standalone unit, which I could deploy to other machines via our Nexus repository (or via anything…
Martinecko
  • 1,719
  • 4
  • 22
  • 35
12
votes
1 answer

How to reliably reference external .NET assemblies in a PowerShell v3 module?

I am working on a PowerShell v3 module that needs to work with Types which are contained in a few external .NET assemblies. I would like this module to be reasonably self-contained for ease of deployment and I do not want to rely on these assemblies…
syneptody
  • 1,250
  • 1
  • 10
  • 27
11
votes
2 answers

PowerShell Module Manifest - automatically loading a Required Module

I am creating a module that depends on several other modules that I need loaded into the global environment. I tried creating a script and using ScriptsToProcess to import the modules, but it looks like the check for RequiredModules happens before…
Andy Schneider
  • 8,516
  • 6
  • 36
  • 52
9
votes
3 answers

Use GitHub package registry as a PowerShell package repository

As far as I know a PowerShell repository is a NuGet repository... GitHub just released their package registry, which my company currently uses for npm, but also has an endpoint for NuGet. I can access the NuGet endpoint…
8
votes
1 answer

PowerShell dot source within a dot sourced file - import classes

My project is structured like this: MyScript.ps1 classes\ Car.ps1 Tesla.ps1 Car.ps1 is the base class of Tesla.ps1. I attempt to define Tesla like this in Tesla.ps1: . "$PSScriptRoot\Car.ps1" class Tesla : Car { } MyScript.ps1 needs to…
Jonathan Eckman
  • 2,071
  • 3
  • 23
  • 49
1
2 3
13 14