For topics and problems related specifically to Windows PowerShell version 6.0. For general PowerShell topics, use the [powershell] tag.
Questions tagged [powershell-6.0]
26 questions
12
votes
1 answer
how to get winrm to use powershell 7 for remote sessions by default
With the release of powershell 7, seems like it is time to move past ps 5.1 so I have installed in on a couple of servers to give it a go.
However I when I create a session to these servers from my pc with ps7 I am always running ps5.1 on the remote…

Alexis Coles
- 1,227
- 14
- 19
4
votes
1 answer
HtmlWebResponseObject.ParsedHtml replacement in Powershell Core 6
My goal is to parse an html file retrieved with Invoke-WebRequest. If possible I'd like to avoid any external libraries.
The problem I am facing is, that Invoke-WebRequest returns a BasicHtmlWebResponseObject instead of a HtmlWebResponseObject since…

Jannik
- 1,583
- 1
- 14
- 22
4
votes
3 answers
Invoke-Expression, not all output returned to variable
I'm using some GIT commands in my PowerShell scripts. Most of the time I'm calling the GIT commands via Invoke-Expression so that I, e.g.
can parse the output, or/and
forward the out to a logging method.
At some GIT commands I recognized that not…

Moerwald
- 10,448
- 9
- 43
- 83
3
votes
1 answer
What is the difference between PowerShell 5.1, 6, and core?
From what I understand PowerShell 6 and Core uses the .Net Core framework and is cross-platform while PowerShell 5.1 uses the .Net framework. To my understanding PowersSell Core is also not as developed as 5.1
What would you recommend I start…

zooboo
- 33
- 3
2
votes
0 answers
How to remove a folder recursively in PowerShell Core 6?
Since PowerShell 6 supports aliases from unix I tried running
rm -rf node_modules
to force remove the node_modules folder and all its subdirectories.
However, I get
Remove-Item : A parameter cannot be found that matches parameter name 'rf'.
At…

mancristiana
- 1,896
- 3
- 18
- 28
2
votes
4 answers
Elegant way of setting default value for variable in Powershell 6.0?
I have the following, which works but looks clunky:
if($config.contentDir){
$contentDir = $config.contentDir
} else {
$contentDir = "contents"
}
Is there a nicer way of doing this? I have seen this answer here, but it isn't exactly…

Starfall Projects
- 395
- 4
- 21
1
vote
0 answers
Azure HTTP Trigger. How to avoid everytime the login
I have an Azure HTTP trigger function.
And it all works, except that I am executing everytime the slow
Connect-ExchangeOnline -Credential $Credential
How can I re-use the security token so it is only once slow.
And instead of using a normal login…

Bert
- 21
- 3
1
vote
0 answers
Running Vagrant provisioner with PowerShell Core 6 / PowerShell 7
I'd like to run PowerShell Pester tests using Vagrant on Windows Server 2008R2.
Windows Server 2008R2 has PowerShell 3.0 installed by default, and I'd obviously prefer to use a more modern version of PowerShell.
I can install PowerShell 6 using…

Grzegorz Smulko
- 2,525
- 1
- 29
- 42
1
vote
1 answer
Use Connect-SPOService with Powershell 6 (core version)
I'm trying to connect to a sharepoint environment and I want to do that with Powershell version 6. Why? Eventually, I want to put the PS commands in a .net core 3 application. And as far as I know I cannot use PS5.1 in .net core.
It is about this…

Rub3s
- 359
- 2
- 13
1
vote
1 answer
Why does scanning a single file in Powershell with Start-MpScan take longer than using the context menu option?
I'm currently writing a script to use Windows Defender for scanning various files. I've read the documentation on Microsoft Docs - StartMpScan, however I am running into an issue when attempting to scan a single file or folder.
Documentation…

Hebon
- 195
- 1
- 1
- 6
1
vote
1 answer
Export-Csv and Array objects
I have a CSV that I want to process in an array object and export as another CSV. However when I do that, instead of copying the values of the array, it copies the attribute of the…

Mudassir
- 725
- 6
- 28
1
vote
0 answers
Powershell use SecureString from linux to office365
I have some trouble when I try to use the Exchange powershell commandlet : New-MailUser (doc).
More specifically, it's using a SecureString that fails.
My problem is that it works well on my windows dev env, but once it's executed on a Linux, it…

Vitelize
- 23
- 3
1
vote
1 answer
Code works perfectly in Powershell 5 but not in Powershell 6
One of my tasks required creating ISO images from the list of files. I found this gist (according to author the code is in the public domain).
My company uses Powershell 6.2.2 only and that's the fact I have to deal with. Problem is that code works…

Goujon
- 606
- 8
- 16
0
votes
1 answer
remote connection using powershell from linux to windows
I am able to connect to a remote windows machine from my windows local machine using Powershell session created by New-PSSession command.
New-PSSession -ComputerName $computerName -Credential $cred
Now, I need to create similar remote session to a…

Vishwanath
- 149
- 2
- 14
0
votes
1 answer
Powershell: Catching WebRequest Respose differs from Native Response
I'm having a little issue with getting the same data from the exception inside a catch block from what I would get without.
A call to Microsoft Defenders ATP API without a try/catch block renders the following error message:
Invoke-WebRequest :…

LinkOps
- 331
- 3
- 14