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

high memory consumption in powershell foreach loop

I am trying to write a powershell script that will take users from our oracle DB export (CSV) and use that to either update info in Active Directory or create new accounts (with the Quest AD cmdlets, set-qaduser). The script I have is working,…
0
votes
1 answer

how to open the windows explorer map network

Hi All, I need to be able to open the [Windows Explorer - Map Network Drive] popup using either VB or cmdlet. I tried using the code in both VB and cmdlet: System.Diagnostics.Process.Start("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL…
user2741620
  • 305
  • 2
  • 7
  • 21
0
votes
2 answers

Execute a file in multiple folders

I need a command BACH to allow me to run a file to multiple folders . This executable file is already copied these folders. for /D %i in (C:\Teste\*) do Paint.bat %i The above command did so, however , he runs paint.bat contained in the folder "…
Jones
  • 7
  • 4
0
votes
1 answer

Calling a cmdlet via a value

I have a variable in my psm1 file that's a KVP hash $subcmdlist = @{ "addhost" = "Add-Host"; "deletehost" = "Remove-Host"; "setparameter" = "Set-Parameter"; } This psm1 file also has a function called 'newtask' which accepts an argument of…
anoopb
  • 533
  • 4
  • 6
  • 20
0
votes
1 answer

Accept arbitrary parameters in c# PSCmdlet

I've written a bunch of classes that reach out to an API and get JSON. When compiled, I get nice commands like get-host, get-version, get-app, etc. each cmdlet takes an argument like -host or -app. I've got about 160 of these that I can write but…
anoopb
  • 533
  • 4
  • 6
  • 20
0
votes
2 answers

Run Exchange Management Shell cmdlets from Visual Basic/C#/.NET app

Goal: Provide a web service using Visual Basic or C# or .NET that interacts with the Exchange Management Shell, sending it commands to run cmdlets, and return the results as XML. (Note that we could use any lanaguage to write the service, but since…
coderintherye
  • 901
  • 1
  • 11
  • 20
0
votes
2 answers

Trying to invoke PSCmdlet class from within C#

At first, I tried to simply declare a new instance of cmdlet but got an error that indicated I couldn't invoke powershell cmdlets of type pscmdlet from within a cmdlet. in order to do this, i have to instantiate Powershell engine. PowerShell ps =…
anoopb
  • 533
  • 4
  • 6
  • 20
0
votes
3 answers

export powershell cmdlet as executable

Are windows power shell cmd lets stored on the computer as individual files or not. If so what is the extension of those files. If not is there a way to export them as individual files? this would be useful say if I only needed a few cmdlets I could…
user2912448
0
votes
1 answer

PowerShell: Another instance of Start-Process is already running

There are 2 PowerShell scripts that run at startup, 1 is in my control and the other is out of my control. Both of our scripts use Start-Process. Strange issue is if both of our Start-Process's happen to execute at the same time, I get the…
Vippy
  • 1,356
  • 3
  • 20
  • 30
0
votes
1 answer

Publish Azure Web Role : package not created

To create, configure and deploy my Azure Cloud PHP Services, I am using the cmdlets on Windows Azure Powershell. Via the 'Web platform Installer' tool, I updated the following programs : Windows Azure PowerShell - 0.8.8.1 Microsoft Azure SDK -…
0
votes
1 answer

How to pass parameters to a cmdlet from C#

I have some powershell scripts that I want to call from C#. From the commandline I would do this: Import-Module c:\provisioning\newModule.psm1 –Force Get-MTMailbox -customerID custid0001 This works and gives the correct result. I want to call my…
Megasaur
  • 626
  • 8
  • 20
0
votes
1 answer

Executing cmdlet Get-ClusterGroup from C#

Hi I'm trying to execute the Get-ClusterGroup cmdlet from C# 4.0. I've used the following code InitialSessionState iss = InitialSessionState.CreateDefault(); iss.ImportPSModule(new string[] { "failoverclusters"}); Runspace myRunSpace =…
0
votes
1 answer

IIS Command-lets

I am trying to add a IIS website via command-lets. What I currently have: ' User input Dim domainname As String = "niels_test" ' System vars Dim basePath As String = "C:\Projecten\Websites\" Dim finalDirname As String = basePath…
Niels
  • 48,601
  • 4
  • 62
  • 81
0
votes
1 answer

Adding config file for Cmdlet

I've made a powershell Cmdlet for creating an AppFabric a region, the code: [Cmdlet(VerbsCommon.New, "CacheRegion")] public class NewCacheRegion : Cmdlet { [Parameter(Mandatory = true, Position = 1)] public string Cache { get; set; } …
Serve Laurijssen
  • 9,266
  • 5
  • 45
  • 98
0
votes
2 answers

How to determine the name of the script that called my cmdlet?

In a powershell cmdlet that I am writing in C#, I need to get the name of the script that has called me. I have derived my cmdlet class from PSCmdlet; there is a ton of information attached to this class at runtime, but I don't see where I can get…
Tim Dowty
  • 1,460
  • 13
  • 9