Skip to main content

Questions tagged [powershell-7]

The tag has no usage guidance.

powershell-7
0 votes
0 answers
16 views

Pasting deleted text in Powershell 7

I'm trying to add my favorite keyboard shortcuts from Linux/Bash to PowerShell to make it easier to switch between them (see code snippet below and you'll get the idea). Though there is one feature I'...
cataclysmic's user avatar
3 votes
1 answer
31 views

Format timer.elapsed for write-host

$timer = [System.Diagnostics.Stopwatch]::StartNew() Start-Sleep -Second 83 $timer.stop $elapsed=$timer.elapsed Write-Host $elapsed < Works, but not shown in desired ...
NewbieBAT's user avatar
1 vote
1 answer
64 views

How to limit exported commands from binary powershell module (*.dll file)?

I know I can limit exported commands from module that is imported like this: Import-Module C:\...\MyModule or Import-Module C:\...\MyModule\MyModule.psd1 Then I can use CmdletsToExport in .psd1. But, ...
Miroslav Vanický's user avatar
0 votes
1 answer
44 views

Split behaviour changes when script is run with PS2EXE

If I run this code as a ps1-file in the console it gives the expected output, but if I 'compile' the script with PS2EXE there's no second part of the string: $a = "first Part`r`n`r`nsecond Part&...
Johann's user avatar
  • 36
2 votes
1 answer
140 views

Powershell 7: Issue with Where-Object and tags

I am running a simple powershell query in Azure. I am looking to filter only the Web Apps with a certain Tag assigned to it: $apps = Get-AzWebApp | Where-Object {$_.Tags["Application"] -...
Herald Gjura's user avatar
0 votes
0 answers
85 views

Invoke-WebRequest different behaviour on different computers

I have a powershell script that logs into a webpage. The command for this acction is the following: $responseLogin = Invoke-WebRequest -Uri $urlLogin -Body $loginPayload -Method "POST" -...
Daniziz's user avatar
  • 88
-1 votes
1 answer
115 views

What is the fastest way to extract data from SQL Server 2005 using PowerShell 7?

This is not just a simple extraction. I have two tables. I take the values from one table and then use one column from this table to find a corresponding value in another table and then extract all ...
Brute's user avatar
  • 43
0 votes
3 answers
482 views

upgrade to Powershell 7 & dbaTools 2 causing "Assembly with same name is already loaded" error

I've moved a powershell script that was using modules SqlServer(22.1.18226) & dbaTools(1.0.116) in Powershell 5.1 to Powershell 7.3 using SqlServer(22.1.1) & dbaTools(2.1.5). Now I'm now ...
gjones's user avatar
  • 71
0 votes
0 answers
515 views

"Run with Powershell" opens and immediately closes the window without working, while calling the script inside powershell works properly

I have an odd behavior with PS in a new Acer laptop. I straight up copied the folder with the scripts from my PC on a USB drive and tried to use them on the laptop (both directly on the pendrive and ...
Federico Corradini's user avatar
1 vote
1 answer
142 views

Configure VSCode's PowerShell extension to show a script stacktrace by default for script-terminating errors

The default output of script-terminating errors that appears in the integrated console of VSCode's PowerShell extension, is not very helpful for debugging. It only shows the error message and the line ...
zett42's user avatar
  • 27k
1 vote
1 answer
50 views

Why does wrapping a script block into a commandlet function swallow all output?

Below script works perfectly fine when it is directly executed from a .ps1 file, but ever since i put it in a .psm1 file the function still works, but does no longer redirect the output from &...
Dbl's user avatar
  • 5,814
5 votes
1 answer
99 views

PowerShell fails to pick correct ParameterSet based on number of positional parameters

I am attempting to write a PowerShell function Set-MyRef which uses ParameterSets to expose its available parameters. I would like the function to have parameter sets similar to: Set-MyRef -Latest ...
JHR's user avatar
  • 200
0 votes
1 answer
45 views

Hash key and value do not compare equally [duplicate]

Why is an integer hash key not an integer? The key is of type KeyCollection even though it was created from a constant integer. The script to produce this output is below. I will show only the last ...
lit's user avatar
  • 15.8k
0 votes
1 answer
254 views

run .exe as administrator on a vm with Invoke-VMScript Powershell 7

I need to be able to launch command by shell console or powershell having the administrator window in powershell 7. I have launched several commands with Start-Process but none of them returned the ...
alex's user avatar
  • 1
2 votes
1 answer
325 views

ConvertFrom-Json unpacks arrays with 1 item and behaves oddly with empty object

I am trying to figure out how to stop ConvertFrom-Json from unpacking array types if they have one or zero items. I have read these related posts: ConvertTo-JSON an array with a single item How to ...
Braiden Cutforth's user avatar

15 30 50 per page