Questions tagged [powershell-v5.1]

For issues specifically relating to Windows PowerShell, version 5.1. If you're using v5.1 but the issue is not likely to be specific to that version, use the [powershell] tag instead.

For general PowerShell information see the tag wiki.

Version 5.1 of Windows PowerShell, Microsoft's task automation and configuration management platform that functions as an interactive command shell and a scripting language.

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

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

51 questions
13
votes
4 answers

Why does Write-Output not work inside a PowerShell class method?

I am trying to output variables using Write-Output, but it did not work inside a PowerShell class method. Write-Host is working. See the sample code below. class sample { [string] sampleMethod() { $output = "Output message" try { …
Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230
11
votes
2 answers

Cannot add "-persist" to New-PSDrive - getting error "network resource type is not correct"

As the title says, if I try to add -persist to the cmdlt, it returns an error: New-PSDrive : The network resource type is not correct At line:1 char:1 + New-PSDrive -Name P -Root ... +…
10
votes
3 answers

Powershell won't install almost any module using install-module

My Powershell v5.1 won't install almost any module automatically using install-module whereas manually installation does work. First, when I run install-module, it would download the module then throw an error, say the pscx module:…
preachers
  • 373
  • 1
  • 5
  • 15
7
votes
4 answers

powershell update-help fails

I just started to learn PowerShell from the Microsoft virtual academy and I was running one of the commands indicated. while on their end it worked mine did not. I did look around for a solution to this issue. I just don't know what went wrong. any…
Bob
  • 73
  • 1
  • 6
6
votes
1 answer

Property passed to Invoke-Command changes type from IDictionary to HashTable

I've been getting an error running Invoke-Command where the script block takes a parameter of type dictionary: Cannot process argument transformation on parameter 'dictionary'. Cannot convert the "System.Collections.Hashtable" value of type …
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
6
votes
1 answer

Write-Information does not show in a file transcribed by Start-Transcript

I'm using PowerShell 5.1 and I am trying to determine why Write-Information messages do not show in the transcript log created by Start-Transcript unless I set $InformationPreference to SilentlyContinue. I want to both display the messages in the…
6
votes
4 answers

Powershell v5.1 Invoke-RestMethod and bypass proxy

I am currently in Powershell V5.1 and would like to bypass Internet Explorer proxy on a Invoke-RestMethod command. In Powershell V6, there is the -NoProxy option that indicates that the cmdlet will not use a proxy to reach the destination. This is…
Philippe
  • 103
  • 1
  • 1
  • 8
6
votes
1 answer

Powershell forcing reload for using module

Is there a way to force PowerShell to reload a module when using module .\MyModule.psm1? Normally I would use Import-Module .\MyModule.psm1 -Force but since I am using enum and class C# style this won't do; since enum and class are not visible…
LosManos
  • 7,195
  • 6
  • 56
  • 107
5
votes
2 answers

Powershell Cmdlet.ShouldProcess Method default answer

I have a powershell script in which I have implemented the should process method with a high ConfirmImpact to ensure a prompt occurs. Prompting is working as expected however the default response when nothing is entered is "Y" [Y] Yes [A] Yes to…
3
votes
0 answers

Extracting data from Azure Data Factory Logs

I'm retrieving Azure Data Factory logs for analysis using Powershell. I am successfully retrieving the top level log (the pipeline) and the log nested inside that (activities) and writing to a text file. However I'm having issues flattening the…
Nick.Mc
  • 18,304
  • 6
  • 61
  • 91
2
votes
0 answers

powershell ftps upload causing error "DATA connection terminated without ssl shutdown" on stream close

I have the following code I have built upon something I found online (can't remember where) $Server = XXXXX $port = XXX $remotepath='/' $username = 'XXXX' #$passward = ConvertTo-SecureString -AsPlainText 'XXXX' -Force $password = 'XXXXX' $file =…
GKman
  • 503
  • 1
  • 5
  • 19
2
votes
2 answers

What type of object is $: (such as `$code:`) in Powershell?

I was using tab autocompletion for a variable name in Powershell 5.1 today and noticed that one of the choices was the name of a PSDrive. The drive name is docs and I wanted to expand is called $document_name. When I typed $do, the shell did…
chris
  • 588
  • 5
  • 16
2
votes
1 answer

Find whether PowerShell error is originally Terminating or non-terminating

Lets say I ran a command with ErrorAction Stop and it generated an error. I would like to know whether the error was originally terminating or not? I have the ErrorVariable or $Error object. Does ErrorVariable catches both kind of errors? I am…
user10340130
2
votes
1 answer

X509Certificate2 Constructor fails with Byte[] using Powershell

I am hoping I missed something obvious as I have tried 3 different approaches to generate a PFX/PKCS12 byte array so that the X509Certificate2 class will initiate. Problem: Code is throwing an…
jjhayter
  • 352
  • 4
  • 19
2
votes
2 answers

Using New-Item cmdlet with Literalpath in Powershell?

I'm using New-Item cmdlet to create a new folder and surprisingly find that it has no -Literalpath parameter available. My path contains square brackets in it. What can I do to address this problem?
preachers
  • 373
  • 1
  • 5
  • 15
1
2 3 4