Questions tagged [powershell-7.0]

Use this tag for version specific questions about Windows PowerShell version 7.0. When using this tag also include the more generic [powershell] tag where possible. For general PowerShell topics, use the [powershell] tag.

216 questions
3
votes
1 answer

Powershell - Invoke-RestMethod - POST nested JSON

I'm trying to interact with an API to POST some data to a service we use, in order to add some email addresses to a policy. This will eventually take a list of email addresses and loop through it for each one, but for now I'm just trying to get it…
Spencer
  • 33
  • 1
  • 4
3
votes
1 answer

Azure Function | PowerShell | Could not load type 'System.Security.Cryptography.SHA256Cng'

I have an azure function app with runtime version ~3 and powershell version 7.0 creating a connection to powerbi that is connecting to azure active directory. Import-Module -Name MicrosoftPowerBIMgmt $id=$user $password=$token |…
hagarwal
  • 1,153
  • 11
  • 27
3
votes
1 answer

What is the equivalent of 'nohup' in linux PowerShell?

I very well know existence of duplicate question. But that question is marked answered and I don't think it at all answers the original question. The $ nohup command keeps executing command even if the parent process (shell) of nohup dies. More info…
vmiheer
  • 147
  • 9
3
votes
1 answer

Error handling within Foreach-object Parallel block - Powershell 7

What would be the best way to capture error within below Foreach-Object Parallel block as there would be three separate threads/runspaces running and executing code written in the block and multiple errors/exception can occurs at the same time?…
user13624867
  • 225
  • 4
  • 14
3
votes
1 answer

Remove an attribute from the JSON object in powershell

I have following JSON and I would like to remove streets from the JSON object under Address which is an array. I am trying to do this in powershell { "Customer": [ { "id": "123" } ], "Nationality": [ { "name": "US", …
Learn AspNet
  • 1,192
  • 3
  • 34
  • 74
3
votes
2 answers

Powershell 7 Byte encoding an image file

I'm using PowerShell to upload files to a web site through an API. In PS5.1, this would get the image in the correct B64 encoding to be processed by the API at the other end: $b64 = [convert]::ToBase64String((get-content $image_path -encoding…
EnterpriseMike
  • 165
  • 2
  • 7
3
votes
1 answer

Can I Write-Warning in a powershell script without a newline at the end?

I want to print a Warning in PowerShell as a prompt and then read the answer on the same line. The problem is that Write-Warning prints a newline at the endof the message, and one alternative, Read-Host -Prompt, doesn't print the prompt to the…
xdhmoore
  • 8,935
  • 11
  • 47
  • 90
3
votes
1 answer

Why does VS Code PowerShell terminal map a new drive?

I was making a PowerShell script in Visual Studio Code that used the command Get-PSDrive, and to my surprise, it seemed like while using VS Code, a new drive identical to my C:\ drive called Temp appeared. I was taken aback by this result as as far…
3
votes
1 answer

Unable to use the "ForEach-Object -Parallel" in a directory with a name containing "["

Using the ForEach-Object -Parallel cmdlet in a directory with a name containing "[" will return a WildcardPatternException. Remove -Parallel, it will run successfully. I created a few directories and ran the following commands.1..5 | ForEach-Object…
2
votes
1 answer

Why do process blocks correctly return a hashtable, instead of an array of hashtables?

I am trying to sort some REST API responses and extract data from them, and found this helpful answer on how to end up with a hashtable at the end. $res= (Invoke-RestMethod @commonParams -uri "foo" -Method GET -FollowRelLink) | ForEach-Object { $_ }…
2
votes
2 answers

Set a PSObject path using an array for the "dot" variable names

I have a PSObject that I have filled with a json structure. I need to be able to set the value of one of the entries in the tree using an array that has the names nodes of the json path. Here is an example that gets close, but does not ultimately…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
2
votes
2 answers

Service 'McpManagementService (McpManagementService)' cannot be queried due to the following error:

I am trying to run this in PowerShell7 PS C:\Users\MYUSER> $myoutput = get-service| where-Object Status -eq "Stopped"| select-Object Name, Status However, I am getting the below error: Get-Service: Service 'McpManagementService…
Javi Torre
  • 724
  • 8
  • 23
2
votes
2 answers

How to fix Nuget Provider "Find-Module" Installation error with PowerShell 7.3?

I've been trying to run a PowerShell script, and upon doing so, I receive a message that NuGet Provider is required. NuGet provider is required to continue This version of PowerShellGet requires minimum version '2.8.5.201' of NuGet provider to…
Timothy G.
  • 6,335
  • 7
  • 30
  • 46
2
votes
0 answers

Converting extremely large JSON file to object

I have very large JSON files that I would like to explore the structure of before processing. Some of these can be in excess of 4-5 GB, but the one I've picked a smaller one just for exploration purposes. The bonus difficulty here is that the files…
2
votes
2 answers

Default Powershell Terminal is 7.2 but scripts run as Powershell 5.1

Notice in my VS Code, a fresh terminal, the very first line indicates it is properly defaulted to Powershell 7.2.2 - just as I believe it should. But then in this same screenshot, the first script I run (which has a command to print out the…
bkwdesign
  • 1,953
  • 2
  • 28
  • 50
1
2
3
14 15