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
0
votes
1 answer

Interactively kill process using powershell

How can an interactive method for killing process in powershell be created? Kill process preferably in a form using input field to find and kill the processes desired.
skrap3e
  • 143
  • 1
  • 1
  • 8
0
votes
1 answer

Results in single string, need one per line

Trying to combine some properties from get-netadaptor with get-netipaddress tried everything I know but the results of the variable $getnet-name are all on one line ${getnet-name} = New-Object psobject -Property @{ Status = $null AdminStatus =…
skrap3e
  • 143
  • 1
  • 1
  • 8
0
votes
1 answer

How to get PS script to access folders that need admin access

I'm a desktop support tech for my company, and we often have a good bit of repetitive troubleshooting we perform such as clearing temp files and cache from C\windows\temp, local appdata temp folder, as well as google and IE cache/cookies. I was…
0
votes
1 answer

How can I compress every X subfolder in a folder as a separate rar file

I am really new to Powershell coding and need your help please I'm on Windows 10 with Powershell 5.1 and trying to work it out with Winrar. The Main folder contains 5000 subFolders I would like to specify how many folders should be included per…
webster
  • 11
  • 2
0
votes
0 answers

Weird behavior when launching powershell through different ways

I have a Powershell script assigned to the context menu and it has been running fine. Recently, after I've reset my win10 system and then manually reconfigured my whole system Powershell begins to behave weirdly. The script won't be run correctly…
preachers
  • 373
  • 1
  • 5
  • 15
0
votes
0 answers

How can `Get-Command` return "commands" that aren't really commands?

'Get-Command' returns a list of all available commands in a powershell session. The following code evaluates to $false, when passed a string which is not a command: function f($x) {[bool](Get-Command $x -ErrorAction SilentlyContinue)} And it…
0
votes
1 answer

Powershell Script not working using Import-Clixml command

I had a script that was working in Powershell 4.0 in Windows Server 2012 R2. Now I installed Windows Server 2016 and I have Powershell V5.1.17134.590. In my script I have this: $credFile = "c:\Program Files\Scripts\MyCredentials.xml" $credentials =…
fr0zt
  • 733
  • 4
  • 12
  • 30
0
votes
0 answers

Process moving from one script to another in powershell

MainFunction which i want to check writing another script. In short i just want to check certain part of the mainfunctiona and go back to pester. param( [int]$jobCardID = $(Throw '-jobCardID is required'), # VSTS Job Card…
0
votes
1 answer

How to get the -Depth switch to work in a script?

I'm trying to limit the recursion depth for this script that generates a list of folders, associated security groups, and the members of each group. I'm using PowerShell 5.1. I've tried adding -Depth 3 on line 18 (as seen below), but I still get…
0
votes
1 answer

Get value from json variable using windows powershell 5.1

I've got a JSON like this [ { "Param1":true, "Param2":0, "Param3":"OK" ... ... } ] How can I get Param2 value, using powershell 5.1? For now, I tried to get property names, but only get…
0
votes
2 answers

Leftpad doesn't work when using with regex in Powershell

Here are two code blocks which show the strange behavior that Leftpad does. $array = "z", "fg" $array -replace "(\w{1,2})", '$1'.PadLeft(2, "0") # output: z, fg $array = "z", "fg" $array -replace "(\w{1,2})", '$1'.PadLeft(3, "0") # output: 0z,…
preachers
  • 373
  • 1
  • 5
  • 15
0
votes
2 answers

Run a external program with parameters and wait for it to end in Powershell

Actually, I've found so many solutions to this question, but none works. The program I'd like to run in Powershell is Reaper - a Digital Audio Workstation, and I'm going to use its command line tool for batch-processing audio files within a PS…
preachers
  • 373
  • 1
  • 5
  • 15
0
votes
1 answer

Use variables in string replace - Windows powershell

I have a requirement where my string is of format as below: I am using below powershell script in TFS 2017 build template to replace the build number value: $content = Get-Content -path…
Mustafa
  • 202
  • 3
  • 14
0
votes
0 answers

Browsing IE via its COM object in Powershell

I've written a Powershell script to automate a Web UI test using IE. The script runs fine when I execute it from PowerShell. However, I have run into an obscure problem and that is when I run my Web UI test script from another powershell script, it…
user6037143
  • 516
  • 5
  • 20
0
votes
1 answer

Set-ItemProperty ignores trailing .

Using Powershell 5.1, I am trying to create a registry value under: HKLM:\SOFTWARE\Classes\. (Note trailing period) Unfortunately Set-ItemProperty appears to ignore the trailing . and creates the value under: HKLM:\SOFTWARE\Classes instead. I'm…
moon
  • 320
  • 3
  • 10