Questions tagged [powershell-v5.1]

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.

52 questions
8
votes
1 answer

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 ... +…
8
votes
3 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
  • 13,922
  • 28
  • 113
  • 200
7
votes
2 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
  • 283
  • 1
  • 4
  • 12
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…
Jessie
  • 250
  • 2
  • 10
4
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…
4
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
  • 6,117
  • 5
  • 44
  • 81
3
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
  • 18,988
  • 5
  • 75
  • 151
3
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
  • 57
  • 1
  • 7
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.McDermaid
  • 15,079
  • 5
  • 40
  • 67
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
  • 341
  • 2
  • 14
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
  • 489
  • 4
  • 11
2
votes
2 answers

Get-ChildItem and wildcards and filtering

I have two different ways of getting files with a wildcard pattern: Get-ChildItem "$ActivityLogDirectory/*.csv" and Get-ChildItem "$ActivityLogDirectory" -Filter *.csv I prefer to use the latter instead of the former because the former…
HairOfTheDog
  • 1,948
  • 1
  • 22
  • 28
2
votes
1 answer

Copy-Item : A parameter cannot be found that matches parameter name 'FromSession'

When I try to copy files from the remote machine to local machine, I get the error: Copy-Item : A parameter cannot be found that matches parameter name 'FromSession'. I copy files to the same drive and the drive and path exists in both the…
shanmuga raja
  • 575
  • 5
  • 16
2
votes
1 answer

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…
finickydesert
  • 23
  • 1
  • 4
1
vote
1 answer

Update zipfiles with PowerShell 5 or >. Working code looking for improvement

Windows 10 64-bit. PowerShell 5.1 Update zipfiles with PowerShell 5 or >. Working code looking for improvement. 1.1.txt, 1.1.3.txt and 1.txt go in FileGroup0000000001.zip 11.txt and 11.1.txt goes in …
somebadhat
  • 714
  • 1
  • 5
  • 16
1
2 3 4