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…
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…
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.
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…
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…
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?
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…
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…
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…
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,…
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…
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 =…
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…
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…
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,…