Questions tagged [powershell-5.0]

For issues relating to Windows PowerShell, version 5.0

Version 5.0 of Windows PowerShell, Microsoft's task automation and configuration management platform that functions as an interactive command shell and a scripting language. For general information about Windows PowerShell, see the tag wiki for the tag.

Windows PowerShell 5.0 is available as part of the Windows Management Framework (WMF) 5.0.

For the latest news and developments, check out the PowerShell blog.

855 questions
60
votes
4 answers

How do I force powershell to reload a custom module?

I have created a module 'ActiveDirectory.psm1' which contains a class in powershellv5. I am importing that module in another file called 'test.ps1' and then calling a method from the class. test.ps1 contains the following: using module…
S. Mitchell
  • 603
  • 1
  • 5
  • 6
49
votes
3 answers

Making a PowerShell POST request if a body param starts with '@'

I want to make a POST request in PowerShell. Following is the body details in Postman. { "@type":"login", "username":"xxx@gmail.com", "password":"yyy" } How do I pass this in PowerShell?
live2learn
  • 691
  • 1
  • 7
  • 16
41
votes
3 answers

Iterating through a JSON file PowerShell

I am trying to loop through the below JSON file in PowerShell. Without specifically naming the top tags (e.g. 17443 and 17444), as I do not know them in advance I cannot find a way to loop through the data. I want to output tags 3, 4 and 5 (title,…
Omen9876
  • 563
  • 1
  • 4
  • 7
35
votes
5 answers

List file names in a folder matching a pattern, excluding file content

I am using the below to recursively list all files in a folder that contains the $pattern Get-ChildItem $targetDir -recurse | Select-String -pattern "$pattern" | group path | select name But it seems it both list files having the $pattern in its…
u123
  • 12,921
  • 42
  • 141
  • 247
31
votes
3 answers

PowerShell 5.1 - How to uninstall module which is currently use

We are using some PowerShell modules in one deployment PowerShell script. Using following command we are installing module (i.e. XXXX) into "C:\Program Files\WindowsPowerShell\Modules". Install-Module -Name "XXXX" -AllowClobber -RequiredVersion…
mit
  • 1,521
  • 3
  • 14
  • 25
30
votes
5 answers

Write-Host vs Write-Information in PowerShell 5

It is well known that Write-Host is evil. In PowerShell 5, Write-Information is added and is considered to replace Write-Host. But, really, which is better? Write-Host is evil for it does not use pipeline, so the input message can't get reused. But,…
wontasia
  • 412
  • 1
  • 5
  • 10
29
votes
10 answers

how to export a class in powershell v5 module

I've got a module setup to be like a library for a few other scripts. I can't figure out how to get a class declaration into the script scope calling Import-Module. I tried to arrange Export-Module with a -class argument, like the -function, but…
jason
  • 333
  • 1
  • 4
  • 8
27
votes
2 answers

Set-Content appends a newline (line break, CRLF) at the end of my file

My original config file (web1.config) has no extra line and when viewed in notepad (showing all characters) looks as:
OmGanesh
  • 632
  • 1
  • 9
  • 20
26
votes
6 answers

The term 'Invoke-WebRequest' is not recoginzed as the name of a cmdlet

I've got problem with executing Invoke-WebRequest cmdlet. I read that ~100% case of that scenario is PS version lower than 3, but it's not my case: Name Value ---- ----- WSManStackVersion …
Dawid Komorowski
  • 488
  • 1
  • 6
  • 12
23
votes
1 answer

How do I create file hardlink in PowerShell on Windows 10?

How do I create file hardlink in PowerShell on Windows 10? PSCX has New-Hardlink, but is it still needed on Windows 10? You could always shell out to mklink, but from powershell that requires you prefix the command with cmd /c, which is ugly and…
yzorg
  • 3,673
  • 3
  • 32
  • 49
22
votes
2 answers

Starting programs on multiple desktops using powershell in windows 10

Suppose I want to start several programs C:\program1.exe, C:\program2.exe, etc. on multiple desktops in windows 10. For example, programs 1 and 2 should be started on desktop 1 side-by-side, program 3 should be started on the second desktop, while…
HRSE
  • 323
  • 6
  • 13
20
votes
5 answers

Invoke-RestMethod - Ignore Self Signed Certs

It seems like this question has been asked and answered, but so far every solution I come across does not help. I'm writing a PowerShell script to run some REST API's to get usage information. My script breaks immediately just trying to communicate…
firestarter247
  • 255
  • 1
  • 3
  • 7
19
votes
3 answers

PowerShell PackageManagement, how to uninstall a package provider?

To troubleshoot a problem, I thought I'd try reinstalling the Chocolatey package provider. There appears to be no cmdlet to remove or uninstall a package provider. I'm not referring to removing a package source or package. I'm using PowerShell 5 on…
Vimes
  • 7,886
  • 14
  • 52
  • 83
13
votes
5 answers

How to run the .reg file using PowerShell?

I want to run the .reg file (registry file) using PowerShell Script but I am not able to run it. When i run it manually it creates the respective nodes in registry but i want it execute using powershell script. Below is the code which i tried using…
SRP
  • 697
  • 2
  • 11
  • 29
13
votes
2 answers

PowerShell type accelerators: PSObject vs PSCustomObject

In PowerShell v3.0 PSCustomObject was introduced. It's like PSObject, but better. Among other improvements (e.g. property order being preserved), creating object from hashtable is simplified: [PSCustomObject]@{one=1; two=2;} Now it seems obvious…
AdamL
  • 10,453
  • 5
  • 46
  • 68
1
2 3
56 57