Questions tagged [powershell-v6.0]

For issues related to the open source PowerShell 6.0

Resources:

  1. github project
  2. PowerShell Documentation
55 questions
2
votes
1 answer

PowerShell -is operator always matching PSCustomObject when used in ForEach-Object

Using PowerShell Core 6.1 on Mac. It appears that piping an array to ForEach-Object is modifying or wrapping each element such that the -is operator considers all of them to be PSCustomObjects. Let me demonstrate: Set up an array of four items of…
user221592
  • 361
  • 1
  • 10
2
votes
1 answer

How can I get the number of bytes in a newline from PowerShell?

DOS/Windows newline is two (2) bytes, 0x0D0A. UNIX/Linux newline is one (1) byte, 0x0A. Mac newline is one (1) byte, 0x0D. How can I write code to find the length of a newline on each platform? Output on Windows will produce two (2) bytes, but…
lit
  • 14,456
  • 10
  • 65
  • 119
2
votes
2 answers

How is the efficiency of Test-Path affected by using the -PathType parameter?

Does using the -PathType argument to specify a Leaf or Container have any impact on the efficiency of the Test-Path cmdlet? More an academic question as I can't imagine any gain here being anything other than negligible.
Mackles
  • 23
  • 3
2
votes
3 answers

PowerShell 6 - support for Windows GUI libraries

I understand that the new PowerShell 6/core lacks support for Windows GUI libraries, I have developed some important projects in PS-5.1 using the Windows.Forms .NET classes. Problem: We are planning to upgrade to PowerShell 6 this summer, which…
Eddie Kumar
  • 1,216
  • 18
  • 20
2
votes
2 answers

Cannot set default terminal to PowerShell 6.0

I am trying to set the default terminal in vscode to PowerShell 6.0. However, after restarting vscode, the following message appears and a terminal is not started. ERROR e.executable.toLowerCase is not a function Here is the user settings override…
lit
  • 14,456
  • 10
  • 65
  • 119
1
vote
2 answers

Ignore CTRL+C in delay - powershell

Whenever I set a delay in powershell using Start-Sleep, e.g: Start-Sleep 10 then it does not ignore CTRLC. I mean when I hit that key stroke the delay quits. How can I ignore it in delays?
Wasif
  • 14,755
  • 3
  • 14
  • 34
1
vote
1 answer

Alternative to Get-Service for Remote Computer in Powershell V6.0

I have a script that uses Get-Service to see if a particular service exists and is running on a group of computers. Get-Service -Name "ServiceName" -Computername "PCName" In Powershell V6.0 the Get-Service cmdlet doesn't have the -Computername…
1
vote
1 answer

Powershell 6.2 and Get-CimInstance to remotely stop/start/restart service issues

So I am at a big roadblock right now. I was working in PowerShell 5.1 and had the Get-WmiObject with the Win32_Service Class working perfectly fine to remotely stop/start/restart services remotely. However, I found out that the .StopService() method…
1
vote
1 answer

Is using Select-Object suitable when you don't have access to -Extension?

In Powershell v6, the split-path has the -Extension parameter to access the extension of a file name, for example: $pathToResume = "R:\Work\cover.letter_resume_base.odt" $extension = Split-Path -Extension $pathtoResume Write-Output $extension # Will…
user11247457
1
vote
1 answer

Why is the error handling in powershell ISE and command line different?

I have a powershell script that uses azure cli to log in and do a bunch of other stuff. At the beginning I set $ErrorActionPreference = "Stop" When I run the script in the ps ISE and the azure login fails the error is displayed and execution stops,…
srudin
  • 261
  • 2
  • 13
1
vote
3 answers

How to column print only certain row parts of a list in powershell?

I have tried various ways to format the output from a poweshell command and would like to print only some of the row items in the list as part of a a column in one line. Perhaps more easy to illustrate: # I want the output from: Get-CimInstance…
not2qubit
  • 14,531
  • 8
  • 95
  • 135
1
vote
2 answers

Trying to pull information from webpage

I am trying to pull data from a website. In my example case, I am running a search on Armorgames.com for the search term idle. From there I would like to pull the name of each game and put it into a csv file for use later. My code: $SearchResult =…
James Hardy
  • 21
  • 1
  • 5
1
vote
0 answers

How can you get Powershell to interact with elements on a webpage

I am trying to write a Powershell script that will interact with elements of a webpage. To learn the concepts for the script, I am using Armorgames.com as the target url with my aim to use powershell to log into the site, then make a search of…
1
vote
3 answers

Find all IP addresses from array

I have a lot of arrays which looks like $a = 'Handshake', 'Success', 'Status', 200, '192.30.253.113', 'OK', 0xF Information contained in this array may be different but there are IP addresses always in it (one or more, maximum three). I looking for…
user9171470
1
vote
0 answers

PowerShell 6 ApartmentState

I've seen a few questions on here, but have not seen any response. I have a class file that displays a script progress window and it works fine in PowerShell version 5.1.15063.966 but it fails in PWSH version 6.0.2 . I'm not sure if it's relevant,…
Paul Young
  • 37
  • 7