Questions tagged [powershell-4.0]

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

For general PowerShell information see the tag wiki.

Description of PowerShell-v4.0

Windows PowerShell Microsoft's strategic task automation platform for Windows, and includes a command-line shell and scripting language. PowerShell was designed especially for system administrators.

PowerShell 4.0 ships with Windows 8.1 and Windows 2012 R2 as a built-in package.

Availability

PowerShell 4.0 is also available as a download for Windows 7 SP1. http://www.microsoft.com/en-us/download/details.aspx?id=40855

Notable New Features in 4.0

Resources

A list of fetaures new and changed int Windows PowerShell is available here.

For latest news and development, check out the PowerShell blog

1951 questions
14
votes
2 answers

Extract value from JSON

I am trying to use PowerShell to extract value from JSON object, I have the following JSON: { "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { …
roy
  • 6,344
  • 24
  • 92
  • 174
14
votes
2 answers

Search on an Internet Explorer App Object

I have a InternetExplorer.Application I am creating an automation and one of the pages I opened, opened a dialog that looks like a new tab, but on the same process (I checked it by the task manager >> process tab that the same process just consumes…
Asaf Shazar
  • 1,065
  • 1
  • 11
  • 33
14
votes
2 answers

How do I resolve "Cannot invoke the SendConfigurationApply method." when performing Start-DscConfiguration?

Another way to phrase the question less specifically: What is the correct way to 'reset' the DSC processes on a target machine? I've created a DSC configuration that I'm iterating on right now, and I am adding new Package configuration which I've…
d3r3kk
  • 3,465
  • 3
  • 18
  • 22
13
votes
1 answer

PowerShell crashes when using ref parameter in .NET event

PowerShell crashes when an .NET-event with a ref parameter I've subscribed to, is invoked. I've reduced the problem to the following code. .NET: namespace PSEventTest { public delegate void BadHandler(ref string str); public class…
Jon List
  • 1,504
  • 1
  • 14
  • 20
12
votes
2 answers

Replace a character with new line

Powershell ver 4. Windows 7 I wanted to replace , with new lines in a text file. I tried the script below (Get-Content C:\Test\test.txt).Replace(',','`n') | Set-Content C:\Test\testv2.txt but when I see the output file I see , replaced with '`n'…
bobby789
  • 175
  • 1
  • 2
  • 7
12
votes
2 answers

How do I pass a local variable to a remote `Invoke-Command`?

I'm trying to retrieve the hash of a file located on remote server using Invoke-Command. It works fine when I give the full path as below: Invoke-Command -ComputerName winserver -ScriptBlock { Get-FileHash -Path E:\test\testfile.zip -Algorithm…
Bose
  • 143
  • 1
  • 2
  • 10
12
votes
3 answers

How can I query a temporary PS-Drive while returning files with a name relative to the drive?

I am trying to create a script where I will be searching the file servers for non inherited permissions. I have run into the 260 character limit for file names as a result. A suggestion I saw, that I thought would help, a couple of times was to…
Matt
  • 45,022
  • 8
  • 78
  • 119
12
votes
2 answers

Stopping PowerShell pipeline, ensure end is called

What I'm trying to do is get a function to stop the pipeline feed when a time limit has been reached. I've created a test function as follows : function Test-PipelineStuff { [cmdletbinding()] Param( …
campbell.rw
  • 1,366
  • 12
  • 22
11
votes
2 answers

How do you apply multiple DSC configurations?

Here's my example: $Config = @{ AllNodes = @( @{ NodeName = 'localhost'; PSDscAllowPlainTextPassword = $True } ) } Configuration LocalAdmin { Param([String[]]$Node='localhost',[PSCredential]$Cred) Import-DscResource…
Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63
11
votes
2 answers

how to create tar gz file using powershell

I'm searching for solution to solve problem with creating tar.gz archive using Powershell v4. I couldn't find extensions/packets created or verified by Microsoft to provide such functionality. Do such solutions exist [tar-ing and gzip-ing]?
user3376246
  • 413
  • 3
  • 9
  • 17
10
votes
2 answers

PsObject array in powershell

This is my code : $a = @() for ($i = 0; $i -lt 5; $i++) { $item = New-Object PSObject $item | Add-Member -type NoteProperty -Name 'Col1' -Value 'data1' $item | Add-Member -type NoteProperty -Name 'Col2' -Value 'data2' $item | Add-Member -type…
Adeel ASIF
  • 3,354
  • 9
  • 27
  • 44
10
votes
4 answers

Powershell - Regular Expression Multiple Matches

Maybe my reasoning is faulty, but I can't get this working. Here's my regex: (Device\s#\d(\n.*)*?(?=\n\s*Device\s#|\Z)) Try it: http://regex101.com/r/jQ6uC8/6 $getdevice is the input string. I'm getting this string from the Stream/Output from a…
Frankstar
  • 306
  • 1
  • 3
  • 10
9
votes
1 answer

Gitlab pipeline test stage to fail AND create artifacts anyway

I have a gitlab pipeline running on a windows machine with Windows 7 and powershell 4.0. The .yaml has the typical 3 stages: build, test and deploy. For the second stage I want to perform some simple tests that generate a log file which should be…
9
votes
1 answer

Invoke-Command faster than the command itself?

I was trying to measure some ways to write to files in PowerShell. No question about that but I don't understand why the first Measure-Command statement below takes longer to be executed than the 2nd statement. They are the same but in the second…
Ben
  • 93
  • 4
9
votes
1 answer

Replace string in powershell array

This is my array : $array who contains theses values :…
Adeel ASIF
  • 3,354
  • 9
  • 27
  • 44