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
0
votes
1 answer

Powershell: parametersets, require one or the other

Consider this Cmdlet (usings removed): public class Foo : Cmdlet { [Parameter(Mandatory = true, ParameterSetName = "Foo"] public string A { get; set; } [Parameter(Mandatory = true, ParameterSetName = "Bar"] public string B { get;…
Anemoia
  • 7,928
  • 7
  • 46
  • 71
0
votes
2 answers

Identify processes that have placed locks on a DLL using Powershell

Using powershell, I want to identify any process locks placed a given DLL. Solved. See below.
bartonm
  • 1,600
  • 3
  • 18
  • 30
0
votes
1 answer

How to troubleshoot "Get-WmiObject : Access is denied."?

I have two working powershell scripts. You would invoke script1.ps1 with: .\script1.ps1 "sender-ip=10.10.10.10" And the script is supposed to return userId=DOMAIN/UserId. The first script: #script1.ps1 $abc = $args $startInfo = $NULL $process =…
Glowie
  • 2,271
  • 21
  • 60
  • 104
0
votes
1 answer

The term 'connect-QADService' is not recognized as the name of a cmdlet... inside C# function

Can someone, please, help to understand why the following code inside a Csharp function Runspace runspace = RunspaceFactory.CreateRunspace(); runspace.Open(); Pipeline pipe = runspace.CreatePipeline(); Command connectToActDir = new…
rok
  • 9,403
  • 17
  • 70
  • 126
0
votes
0 answers

Memory size error when creating virtual machine in PowerShell C# codings

When I insert file path through my metro app (by browsing to the folder path), the value that I get (in the database) is the same as the below path whereby there's double slashes. Thus, it always give this error: An exception of type…
0
votes
1 answer

Calling a cmdlet with custom arguments

I have a powershell script which can be called by certain users. The script runs with some elevated permissions so I need to make sure they can't use it to bypass the intended behavior. One of the parameters to the script is a string which acts as…
Horatiu
  • 29
  • 3
0
votes
1 answer

Where is the "Invoke" member in System.Management.Automation.VerbsCommon?

I'm trying to create a cmdlet with the name Invoke-Something. But I cannot find the member "Invoke" to put in the attribute: [Cmdlet(VerbsCommon.Invoke, "Something", SupportsShouldProcess = true)] ^^^^^^ What am I missing?
Nestor
  • 13,706
  • 11
  • 78
  • 119
0
votes
1 answer

Can powershell Import-csv read from an variable location?

Just a simple question regarding how import-csv command is read. if I have something like this in ps (sorry first time poster, and I can't seem to indent block the script below): $ReadthisCSV = "C:\...\List.csv" Function Meh{ param ($readhere) …
0
votes
1 answer

Powershell Script - Services Running eq OK or list Services Not Running

I have this script which checks multiple servers for particular services running. I need assistance or pointers on how to get it to not pull back running / not running response. I need to get it to be "If all queried services are running = OK, if…
user2299515
0
votes
2 answers

ParameterSet doesn't work in custom PowerShell cmdlet in C#

I have the following code, where I try to create a custom Cmdlet for PowerShell using C#. What I want to do with my custom cmdlet is that, user should call it with two parameters, from which first one should be -Text or -File or -Dir, and the next…
user1726549
0
votes
0 answers

Getting "Operation is not valid due to the current state of the object" error for Exchange commands

I have an ASP.NET 3.5 application running Powershell scripts to add/update Exchange mailboxes. Most of the Powershell commands work great, but two of them so far have caused an error: get-calendarprocessing and set-calendarprocessing, which get or…
Kelly
  • 945
  • 2
  • 18
  • 31
0
votes
2 answers

cmdlet says parameter cannot be retrieved: expression must be readable

My cmdlet has a Get-Deal command, which will receive value from pipeline: [Cmdlet(VerbsCommon.Get, "Deal")] public class GetDealCmdlet : InsightBaseCmdlet { private List _legalentities = new List(); [Parameter(Position = 0,…
jamesdeath123
  • 4,268
  • 11
  • 52
  • 93
0
votes
2 answers

Durable variable in powershell

I wrote a powershell module in c# which allows me to call some webservices. Before I can use them, I have to specify where the service is located. For example: Set-ServiceUrl 'http://myService.cloudapp.net/' Create-Something ... Get-Something…
Martin Brandl
  • 56,134
  • 13
  • 133
  • 172
0
votes
2 answers

Powershell convert man page to html

Im a noob with Powershell, I need help converting a specific man page into an html document about_script my code is: get-help about_scripts | convertto-html > scr.html it creates an html page but it doesn't have most of the data in just the first…
0
votes
1 answer

Format-Table returning blank column

I'm having trouble only displaying the Time column for a command. Get-EventLog -log Security | where {$_.EventID -eq 4800 -or $_.EventID -eq 4801} returns: Index Time EntryType Source InstanceID Message …
m.edmondson
  • 30,382
  • 27
  • 123
  • 206