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.
powershell-7.0
232
questions
0
votes
1
answer
22
views
Applying a template with PnP to a SharePoint site
I am writing a script to export a template from a SharePoint site then uploading it to a different tenant.
I am using PnP PowerShell library, and I am exporting the template using this command:
Get-...
0
votes
1
answer
35
views
Parameter values empty in Powershell function
All my parameter values are being received as empty in this seemingly straightforward function:
function Get-SSH-Command {
param (
[string]$private_key_path,
[string]$user,
...
0
votes
1
answer
55
views
Update Powershell 7 to specific version without winget
I have a server running Powershell 7.3.10 core and I need to upgrade to 7.4.2 which is the latest version my company supports. The problem is the server doesn't have winget on it and I can't find an ....
0
votes
0
answers
18
views
Unable to connect to service principal/keyvault
I'm running a pwsh script that is supposed to connect to mggraph using a service principal. This will ultimately be used in powershellcore on linux. I've found that I need to do Connect-AzAccount -...
1
vote
0
answers
58
views
Executing PowerShell scripts from C# .NET 6 web app using RunImpersonated not working - Scripts still execute as IIS APPPOOL\APP
My app needs to execute PowerShell scripts to create and manage AD accounts. My current setup uses HangFire to launch background jobs, PowerShell execution being one of them. I have an ...
0
votes
1
answer
275
views
Start Powershell 5 out of Powershell 7
My main Script is Powershell 7, but i want to run a function in powershell 5 (because this function is only possible in powershell 5).
I also want to give the function a psobject and return a psobject,...
0
votes
0
answers
52
views
dbatools SQL Functions Not Running In Parallel While SQL Server queries do in Powershell
I am writing a distribution package in PowerShell that will take a list of SQL Server names and distribute data from a host server to various production servers. I am a massive fan of dbatools.io and ...
0
votes
1
answer
43
views
On running the dotnet --version or dotnet run command on Visual Studio or VSCode Poweshell, we are getting the Windows popup asking for App selection
On running the dotnet --version or dotnet run command on Visual Studio or VSCode PowerShell, we are getting the Windows popup asking for App selection. Same issue doesn't occur on command prompt when ...
0
votes
0
answers
51
views
TextBox.Text gets saved as System.Object
I started writing a script to copy specific attributes from one AD-User and create a new User with those attributes and a different name. So far so well, it worked in the past.
I deleted a codeblock ...
0
votes
1
answer
75
views
How to export/import cmdlet from local module?
The problem I have is that cmdlets are not exported and not imported.
Consider following module example (.\Modules\Tools.psm1)
Function Write-Message() {
param ([String] $Message)
Write-...
2
votes
1
answer
92
views
Why PowerShell $Matches Hashtable automatic variable is not returning all matches?
I'm using Named Captures in PowerShell. But the following example is not returning all matches. All the lines in the following code return correct output - except the lines 7 and 8. I was expecting $...
2
votes
1
answer
167
views
How to error handle Invoke-Command over SSH
I'm currently working with a script that utilizes the Invoke-Command over SSH as shown below. While it works well, I'm looking to implement exception handling, specifically for scenarios where the ...
0
votes
0
answers
238
views
COM Objects, Powershell 5 vs 7 and Constrained Language mode
I have a strange issue and wonder if anyone has any ideas. I am trying to make a powershell script that can replace text in a word document.
This script works fine on version 5 but not on version 7
...
2
votes
1
answer
65
views
Why is `Install-Module` not respecting $ErrorActionPreference=Stop from the script scope?
I have the following script:
$ErrorActionPreference = "Stop"
Install-Module 'DoesNotExist' -Force
Write-Host "This should not be printed!"
I'd assumed, that if an error occurs in ...
2
votes
1
answer
479
views
Any way to remap ls from Get-ChildItem to another command in PowerShell?
Trying to replace the default PowerShell Get-ChildItem command (mapped to ls by default in PowerShell 7) with eza, however I cannot seem to find anything on how to do so
Using New-Alias results in ...