Questions tagged [powershell-5.1]

280 questions
0
votes
0 answers

How to run my PowerShell script for multiple local users?

I have a big PowerShell script that I want to run for each user automatically. I want to run this command as Admin and not have to specify credentials of other Standard users because all Standard users are Microsoft password-less accounts using…
user20225877
0
votes
0 answers

Remote DSC execution fails to resume after node reboot

Using PowerShell DSC, we're attempting to install DotNet Core among other application prerequisites onto a remote machine. We've set and applied LCM to Reboot and Continue. When executing the DSC the resources before and DotNetCore itself is…
0
votes
1 answer

Windows Terminal doesn't recognize a script function

I've recently discovered the Windows Terminal and wanted to give it a try. However, it doesn't seem to work the same as the original PowerShell Console. When I try to call a script function in it like . .\Func-Test.ps1; My-Func -test abc it…
t3chb0t
  • 16,340
  • 13
  • 78
  • 118
0
votes
0 answers

Restoring database from file or multiple files

Trying to restore the file or files returned by this statement $backupFiles = Get-ChildItem -Path $BackupPath -Filter "*$tstamp*.bak" -Recurse | Sort-Object -Property CreationTime | Select-Object I am executing this command. I get a warning and the…
Leo Torres
  • 673
  • 1
  • 6
  • 18
0
votes
1 answer

How to remotely start service on Azure VM with powershell 5.1

How can I start a service on an Azure VM remotely? It seems impossible to do without Powershell being "Run as Administrator". Is there a way to launch as admin? (I would pass in Get-Credential parameter, but unfortunately the 5.1 version Set-Service…
0
votes
1 answer

Powershell: Regex matching with Get-content -Raw flag results in empty results

Solution was adding (?ms) to the front of my regex query I am trying to search for chunks of text within a file, and preserving the line breaks in a chunk. When I define my variable as $variable = get-content $fromfile, my function (below) is able…
Alex Smith
  • 11
  • 3
0
votes
0 answers

Can you sense javac errors using Powershell?

I am using javac in Powershell right now, but I am having an issue. The message selected file has been succesfully compiled:) I made it show after compilation shows up even if there have been errors during compilation. Here is my current…
PlatoHero
  • 31
  • 5
0
votes
0 answers

Powershell Replace Method Stopped Working For This Loop

The replace method worked in this code for two years, why did it stop? Am I missing an update? Did a security update kill it? I just want to know if it's me, or if by some fluke it worked to begin with. The following is a slice of a script that…
dwillits
  • 183
  • 1
  • 11
0
votes
1 answer

Trimming columns containing zero in powershell

Help! I'm looking for a PowerShell solution that can do the following to trim columns from a csv file containing only zeros: Read/open the csv file Scan the first column for 'Total' Scan the first row for 'Total' Read that 'Total' row until the…
jw-smc
  • 23
  • 5
0
votes
0 answers

Does 2>$null still work in Powershell 5.1?

It was my understanding that anything that writes to $error should be re-directable to $null, but I can't make it work, even with something as simple as substring or a bad cmdlet name: sample screenshot PS C:\WINDOWS\system32> asdf 2>$null asdf :…
Josh
  • 1
  • 3
0
votes
1 answer

Validate an expired ActiveDirectory password using PowerShell or LDAP

As title said, I need a way to validate an expired password against ActiveDirectory. It has to be LDAP, or PowerShell, because the user will perform validation via a NodeJS service from another machine running Linux. I have tried using…
Magician
  • 1,944
  • 6
  • 24
  • 38
0
votes
1 answer

Powershell 5.1 if statement result is incorrect

I'm using Powershell 5.1 in constrained language mode with no access to additional modules. I've created a script to return information from "net user query (username) /domain" that includes an If statement to return results if the end user I'm…
0
votes
1 answer

PowerShell: store Out-String results formatted in an array

I have a script that is looking for some values in xml-like files: $path = "C:\Users\*.xml" Get-ChildItem $path | Select-String -Pattern "", "" | Out-File out.txt The result is: I am trying to store these in an…
PSrookie
  • 17
  • 7
0
votes
1 answer

PowerShell - Accessing root web.config

I can't seem to find a good hint on accessing the root web.config, currently in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config. In my situation, I want to apply a few security settings to cascade down to apps (ex: disable…
0
votes
0 answers

Is it possible to check if a specific key is pressed in Powershell without pausing the entire script?

The only ways I know to check if a key is pressed in Powershell are $Host.UI.RawUI.ReadKey() and [console]::ReadKey(). I want to make a script that writes in the console "1 is pressed" whenever 1 is pressed and"1 ain't pressed" whenever 1 isn't…
PlatoHero
  • 31
  • 5