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

How to set help information for pscmdlet class

I'm writing a powershell module in c# that's comprised of a bunch of powershell cmdlets. for example: get-application When I declare the class [Cmdlet(VerbsCommon.Get, "Application")] public class GetApplication : PSCmdlet I can do things…
anoopb
  • 533
  • 4
  • 6
  • 20
7
votes
1 answer

How can I change the default confirmation option for a PowerShell Cmdlet?

Is there a way to change the default confirmation option for a High Impact PowerShell script? When I implement a Cmdlet and run it asking for Confirmation like MyPS Confirm Are you sure you want to perform this action? Performing operation…
user3006883
  • 71
  • 1
  • 2
7
votes
2 answers

Interoping With PowerShell CmdLets

I've been writing some utilities that make use of PowerShell Cmdlets for App-V. The interesting part is Microsoft seems to only document the cmdlets and not the .net assemblies used behind the Powershell modules. Now I'm familiar with P/Invoke and…
Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
7
votes
4 answers

Is there any tool that can do c# code to powershell

I was wondering if there is an online tool that can convert c# code to powershell cmdlet code. I have following code that i need to have it powershell. I dont have visual studio to turn this into an exe or dll. any help or ideas would be…
torres
  • 1,283
  • 8
  • 21
  • 30
7
votes
2 answers

Changing powershell pipeline type to hashtable (or any other enumerable type)

I like to write a cmdlet "Convert-ToHashTable" which performs following task: $HashTable = Import-Csv Table.csv | Convert-ToHashTable Import-csv places an array on the pipeline, how can i change it to a hashtable in my Convert-ToHashTable cmdlet? …
Thomas Maierhofer
  • 2,665
  • 18
  • 33
6
votes
1 answer

flutter desktop application "error MSB3073: The command "setlocal "

I was building a flutter desktop app using vs code and all sudden was presented with this error completely unfamiliar with. anyone with a solution on how to handle this, I appreciate following is my flutter doctor log:
6
votes
3 answers

Is there an powershell cmdlet equivalent of [System.IO.Path]::GetFullPath($fileName); when $fileName doesn't exist?

If $fileName exists then the cmdlet equivalent of [System.IO.Path]::GetFullPath($fileName); is (Get-Item $fileName).FullName. However, an exception is thrown if the path does not exist. Is their another cmdlet I am missing? Join-Path is not…
Justin Dearing
  • 14,270
  • 22
  • 88
  • 161
6
votes
1 answer

Write-Information does not show in a file transcribed by Start-Transcript

I'm using PowerShell 5.1 and I am trying to determine why Write-Information messages do not show in the transcript log created by Start-Transcript unless I set $InformationPreference to SilentlyContinue. I want to both display the messages in the…
6
votes
2 answers

Service Fabric/Jenkins integration issue

I am trying to automate deployment to Azure Service Fabric with Jenkins and ServiceFabric PowerShell extension. Jenkins ServiceFabric plugin is not a good option in my case due to lack of control and flexibility over deployment process. I've faced…
6
votes
1 answer

Powershell String Length Validation

I created a really simple HelloWorld.ps1 Power-shell script which accepts a Name parameter, validates its length and then prints a hello message, for example if you pass John as Name, it's supposed to print Hello John!. Here is the Power-shell…
Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
6
votes
2 answers

In Powershell, Invoke-expression is not working when entering space in the path

I have a query like when I try to execute the expression which contains a path with space, I am getting an error as below. Code: $path="E:\Test\My space\Log" Invoke-Expression $path E:\Test\My: The term 'E:\test\My' is not recognized as the name…
Bharathi
  • 61
  • 1
  • 4
6
votes
2 answers

Powershell not importing functions from module

I'm trying to setup a NuGet Feed here, and that worked ok. I installed a module from my feed via Install-Module -Name MyCmdlets -Repository $RepoName -Scope CurrentUser -Force Import-Module -Name MyCmdlets However when I run Get-Module, I get no…
6
votes
2 answers

The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet

I have a solution with two project, one is the main project and the second a project that will use EF Core 10.0 RC2. In the second project I use this three commands to install EF Core and run this nuget commands to install it: Install-Package…
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
6
votes
5 answers

Join two results in Powershell

I've got two CMDlets that return lists of objects. One returns objects of the type SPSolution, which contains the property Id, the other returns objects of the type SPFeature with a property SolutionId. Now I want to join/merge this data something…
Hinek
  • 9,519
  • 12
  • 52
  • 74
6
votes
2 answers

Automatically Removing a PowerShell Job when it has finished (asynchronously)

I have a PowerShell cmdlet which I use to simplify connecting to another computer with RDP. Within that cmdlet I run do the following: if ($null -ne $Username -and $null -ne $Password) { Start-Process -FilePath "cmdkey.exe" -ArgumentList…
Paul
  • 3,125
  • 2
  • 24
  • 21