Questions tagged [powershell-6.0]

For topics and problems related specifically to Windows PowerShell version 6.0. For general PowerShell topics, use the [powershell] tag.

26 questions
0
votes
2 answers

In a JSON array, how to search for a certain record returned by ConvertFrom-Json?

With Powershell 6 I am able to download a file in JSON format with: PS C:\> Invoke-WebRequest https://login.microsoftonline.com/common/discovery/v2.0/keys | >> ConvertFrom-Json | >> Select-Object -expand keys kty : RSA use : sig kid :…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
0
votes
2 answers

User assigned managed identity in azure functions throwing value cannot be null

I have a http post azure functions that is created using power shell 6.2. It requires access to azure key vault to retrieve secrets. It works perfectly when I assign system assigned managed identity. However, getting the attached error whilst…
KrishOnline
  • 488
  • 1
  • 5
  • 16
0
votes
0 answers

Abount ConvertFrom-Json and pipeline Foreach

Why the following two behave differently? '[{"b":1}]'|ConvertFrom-Json|%{$_}|gm '[{"b":1}]'|ConvertFrom-Json|gm they seems like different types. My PS version is 6.2.3
onriv
  • 145
  • 1
  • 7
0
votes
1 answer

Extract attached file from response

According to Whitesource document, the response headers will have Content-Type = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Content-Disposition: attachment; filename=.xslx I want to extract that xslx file but,…
7_R3X
  • 3,904
  • 4
  • 25
  • 43
0
votes
2 answers

How do I print file for a specific parent/child using Get-ChildItem?

I'm able to recursively search a directory using Get-ChildItem -Recurse. But not getting output as expected. Tried -Depth also. But no luck. Folder structure is like below: C:\Users\Documents\Azure\repo\Templates\directory* directory1-uat -->…
user47
  • 105
  • 2
  • 12
0
votes
2 answers

Is -and comparison evaluated individually or against the same object?

I am looking for missing events between two arrays: $tc_records & $RelationshipEvents_array. Both arrays should have the same two entries. An entry for A->B and reverse B->A. When I'm evaluating RelationshipEvents with -and statement, does one…
mr.buttons
  • 685
  • 1
  • 9
  • 18
0
votes
1 answer

Pass json array to function in powershell

I have this short script which displays a table with row numbers and asks the user which Azure subscription wants to use. It works neatly. $subscriptions = $(& az account list --query '[].{name:name}' --output json) | ConvertFrom-Json $subscriptions…
tomab
  • 2,061
  • 5
  • 27
  • 38
0
votes
0 answers

Interacting with Get-WmiObject via .NET core

I need to get information about system. I can get it from Get-WmiObject with Powershell. But I need to gather it with .NET core application. I'm able to execute some basic commands like Get-Command or Get-Process. When i try to exexute…
0
votes
1 answer

How do I prevent PowerShell from adding exception data to $error

I am invoking a lot of REST calls in a function. I know that some of them will fail, but that is expected. My question is: How do I prevent powershell from adding entries to the global $error variable? foreach: $oldErrorActionPreference =…
-1
votes
1 answer

Stop user from opening an already program using PowerShell

I want to stop the user from running another instance of an already running program/service in Windows using PowerShell. Eg: I have notepad opened, then for minute's time period I want to disable the option to open notepad, since it already is…
-7
votes
1 answer

Why does the ProtectedFromAccidentalDeletion property on the Get-ADGroup command in the PS AD module return a NullReferenceException on one machine?

I have a PowerShell script that uses the Active Directory PowerShell module (part of RSAT). It's running fine on my Windows 10 machine in PowerShell 7, but on a Windows Server 2019 VM in PowerShell 6, it's returning an error. RSAT's AD tools are…
TylerH
  • 20,799
  • 66
  • 75
  • 101
1
2