tagged [powershell]

In Custom C# PowerShell Cmdlet Identify If -Verbose Was Specified

In Custom C# PowerShell Cmdlet Identify If -Verbose Was Specified I have a custom C# PowerShell Cmdlet (inheriting from the Cmdlet base class) and I want to be able to identify if the "-Verbose" param...

1 Oct at 16:56

Calling Powershell functions from C#

Calling Powershell functions from C# I have a PS1 file with multiple Powershell functions in it. I need to create a static DLL that reads all the functions and their definitions in memory. It then inv...

14 Nov at 19:53

GetType used in PowerShell, difference between variables

GetType used in PowerShell, difference between variables What is the difference between variables `$a` and `$b`? I tried to check ``` $a.GetType $b.GetType MemberType : Method OverloadDefinitions ...

19 Feb at 14:6

PowerShell The term is not recognized as cmdlet function script file or operable program

PowerShell The term is not recognized as cmdlet function script file or operable program I am implementing a script in powershell and getting the below error. The sceen shot is there exactly what I en...

Using PowerShell credentials without being prompted for a password

Using PowerShell credentials without being prompted for a password I'd like to restart a remote computer that belongs to a domain. I have an administrator account but I don't know how to use it from p...

5 Jun at 00:52

How can you test if an object has a specific property?

How can you test if an object has a specific property? How can you test if an object has a specific property? Appreciate I can do ... and then `foreach` through the `$members`, but is there a function...

22 May at 11:5

What's the best way to determine the location of the current PowerShell script?

What's the best way to determine the location of the current PowerShell script? Whenever I need to reference a common module or script, I like to use paths relative to the current script file. That wa...

21 Oct at 23:3

How to get disk capacity and free space of remote computer

How to get disk capacity and free space of remote computer I have this one-liner: and the output is this: ``` DeviceID : A: DriveType : 2 ProviderName : FreeSpace : Size : VolumeName : Device...

15 Jun at 15:44

Using Get-childitem to get a list of files modified in the last 3 days

Using Get-childitem to get a list of files modified in the last 3 days Code as it is at the moment Essentially what I am trying to do is get a list of all PST files in the folder above based on them b...

28 Jun at 14:10

How do I persist Powershell provider drive information?

How do I persist Powershell provider drive information? In my Powershell provider, which is a business-logic layer over an SQL database, the Powershell drives equate to database connection settings. T...

PowerShell : retrieve JSON object by field value

PowerShell : retrieve JSON object by field value Consider JSON in this format : In PowerShell 3, we can obtain a list of Stuffs : Assuming we don't know

16 May at 11:11

Executing an EXE file using a PowerShell script

Executing an EXE file using a PowerShell script I'm trying to execute an EXE file using a PowerShell script. If I use the command line it works without a problem (first I supply the name of the execut...

11 Jul at 23:7

Does PowerShell compile scripts?

Does PowerShell compile scripts? Suppose I have a simple PowerShell script: - - - - - -

10 Dec at 13:0

How to create a zip archive with PowerShell?

How to create a zip archive with PowerShell? Is it possible to create a zip archive using PowerShell?

9 Feb at 20:24

What does $_ mean in PowerShell?

What does $_ mean in PowerShell? I've seen the following a lot in PowerShell, but what does it do exactly?

1 Feb at 19:54

When should I use Write-Error vs. Throw? Terminating vs. non-terminating errors

When should I use Write-Error vs. Throw? Terminating vs. non-terminating errors Looking at a Get-WebFile script over on PoshCode, [http://poshcode.org/3226](http://poshcode.org/3226), I noticed this s...

Install-Module : The term 'Install-Module' is not recognized as the name of a cmdlet

Install-Module : The term 'Install-Module' is not recognized as the name of a cmdlet I was trying to install Azure using `Install-Module Azure` in PowerShell. I got the following error: ``` PS C:\Wind...

Concisely parsing a pipe

Concisely parsing a pipe I have lots of text output from a tool that I want to parse in Powershell 2.0. The output is nicely formatted so I can construct a regex to pull out the data I want using sele...

1 Jul at 09:4

How do I get the localhost name in PowerShell?

How do I get the localhost name in PowerShell? How do I get the localhost (machine) name in PowerShell? I am using PowerShell 1.0.

16 Feb at 16:32

Determine installed PowerShell version

Determine installed PowerShell version How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all?

6 Dec at 14:49

Powershell Multidimensional Arrays

Powershell Multidimensional Arrays I have a way of doing Arrays in other languagues like this: This generates an error.

24 Jun at 02:14

Removing duplicate values from a PowerShell array

Removing duplicate values from a PowerShell array How can I remove duplicates from a PowerShell array?

6 Mar at 07:59

Upload files with FTP using PowerShell

Upload files with FTP using PowerShell I want to use PowerShell to transfer files with FTP to an anonymous FTP server. I would not use any extra packages. How?

19 Oct at 14:28

How do you run a SQL Server query from PowerShell?

How do you run a SQL Server query from PowerShell? Is there a way to execute an arbitrary query on a SQL Server using Powershell on my local machine?

7 Dec at 22:27

Capturing Powershell output in C# after Pipeline.Invoke throws

Capturing Powershell output in C# after Pipeline.Invoke throws I'm running a Powershell test script from a C# application. The script can fail due to a bad cmdlet which causes pipe.Invoke() to throw a...

7 Aug at 13:39