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.
Questions tagged [powershell-7.0]
216 questions
2
votes
1 answer
How to Stop powershell form Converting the variable assigment of a boolean to Uppercase letter
I am trying to format a json and do dynamic variable assignment but once the boolean value is assigned powershell is changing the casetype for the first letter to uppercase.
I still want to maintain the case type for my input values both lowercase…

wehelpdox
- 339
- 6
- 16
2
votes
2 answers
ShouldProcess failing in PowerShell7
Environment: Windows Server 2022 21H2, Powershell 7.2 (running as administrator)
I have a script that implements ShouldProcess, which works fine in Windows PowerShell 5. However, in PowerShell 7, the script invariably throws the error Cannot find an…

Jeff Zeitlin
- 9,773
- 2
- 21
- 33
2
votes
2 answers
Set property value on object loaded from json containing comments
When loading an object from a json file one can normally set the value on properties and write the file back out like so:
$manifest = (gc $manifestPath) | ConvertFrom-Json -AsHashtable
$manifest.name = "$($manifest.name)-sxs"
$manifest |…

jessehouwing
- 106,458
- 22
- 256
- 341
2
votes
1 answer
PowerShell conversion of String into FileInfo automatically - What is this called?
Some sample code to illustrate what I'm talking about. I've got a utility class with a single method. That method takes one argument: a System.IO.FileInfo object. From the PowerShell side I can pass in a System.String object and everything "just…

BuddyJoe
- 69,735
- 114
- 291
- 466
2
votes
1 answer
Copy file from remote computer to local computer within an Invoke-command session in PowerShell
I use a pwsh code to connect to a remote computer to generate a CSV file.
I do this by Invoke-command, the code works perfectly, generates a CSV file on the server.
The name of the CSV file is generated dynamically.
However, I'm unable to copy…

Gagan
- 49
- 6
2
votes
1 answer
Access user environment variables from elevated script?
I have a script that utilizes $env:appdata which results in C:\Users\username\AppData\Roaming. This works great if I run the script manually, even in an "administrative" prompt. However, when it runs as part of a scheduled task under "SYSTEM" with…
user736893
2
votes
1 answer
Powershell, standalone OK, but scripted output is just newlines
Summary
I am baffled that typing in my code in PS7 works like a charm, but when I put it in a script I seem to NOT get any output.
Info
Take a look at the following script, which runs without generating any errors:
"Iapetus elementary test…

H.Hasenack
- 1,094
- 8
- 27
2
votes
2 answers
Ternary comparison outputs new value
PS C:\Users\Scott> $openlog = "YES"
PS C:\Users\Scott> ($openlog -eq "YES") ? ($openlog = "NO") : ($openlog = "YES")
NO
PS C:\Users\Scott> ($openlog -eq "YES") ? ($openlog = "NO") : ($openlog = "YES")
YES
PS C:\Users\Scott> ($openlog -eq "YES") ?…
user736893
2
votes
1 answer
Sorting not working in a Powershell function
I have the following function in Powershell. It always returns False and also the sorting of the arrays doesn't work within the function while it works in the console. The function is
# $a = [121, 144, 19, 161, 19, 144, 19, 11]
# $b = [121, 14641,…

Suzuna Minami
- 391
- 2
- 11
2
votes
4 answers
Why does pwsh.exe in combination with Start-Process not accept a script block directly?
Why does Start-Process powershell.exe { Read-Host } work, but Start-Process pwsh.exe { Read-Host } does not?
I'm aware of the -ArgumentList switch of Start-Process, but it makes things more complicated when it comes to escaping quotation…

FatalBulletHit
- 762
- 6
- 22
2
votes
1 answer
Install-Module not available - not recognized as a name of a cmdlet
I'm trying to take advantage of the PowerShell Gallery which requires Install-Module. For some reason I cannot get this to work on any computer I have access to:
Install-Module: The term 'Install-Module' is not recognized as a name of a cmdlet,…

Lucky Luke
- 1,373
- 2
- 13
- 18
2
votes
2 answers
Provide an implementation of a C# abstract class in PowerShell
I'm trying to create a PowerShell-class implementation of an abstract class' function:
class ReadList : Intacct.SDK.Functions.AbstractFunction {
[string]$ObjectName
ReadList ([string]$ObjectName) {
$this.ObjectName =…

craig
- 25,664
- 27
- 119
- 205
2
votes
1 answer
How to run commands in parallel in PowerShell
Though this might be duplicate, this is different.
I have written a script to fast delete folders containing large amounts of files and subfolders using PowerShell, now I will post how I achieved parallel processing, and set up some examples:
The…
user14636788
2
votes
1 answer
Powershell parallel processing : How to set value in a global varible
I am calling an API 500 times with 10 parallel threads as part of load testing. I want to capture the result of API call in a global variable (a counter outside script block scope) so, that I can process further for validation.
Example- In below…

suraj_123
- 115
- 13
2
votes
1 answer
PowerShell get Command Line Args of Processes in Linux and OSX
In PowerShell, using Get-WmiObject win32_process it is possible to get the command-line arguments of any active process in windows (like this). How do you do the same in Linux and/or OSX?
The ps command can do this to be sure, but I am looking for a…

Choppy The Lumberjack
- 737
- 7
- 13