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
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
  • 2,489
  • 2
  • 29
  • 35
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
  • 685
  • 6
  • 19
2
votes
2 answers

How to search an object for a value?

Let's say you have a giant object - one which may or may not have nested arrays / objects, # Assuming 'user1' exists in the current domain $obj = Get-ADUser 'user1' -Properties * and I want to search that object for the string SMTP…
Kellen Stuart
  • 7,775
  • 7
  • 59
  • 82
2
votes
2 answers

Is there a way to fetch Response header for InvokeRest Method of Powershell Version 5

How can I fetch Response header for InvokeRest Method of Powershell Version 5, For Powershell version 6 -ResponseHeadersVariable is available , Is there any way to do it in powershell version 5. I am unable to find any way to do it.
Sakshi Rawal
  • 97
  • 2
  • 12
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
  • 744
  • 1
  • 5
  • 17
1
vote
2 answers

Ignore CTRL+C in delay - powershell

Whenever I set a delay in powershell using Start-Sleep, e.g: Start-Sleep 10 then it does not ignore CTRLC. I mean when I hit that key stroke the delay quits. How can I ignore it in delays?
Wasif
  • 14,755
  • 3
  • 14
  • 34
1
vote
1 answer

Selecting multiple strings from the output of command in powershell

This may be a simple question that has been answered before but I just couldn't find it. I am trying to filter out unneeded text/output from a simple script I made. $stop = 2 do { clear netstat -a -n -o | Select-String "ESTABLISHED" Start-Sleep…
FinderFake
  • 35
  • 4
1
vote
2 answers

How to print angular brackets in XML using powershell

I want to print the angular brackets(<,>) in powershell, but it is printing to > and < instead respectively. Is there any way I can print those symbols. I have used \ to overcome the bracket's escape properties and also single inverted commas but…
1
vote
1 answer

Iterate a windows ascii text file, find all instances of {LINE2 1-9999} replace with {LINE2 "line number the code is on"}. Overwrite. Faster?

This code works. I just want to see how much faster someone can make it work. Backup your Windows 10 batch file in case something goes wrong. Find all instances of string {LINE2 1-9999} and replace with {LINE2 "line number the code is on"}. …
somebadhat
  • 744
  • 1
  • 5
  • 17
1
vote
2 answers

Call file in powershell script using relative and absolute path

My script runs from C:\ABC\DEF\Tools\Powershell\Development>myscript.ps1 I want to use this file in myscript.ps1 from this Relative path location '.\AOI\UDT\testfile.text' I cannot use absolute path 'C:\ABC\DEF\AOI\UDT\testfile.text' because it…
1
vote
1 answer

Using Format Operator within Replace Operator in PowerShell

I'm trying to rename my files "Introduction _ C# _ Tutorial 1" to something like "01.Introduction". It needs a -replace operator as well as a -f operator to zero pad the index number. My code is like: $string = "Introduction _ C# _ Tutorial 1" if…
preachers
  • 373
  • 1
  • 5
  • 15
1
vote
1 answer

Find lines in one Object based on strings in other object

Finding lines in one file based on rows in another file. I have one object $A with some rows like: 0c7d3283-bec2-4db1-9078-ebb79d21afdf 200bc957-26dd-4e8e-aa6e-00dc357c4ac2 218e0d2a-0e8b-4a68-8136-8f5dd749a614 I want to find matches in object $B…
1
vote
1 answer

Powershell -command text not appearing

Windows 10, Powershell -v 5.1 I have tried to restore powershell to defaults, both normally and as admin. I have changed/turned off high contrast settings, deleted console files for powershell in Regedit, as well as tried to restore defaults from…
Aaron Lamb
  • 83
  • 2
  • 7
0
votes
0 answers

Restrict parameter to specific type; when using CimInstance

Is there a sensible way to restrict the parameter type used for a function when it may be encapsulated in a CimInstance? e.g. Say I have a method such as below: function Add-DaclAce { [CmdletBinding()] [OutputType([System.Void])] #just for…
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
0
votes
3 answers

Get-Package command includes xml string - Need to convert to PSObject

Need Windows Update Install Date from Get-Package SwidTagText object. The object is in XML format and everything I have tried to convert doesn't work. I am trying to switch from WMI because its terribly slow to pull back results. Tried the…
n8kc
  • 1
  • 2