Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [powershell]

PowerShell is a cross-platform command line and scripting utility from Microsoft. Use this tag for questions about writing and executing PowerShell scripts ONLY. Programming questions specific to the cross-platform version PowerShell Core (Windows, macOS, and Linux) should be tagged [powershell-core]. Questions about system administration should be asked on Super User or Server Fault.

powershell
0 votes
0 answers
5 views

renaming folders and files in large file tree

I have a large file tree with around 954,000 files. There are tons of files that I need to rename back to the original, symbols were removed from the original file name and replaced with a number code ...
1 vote
2 answers
39 views

Powershell : Cannot convert the "java" value of type "System.String" to type "System.Management.Automation.ScriptBlock"

I have a powershell script which converts the String and String[] into a BlockScript. It was working until now but it starts to fail suddenly after some windows upgrade. function Invoke-...
1 vote
3 answers
50 views

Powershell: add new line after every line that contains a given string

I have a >7000 line XML file, which I define as $File, and which contains (scattered throughout all the other lines) four lines exactly as follows: <text:p text:style-name="P27">&...
0 votes
2 answers
54 views

How to make PowerShell `Select-String` aka `sls` output exact match(es) only?

In a PowerShell script, I would like to check if a branch exists locally already, which I'm currently doing as $existsInLocal = (git branch | sls $branch) -ne $null, but that's incorrect because sls $...
0 votes
1 answer
50 views

PowerShell StandardOutput Redirect Issue

I am trying to use ghostscript to get the number of pages in a PDF. I am getting this error: Select-Object : Exception getting "StandardOutput": "StandardOut has not been redirected or ...
0 votes
1 answer
18 views

How to prevent the message "File open in another application" when creating excel instance

I was running a PowerShell script perfectly fine earlier, but for some reason this message popped up that's saying the file is open in another application. I have checked task manager and the excel ...
3 votes
1 answer
1k views

Try catch in PowerShell still showing error

This is my code: try { $usernames = Get-LocalUser | Where-Object { $_.enabled -EQ 'True' } | Select-Object 'Name' $usernames | ForEach-Object { Add-LocalGroupMember -Group 'Hyper-V ...
0 votes
1 answer
62 views

How to extract full monitor manufacturer/vendor ID in Windows? (as same as Linux hwinfo --monitor command)

I´m stuck with extracting hardware information of my monitor manufacturer ID in this format: xxxxx_xxxxxxx Basically, format which provides Linux command hwinfo --monitor as "vendor" ...
1 vote
2 answers
49 views

Place every item from a text file into an array but detect headers/titles

I have text files that contain Firstname: xxx Lastname: yyy Login: abcd It has many others entries for other definitions but all in the same format header: data I would like to use an array in ...
0 votes
0 answers
13 views

PS: Redirecting error output of assignment statement to a variable

I am calling PnP-GetWeb like this: [Microsoft.SharePoint.Client.SecurableObject]$Web = Get-PnPWeb -Connection $pnpConnection -ErrorAction SilentlyContinue if($null -eq $web) { throw &...
0 votes
0 answers
6 views

Is it possible to run Connect-IPPSSession, Connect-ExchangeOnline using pwsh on a linux server?

I am trying to use the Powershell ExchangeOnlineManagement module, but I have to perform some automations on a Linux RedHat server and I would like to know if it is possible to execute commands like ...
10 votes
4 answers
30k views

Powershell redirect stderr and stdout to two different places

How do redirect stderr to logfile stdout to object Things I've looked at: >> and 2>> only redirect to file . -RedirectStandardOutput and -RedirectStandardError only redirect to ...
0 votes
2 answers
2k views

Start multiple transcripts in Powershell

I have a script that loops through a CSV file and create an AD user for each line in the file. I want to have a first transcript for the entire master job and also a separate second transcript for ...
1 vote
1 answer
17 views

Yarn PM not working in Windows when the User folder(UserProfile env var) has space in folder name or path

As stated in title, the Yarn PM(package manager), that I just installed in my system(Windows 11 64Bit) doesn't work if there's space(s) in my UserProfile folder path. My User folder name is "...
1 vote
2 answers
23 views

I get wrong process id number after launch brave profile with Start-Process

I want to open some brave profiles and close them later. So I want to save process id's on a file and iterate them to close it. But Id returned from Start-Process is not a real Id and I can't find ...

15 30 50 per page
1
2 3 4 5
7876