Questions tagged [powershell-3.0]

For topics and problems related specifically to Windows PowerShell 3.0. PowerShell 3.0 shipped with the releases of Windows 8 and Windows Server 2012. It is available as a download for Windows 7 and Windows Server 2008 R2. For general PowerShell topics, use the `PowerShell` tag.

For general PowerShell information see the tag wiki.

Description of PowerShell-v3.0

Version 3.0 of Windows PowerShell, Microsoft's task automation and configuration management platform that functions as an interactive command shell and a scripting language. For general information about Windows PowerShell, see the Tag Info page for the tag.

Availability

PowerShell 3.0 is included in Windows 8 and Windows Server 2012. It is available as a download for Windows 7 and Windows Server 2008 R2 with Service Pack 1 by installing either Windows Management Framework 3.0 or Microsoft .NET Framework 4.0 or 4.5 (PowerShell 2.0 is included in those versions of Windows).

Tag Usage

The tag should be used in conjunction with the tag for questions that involve features that are specific to version 3.0. It is also acceptable, although not necessary, to add this tag to indicate which version you are working with even if the question is not necessarily specific to this version.

Regardless of whether the version-specific tag is included, the general tag should be included in all PowerShell-related questions, as the version-specific tags have low visibility by themselves.

Resources

3438 questions
227
votes
11 answers

Delete files older than 15 days using PowerShell

I would like to delete only the files that were created more than 15 days ago in a particular folder. How could I do this using PowerShell?
user2470170
  • 2,320
  • 2
  • 13
  • 8
176
votes
7 answers

Check if a file exists or not in Windows PowerShell?

I have this script which compares files in two areas of the disk and copies the latest file over the one with the older modified date. $filestowatch=get-content C:\H\files-to-watch.txt $adminFiles=dir C:\H\admin\admin -recurse | ? {…
Samantha J T Star
  • 30,952
  • 84
  • 245
  • 427
172
votes
11 answers

How to load assemblies in PowerShell?

The following PowerShell code #Get a server object which corresponds to the default instance $srv = New-Object -TypeName Microsoft.SqlServer.Management.SMO.Server ... rest of the script ... Gives the following error message: New-Object : Cannot…
Baxter
  • 3,035
  • 3
  • 20
  • 15
137
votes
18 answers

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 ... $members = Get-Member -InputObject $myobject and then foreach through the $members, but is there a function to test if the object has a specific property? Additional…
SteveC
  • 15,808
  • 23
  • 102
  • 173
117
votes
7 answers

How to upgrade PowerShell version from 2.0 to 3.0

The OS that I am using is Windows 7, and the PowerShell version that is installed here is 2.0. Is it possible for me to upgrade it to version 3.0 or 4.0? Because there are cmdlets that version 2.0 can't recognize.
Teppie
  • 1,171
  • 2
  • 8
  • 3
114
votes
6 answers

Powershell - Why is Using Invoke-WebRequest Much Slower Than a Browser Download?

I use Powershell's Invoke-WebRequest method to download a file from Amazon S3 to my Windows EC2 instance. If I download the file using Chrome, I am able to download a 200 MB file in 5 seconds. The same download in PowerShell using Invoke-WebRequest…
Lloyd Banks
  • 35,740
  • 58
  • 156
  • 248
103
votes
6 answers

PowerShell : retrieve JSON object by field value

Consider JSON in this format : "Stuffs": [ { "Name": "Darts", "Type": "Fun Stuff" }, { "Name": "Clean Toilet", "Type": "Boring Stuff" } ] In PowerShell 3, we can obtain a list of Stuffs : $JSON =…
BaltoStar
  • 8,165
  • 17
  • 59
  • 91
89
votes
2 answers

Hide progress of Invoke-WebRequest

How can I hide the progress display of Invoke-WebRequest? I do a lot of successive requests and have my own Write-Progress display that I use, so I don't need the built-in one popping up underneath it every time. I use the mshtml results (the IE COM…
qJake
  • 16,821
  • 17
  • 83
  • 135
70
votes
6 answers

Install NuGet via PowerShell script

As far as I can tell, NuGet is meant to be installed as a Visual Studio extension: http://docs.nuget.org/docs/start-here/installing-nuget But what if I need NuGet on a machine that doesn't have VS installed? Specifically, I would like to install…
BaltoStar
  • 8,165
  • 17
  • 59
  • 91
68
votes
6 answers

PowerShell To Set Folder Permissions

I am trying to use the "default" options in applying folder permissions; by that, I mean that using the "Full Controll, Write, Read, etc" in the 'Properties' for a folder. The following script works to add the user in, but it applies "Special…
The Woo
  • 17,809
  • 26
  • 57
  • 71
67
votes
7 answers

How can I extract "Path to executable" of all services with PowerShell

Get-Service *sql* | sort DisplayName | out-file c:/servicelist.txt I have a one line PowerShell script to extract list of all services running on my local machine, now, in addition to displaying "Status", "Name" and "DisplayName" I also want to…
Abilash A
  • 951
  • 2
  • 8
  • 14
65
votes
5 answers

Prettify json in powershell 3

Given a standard json string value: $jsonString = '{ "baz": "quuz", "cow": [ "moo", "cud" ], "foo": "bar" }' How can I get this to be all pretty with newlines, preferably without brute-force regex? Simplest method I've found so far is: $jsonString…
Eris
  • 7,378
  • 1
  • 30
  • 45
64
votes
2 answers

How do I update JSON file using PowerShell

I have one json file mytest.json like below I want to update values using PowerShell script update.json { "update": [ { "Name": "test1", "Version": "2.1" }, { "Name": "test2", …
Neo
  • 15,491
  • 59
  • 215
  • 405
64
votes
8 answers

List of all colors available for PowerShell?

I am searching for a list of all colors I can use in PowerShell. Since we need to provide names and no hexnumbers, it's hard to figure out if a color exists or not, at least if you don't know how :)) For example, as -foregroundcolor write-host…
RayofCommand
  • 4,054
  • 17
  • 56
  • 92
64
votes
9 answers

ConvertTo-JSON an array with a single item

I'm trying to create a JSON-serialized array. When that array contains only one item I get a string, not an array of strings (in JSON). Multiple Items (works as expected): PS C:\> @("one", "two") | ConvertTo-JSON [ "one", "two" ] Single…
Luggage
  • 1,676
  • 1
  • 19
  • 22
1
2 3
99 100