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

How can I provide a tab completion list, with the values generated on powershell startup?

So I have a cmdlet written in c#: Get-LivingCharacter. I want users to use this like Get-LivingCharacter -Name "Bran", but I would like to allow for the list of available characters to change. Maybe today, "Bran" is a valid name to pass in for…
Rollie
  • 4,391
  • 3
  • 33
  • 55
0
votes
2 answers

Passing a cmdlet as a parameter

I need to restart a service in a powershell script. The problem is that this service is a bit buggy and frequently needs to be shut down several times before it gets into the "stopped" state. Because of that I can't seem to use the Restart-Service…
0
votes
3 answers

Pass -WhatIf flag to all cmdlets being called in powershell script

I have a test powershell script that I am trying to get the whatif flag passed to all cmdlets in the script. In my script I am calling 3 cmdlets new-Item, copy-item and new-customCmdlet. The last one is a custom cmdlet that I wrote. I have…
0
votes
2 answers

How to pass a custom enum to a function in powershell

When defining a function, how can you reference a custom enum? Here's what I'm trying: Add-Type -TypeDefinition @" namespace JB { public enum InternetZones { Computer ,LocalIntranet ,TrustedSites …
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
0
votes
1 answer

powershell: can I string together unrelated cmdlets?

I have powershell script that works, but I'd like to see if there is a better way to accomplish this task. Right now I am using several different if statements followed by script blocks containing one cmdlet each. Is there a way to put these…
0
votes
2 answers

PowerShell : add date and time in filename

I made a powershell script which is following $Now = Get-Date $Days = "1" $TargetFolder = "D:\DatabaseBackup" $Extension = "*.bak" $LastWrite = $Now.AddDays(-$Days) $Files = Get-Childitem $TargetFolder -Include $Extension -Recurse | Where …
Ancient
  • 3,007
  • 14
  • 55
  • 104
0
votes
2 answers

Azure Powershell cmdlets fails

I have requirement to configure secondary interface on azure vm.For this we require Add-AzureNetworkInterfaceConfig cmdlets which is not recognized when i am executing the command.Could someone help me to install cmdlets on azure powershell.
0
votes
1 answer

Powershell Unable to compare MD5 values from file with MD5 values generated

I have generated the list of MD5 checksum values from a directory within my project using Powershell's Get-FileHash function and then I exported the values to a .csv file. $path = "C:\Users\Krishnaa\Documents\Visual Studio…
user3056928
  • 55
  • 3
  • 6
0
votes
2 answers

Powershell Sharepoint snapin when not on the sharepoint server

I am new to both powershell and sharepoint, and I need to make script to automate the removal and uploading of attachments from outlook to sharepoint. I have easily completed the first part of extracting the attachment, however the uploading to…
0
votes
0 answers

Adding a printer to multiple workstations with PowerShell

I am trying to figure out a way to add a printer to multiple workstations. I found the below script which should be able to accomplish this but I run into an error (Exception calling "Put" with "0" argument(s): "Generic failure ") which I will…
0
votes
2 answers

Ignore first line in FINDSTR search

I am searching an object-oriented Modelica library for a certain string using the following command in the Windows 7 PowerShell: findstr /s /m /i "Searchstring.*" *.* click for findstr documentation The library consists of several folders…
Jay_At_Play
  • 136
  • 10
0
votes
1 answer

Unknown error - cmdlet Invoke-SCScript

So this is what I have (full add-in code): using Microsoft.SystemCenter.VirtualMachineManager; using Microsoft.SystemCenter.VirtualMachineManager.UIAddIns; using Microsoft.SystemCenter.VirtualMachineManager.UIAddIns.ContextTypes; using…
000000000000000000000
  • 1,467
  • 1
  • 19
  • 38
0
votes
1 answer

Why is this object treated differently when passed using pipeline vs named parameters?

I have been naïvely assuming that an object passed to a commandlet using PowerShell's pipeline parameter binding is treated the same as passing it using named parameters. However, the following script seems to demonstrate there is a…
alx9r
  • 3,675
  • 4
  • 26
  • 55
0
votes
2 answers

using POWERShell CmdLet to list installed Software and extract software name

I have a POWERSHELL script to check the presence of a predefined list of software: $SoftList = "Microsoft Visual C++ 2005 Redistributable","TotoInexistant","GIMP 2.6.11" define the list of software im looking to check. i use a loop to compare…
Nabil
  • 41
  • 3
  • 10
0
votes
1 answer

How do I call WriteObject() of Cmdlet class to output objects with different types?

Right now I'm calling WriteObject(identities1, enumerateCollection:true) first and then WriteObject(identities2, enumerateCollection:true). If identities1 and identities2 are the same type, the output looks okay. But if they are different types, the…
Dan Liu
  • 812
  • 5
  • 1