Questions tagged [powershell-cmdlet]

Quote from Microsoft site: "A cmdlet is a lightweight command that is used in the PowerShell environment. The PowerShell runtime invokes these cmdlets within the context of automation scripts that are provided at the command line. The PowerShell runtime also invokes them programmatically through PowerShell APIs"

Ref: Cmdlet Overview

882 questions
18
votes
3 answers

Can I write PowerShell binary cmdlet with .NET Core?

I'm trying to create a basic PowerShell Module with a binary Cmdlet internals, cause writing things in PowerShell only doesn't look as convenient as in C#. Following this guide, it looks like I have to: add Microsoft.PowerShell.SDK to my…
brutallord
  • 861
  • 2
  • 11
  • 16
18
votes
1 answer

Powershell 3.0: COPY-ITEM Filter or Include options not working

Does the -Filter or -Include parameter work for anyone when using Powershell 3.0? I've tried both of the following commands: Copy-Item -Path c:\temp -Include "*.TXT" -Destination C:\temp2 and Copy-Item -Path c:\temp -Filter "*.TXT" -Destination…
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56
17
votes
2 answers

Calling Powershell functions from C#

I have a PS1 file with multiple Powershell functions in it. I need to create a static DLL that reads all the functions and their definitions in memory. It then invokes one of these functions when a user calls the DLL and passes in the function name…
Sean
  • 171
  • 1
  • 1
  • 3
17
votes
1 answer

Why are scripted cmdlets listed as functions?

If I create a simple Powershell function e.g. Function Hello { [CmdletBinding( )] Param ( [parameter()] $Name ) Begin{} Process{ Write-Output "Hello $Name" } End{} } then use Get-Command to…
peterot
  • 283
  • 2
  • 9
17
votes
2 answers

How do I add a PowerShell cmdlet or function to my machine so that it is always available?

If I find (or create) a new PowerShell cmdlet (or function), how do I add it to my machine? Do I copy it to a particular folder? Do I put its content in a particular file? Do I need to authorize it, or sign it, or give it permission in some way? I…
Leon Bambrick
  • 26,009
  • 9
  • 51
  • 75
15
votes
13 answers

What are your favorite Powershell Cmdlets?

I just found /n softwares free Powershell NetCmdlets, and after playing with them I love the functionality they bring to the command line. So it raises the question what are your favorite Cmdlets, and how do you use them?
Nick Berardi
  • 54,393
  • 15
  • 113
  • 135
14
votes
7 answers

Get a list of all Resources in my Azure Subscription (Powershell Preferably)

I have an azure subscription and I'm trying to write a powershell script to automatically get a list of all the resources (VMs, Storage Accounts, Databases, etc) that I currently have in my subscription. Is there a way to do this using the azure…
13
votes
2 answers

PowerShell Advanced Function get current ParameterSetName

In C# you can get the current ParameterSetName in the ProcessRecord override of a PowerShell Cmdlet with code like this: switch (ParameterSetName) { case FromUriParamSetName: loadFromUri(); break; case…
Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
13
votes
2 answers

Powershell scripting: recommended way to implement ShouldProcess when function calls are nested?

Test script: function outer { [cmdletbinding(supportsshouldprocess=$true)] param($s) process { $pscmdlet.shouldprocess("outer $s", "ShouldProcess") | out-null "" | out-file "outer $s" inner…
Richard Berg
  • 20,629
  • 2
  • 66
  • 86
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
2 answers

Reading event log remotely with Get-EventLog in Powershell

I've a powershell script which runs on server(test-server) and reads the log file of his client(DC1). Both sides can ping to each other. On both sides, firewalls are disabled. Remote Desktop and Remote Assistance are enabled on DC1. Get-EventLog…
Korki Korkig
  • 2,736
  • 9
  • 34
  • 51
12
votes
2 answers

In Custom C# PowerShell Cmdlet Identify If -Verbose Was Specified

I have a custom C# PowerShell Cmdlet (inheriting from the Cmdlet base class) and I want to be able to identify if the "-Verbose" parameter was specified when running the Cmdlet. I realize that WriteVerbose will output when the -Verbose parameter is…
John Chapman
  • 878
  • 3
  • 14
  • 28
11
votes
1 answer

Writing PowerShell CmdLets in Python Dynamically

I want to be able to write PowerShell CmdLets using IronPython, and furthermore I need one CmdLet to look at the environment and add CmdLets to the PowerShell based on the contents. For example, reading a directory, and adding a CmdLet Remove- for…
moshez
  • 36,202
  • 1
  • 22
  • 14
11
votes
2 answers

Powershell cmdlets development best practices

I'm currently putting together some Powershell cmdlets. Building them is easy enough but I don't know if I'm building them in an acceptable manner (so to speak). Are there any guidelines/best practices that one should follow for passing data into…
Jamie Thomson
11
votes
7 answers

Problems debugging a PowerShell cmdlet

I'm using Visual Studio 2010 on Windows 7 64-bit Professional. I'm having trouble debugging a custom PowerShell cmdlet. Configuration Language: C#, targeting .NET Framework 3.5 SP1. Platform target: Any CPU Start Action:…
Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
1
2
3
58 59