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
11
votes
2 answers

What is a PowerShell cmdlet?

Approaching cmdlets in a conceptual way, How are they made? Are they compiled? Is it the equivalent of a batch file for PowerShell? Is it a script or a binary? What is the structure used for storing these cmdlets?
citn
  • 1,522
  • 3
  • 18
  • 29
10
votes
4 answers

Enum parameter for powershell cmdlet

I'm writing a cmdlet (script) on powershell and I wanted to use eunm as one of the parameters. But I don't know where to put enum definition so that it would be visible for cmdlet parameters declaration. For example, I have a parameters definition…
Mak Sim
  • 2,148
  • 19
  • 30
10
votes
2 answers

How to propagate -Verbose to module functions?

According to answers like this one and my own experience, Powershell can take care of propagating -Verbose (and -Debug) automatically, which is very convenient. However this stops working when the functions which I want to propagate verbosity to are…
stijn
  • 34,664
  • 13
  • 111
  • 163
10
votes
4 answers

Determining internet connection using Powershell

Is there a simple cmdlet I can run in PowerShell to determine if my Windows machine is connected to the internet through Ethernet or through the wireless adapter? I know you can determine this on the GUI, I just want to know how this can be managed…
user1951756
  • 471
  • 1
  • 8
  • 23
9
votes
3 answers

Hosted PowerShell cannot see Cmdlets in the same Assembly

I'm trying to run PowerShell scripts from my C# code, that will use custom Cmdlets from the assembly that runs them. Here is the code: using System; using System.Management.Automation; [Cmdlet(VerbsCommon.Get,"Hello")] public class…
Idan Arye
  • 12,402
  • 5
  • 49
  • 68
9
votes
4 answers

Shorter versions of powershell cmdlet parameters

Given my research, I don't believe the following is easily accomplished, if at all. As a last resort, however, I figured I'd check here. In Powershell 2.0, I'd like a way to reduce the (annoyingly) long names of parameters to various cmdlets. I…
Larold
  • 640
  • 2
  • 8
  • 19
9
votes
3 answers

PowerShell - How do I call a cmdlet in a function when overriding that cmdlet's name with the same name as the function?

So I have a cmdlet named update-name that I have no access to change. I have created a function named update-name (the same name as the cmdlet). How do I call the cmdlet from the function with the same name? I've tried a few things and none of…
ferventcoder
  • 11,952
  • 3
  • 57
  • 90
9
votes
2 answers

Objects with no '.Count' Property - use of @() (array subexpression operator) vs. [Array] cast

I am trying to perform some simple if statements, but all of the newer cmdlets that are based upon [Microsoft.Management.Infrastructure.CimInstance] don't seem to expose a .count method? $Disks = Get-Disk $Disks.Count Doesn't return anything. I…
CobyCode
  • 193
  • 5
9
votes
1 answer

Invoke-RestMethod OutFile Empty When PassThru Used

Using PowerShell 4.0 and Invoke-RestMethod cmdlet. I'm having trouble with the -OutFile and -PassThru options. Whenever I add the -PassThru option, my -OutFile is created but the contents are Empty! According to the Invoke-RestMethod Documentation,…
Mister_Tom
  • 1,500
  • 1
  • 23
  • 36
9
votes
4 answers

PowerShell: Import-Module, but no "ExportedCommands" available

When I use Import-Module -Name -Verbose the cmdlets contained in the DLL file are not exported. Thus, when I type Get-Module my imported module is listed, but without any ExportedCommands. Why? ModuleType Name …
H. Seeger
  • 91
  • 1
  • 1
  • 4
9
votes
1 answer

Returning an object from PowerShell cmdlet

I'm trying to create my own set of cmdlets for a PowerShell snapin. The problem I'm having is that I've created my own object that I create and populate within the ProcessRecord method but I'm not able to change the return type to allow me to return…
user1865044
  • 301
  • 3
  • 9
9
votes
4 answers

Send administrative commands to my C# Windows Service using own PowerShell CmdLets

I have a C# Windows application which runs a service. I would like to leverage PowerShell in order to offer a command line management interface for administering my running service. From my point of view, I am trying to offer the same administrative…
Robert Mircea
  • 699
  • 2
  • 10
  • 18
9
votes
1 answer

Run parallel Invoke-WebRequest jobs in PowerShell v3

Running simultaneous background jobs in PowerShell in pretty straightforward, but I cannot seem to get it working with the new (in v3) cmdlet Invoke-WebRequest. I have several thousand files I am downloading scriptomagically via PowerShell. Works…
9
votes
3 answers

How to capture a Powershell CmdLet's verbose output when the CmdLet is programmatically Invoked from C#

BACKGROUND I am using Powershell 2.0 on Windows 7. I am writing a cmdlet in a Powershell module ("module" is new to Powershell 2.0). To test the cmdlet I am writing Unit tests in Visual Studio 2008 that programmatically invoke the…
namenlos
  • 5,111
  • 10
  • 38
  • 38
8
votes
2 answers

Using Powershell's Invoke-Command to call a batch file with arguments

I want to use Powershell in order to call a batch file on remote machines. This batch file has arguments. Here's what I have so far: $script = "\\fileshare\script.cmd" $server = $args[0] $args [string]::join(',',$args[1 ..…
Jay Spang
  • 2,013
  • 7
  • 27
  • 32
1 2
3
58 59