Questions tagged [powershell]

Windows PowerShell is a command line shell and scripting language for Windows that supersedes the CMD.exe shell and batch language. PowerShell is also an automation engine for Windows that provides functionality similar to Windows Script Host and VBScript.

Filter by
Sorted by
Tagged with
1 vote
1 answer
32 views

How to delete a line based on a regex string in Powershell?

I want to validate if the line above a certain line is there, then ok. if else, then delete that line and remove the empty space ? Can this be done in powershell? please help If before all lines ...
1 vote
0 answers
21 views

How to force install a windows optional feature which was completely deleted and is absent from the Dism /online /Get-Features?

The original Windows 11 installer ISO was modified to work in a constrained resources settings and thus had completely removed the trace of most of the Windows' components, packages, or features to ...
1 vote
1 answer
29 views

Prevent certain commands from being logged by history in powershell

In bash, if you don't want some chore commands to be remembered by history, for instance dir or cd.. or h, you can put them in HISTIGNORE. Is this possible in powershell?
  • 175
1 vote
1 answer
41 views

How to add lines above and below a certain line in Powershell based on regex pattern?

03,201779,,01354,73923309,,,TEST2,7962753,,,0343,5087632,,/#end of line 04,399,777873,,,,text234,,,,/ 33,TEST1,,,0343,,93493,,,343,,,,TEST3,,,,,,/ 37,TEST37,text 49,24605597,6,343,343,343,,,3434,,,/ ...
2 votes
1 answer
31 views

Is `Get-Help -online` in powershell supposed to work on about_* pages?

I'm new to powershell and I find myself always preferring the -online flag when using Get-Help. But it seems about_ pages don't work with Get-Help -online: Get-Help about_* | ForEach-Object { Get-Help ...
  • 175
1 vote
0 answers
27 views

Power shell: after output, scroll to the very top

I have the script below, that is meant to be tailing something I'm outputting with a python script. The issue is that memorizer_output.txt can get very long, and I'd like the powershell to scroll to ...
  • 113
1 vote
0 answers
31 views

PowerShell start not complete

PowerShell td;dr PowerShell runs only as Admin symptome if I run PowerShell.exe it runs until window is open then stops and just shows: Windows PowerShell Copyright (C) Microsoft Corporation. Alle ...
1 vote
1 answer
40 views

Powershell rename with variable and special characters

I’m trying to rename some files. In the path and filename there are symbols like [, ] and spaces. The rename command says it can´t find the file. There is a main file with the symbols and a "temp&...
  • 57
0 votes
0 answers
19 views

Are Classes defined through P/Invoke not allowed to be executed remotely?

To get it out the way: I understand there are different ways to go about this such as Get-ChildItem. So, I have a custom class I'm defining to get rid of some of the overhead PowerShell cmdlets have, ...
1 vote
1 answer
42 views

Is there a way to easily compare driver versions between computer A and computer B?

I have a gold standard machine that contains all the correct drivers and I want to know if there is an easy way to compare the driver version between computer A and computer B (both with identical ...
  • 945
1 vote
1 answer
38 views

PowerShell and Windows Terminal: how to apply IntelliSense suggestion?

Using Windows Terminal (1.15.3465.0) and PowerShell (7.3.2) I get autocomplete suggestion, like in the picture below (ed255196 -C "<comment>" is suggested completion). However, I am ...
2 votes
1 answer
37 views

Is there a way to copy the contents of an ISO file to a specific windows partition and boot from it?

I'm currently trying to accomplish the following from the windows command line / powershell - create a bootable partition from an ISO, add a boot entry for it and boot from it. It's important to note ...
0 votes
2 answers
61 views

How to create a new PowerShell project from Visual Studio?

How do I install a workload for Visual Studio to work with PowerShell? From the console: PS C:\WINDOWS\system32> PS C:\WINDOWS\system32> code --help code : The term 'code' is not recognized as ...
2 votes
1 answer
24 views

Trying to Output Battery CycleCount via Powershell on a single line

The command I am using is the following: Get-WmiObject -Namespace 'root\wmi' -Class MSBatteryClass | select CycleCount The output seems to be inconsistent and out puts multiple lines underneath ...
  • 23
2 votes
1 answer
41 views

PowerShell `Microsoft.Update.Session`; unable to download all updates

How can I at the very least see what Microsoft.Update.Session is doing behind the scene, if not identify outright why downloads are not completing? I am using Microsoft.Update.Session to try and force-...
1 vote
2 answers
39 views

Powershell - How to scroll through the output using a keyboard?

I am using Windows 10 - PowerShell to connect to some VPS over ssh. How can I scroll up/down through the screen buffer (I have 6000 height set in Screen Buffer Size) using only keyboard. I've already ...
0 votes
0 answers
23 views

Why is Resize-Partition not working in WinPE?

I'm currently playing around with making my 'own' MDT / Deployment Software using PowerShell and encountered an issue that I can't find any information to. Basically I already created the EFI, MSR and ...
  • 1
0 votes
0 answers
10 views

How can i add a "launch fluent terminal" button alongside cmd and powershell?

win+x, file menu from file explorer, all over the place there is quick and easily accessible ways of opening cmd and or powershell can i add an open fluent terminal button or replace them with one ...
0 votes
2 answers
31 views

Powershell script Select sort output by number

The following powershell script outputs a server diskspace report. Is there a way of sorting the 'Percent' data in either desc or asc order? [Script] $computers | ForEach { $Disks = Get-WMIObject ...
2 votes
1 answer
25 views

PowerShell, properly association .jar files with java.exe or javaw.exe

Using the answer from this question Copy Java installation to another system I can manually install Java (without running the installer) and port it to other systems. This works well. However, I still ...
  • 579
0 votes
1 answer
30 views

determine what time I connected to the vpn from command line

How do I find what time I connected to a vpn using powershell or cmd? I would only be doing this when there's an active connection to the vpn and would only need the time that I established the ...
  • 103
1 vote
2 answers
64 views

Add header efficiently to a large CSV file using PowerShell

I need to add headers to a large CSV file (900+MB) but PowerShell stalls for 3 hours+ on my system and sometimes even crashes. Question: Is there a way to stream the data through instead of loading ...
  • 11
0 votes
1 answer
46 views

PowerShell Script to display service status and if stopped rename folder

What am I doing wrong? It will not rename folder if service status is stopped? $computers =("GT08544","GT08545") $arrService = Get-Service -Name Spooler Get-Service -ComputerName $...
  • 1
0 votes
0 answers
36 views

What is the SKU Description for Windows 10 Enterprise LTSC?

I have a script that relies on SKU numbers and descriptions. This works fine for all operating systems except for LTSC apparently. For example, this is selection of some of the output for Windows 10 ...
  • 101
0 votes
0 answers
18 views

How to add new 3 line in response to a specific 3 line in nginx.conf file using powershell script

For example, in the nginx.conf file, delete the following 3 lines and add the value in $replace log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '...
1 vote
1 answer
23 views

New-IISSiteBinding returns binding already exists, but binding does not exist in IIS

I'm trying to import IIS Bindings from a json file into IIS using PowerShell. But whenever I run the following command: New-IISSiteBinding -Name "IIS Site Name" -BindingInformation *:443:...
0 votes
0 answers
41 views

SSH key authentication works from Linux but not from Windows

Three machines: A (Ubuntu), B (Windows) and C (Ubuntu) I have run ssh-keygen/ssh-keygen.exe on A and B. ~/.ssh/id_rsa.pub from both A and B are alive and well in ~/.ssh/authorized_keys. When I run ssh ...
1 vote
0 answers
34 views

Remove all pinned apps in start menu using power shell

Im making a script that cleans a fresh install of windows 11 to my liking. Does anybody know of a way to unpin all apps in start menu using PowerShell? I have found scripts but those scripts are name ...
  • 151
1 vote
0 answers
38 views

Downloading and Installing fonts using powershell commands only

Im making a powershell script to install and initialize oh-my-posh on a windows 11 terminal. The problem im having is oh-my-posh requires a font called CaskaydiaCove Nerd Font (or other nerd font) ...
  • 179
1 vote
0 answers
31 views

Why doesn't the login screen show a created New-LocalUser or the Administrator account?

Login is with a pin code and right clicking on cmd allows running in an elevated mode as Administrator so that new accounts can be created: adding a user: PS C:\Windows\System32> PS C:\Windows\...
0 votes
1 answer
68 views

Can't update wsl even when running PowerShell as admin

I'm trying to update my default WSL distribution and even though I'm running PowerShell as an admin I get this error. What am I doing wrong?
2 votes
1 answer
49 views

Extract msu files from Windows 10 22H2 ISO

I am trying to generate msu files from Windows 10 22H2 ISO file. I couldn't find any on that in Google so I believe that this make no sense. Is there any other way to generate msu files since ...
  • 23
5 votes
1 answer
417 views

Why do I get duplicate network interfaces?

While troubleshooting connectivity issues on my PC, I noticed that I have duplicate of every network interface when issuing Get-NetIPInterface command on PowerShell. Notice how each interface has a ...
  • 203
1 vote
0 answers
38 views

Disallow standard Users from generating Resultant Set of Policy data

how to restrict users to see Rsop data such as gpresult /r /x and all data in group policy managements i mean i want users can't see any Rsop data i want if users opened group policy managements or ...
  • 11
0 votes
1 answer
86 views

Fascinating issue with Get-Service to list services; fails listing *all* services due to one causing an issue

Question: as "normal" UAC-elevated user (i.e. member of the BUILTIN\Administrators alias, but not .\Administrator), how can I list all services using Get-Service and sidestep the issue ...
  • 6,417
1 vote
2 answers
25 views

Trying to colour code the output of tracert within powershell - not working as expected

I'm trying to colour the lines green, yellow and red within powershell depending on the latency in milliseconds. Our remote workflow dictates that anything over 40ms is bad, so I want this to be ...
  • 945
0 votes
0 answers
32 views

Script to check SMB status on multiple servers

I am looking to check the SMB version and status on a list of servers. it would be nice to be able to have a list of server, such as a CSV and run the SMBconnection command against each of the ...
  • 1
2 votes
2 answers
62 views

Return exact match from content in a file using PowerShell or batch

This is my powershell script: $Apache_port = Get-Content -Path C:\tmp\httpd.conf | Select-String -Pattern 'Listen' echo $Apache_port But I am getting result like this: # Listen: Allows you to bind ...
1 vote
0 answers
75 views

How to find port on windows (using pid or processes name)

I know the PID, but I need the port on which the processes are running. specifically want only the port of a processes, I know the name and PID of that processes, how to find the port
0 votes
0 answers
49 views

How do I specify chmod 744 in Windows Powershell recursively?

Was going to comment on this question but I do not have the rep. Is there a way to do this recursively? I would like to give all privileges to any administrator user. Nothing I do in the windows GUI ...
0 votes
0 answers
42 views

Powershell.exe command keeps opening 2x during windows 10 Launching

powershell.exe -noexit -command Set-Location -literalPath '%V' HOW do i delete this regkey??? its blocked for removal, everytime i launch my windows 10 i get 2x a powershell.exe scipt opening this ...
0 votes
0 answers
10 views

Combine ESET log files with Powershell

I want to combine logfiles from ESET antivirus to analyze them easily. These log files are automatically split by ESET when they reach a specified size (102400ko) in two or more files. The problem is ...
  • 1
4 votes
2 answers
557 views

Is it possible to modify the WinKey + X menu in Windows 10?

This question is related to codewario's comment on his anwser to this question. I have installed version 7 of PowerShell, and I would like this version to be invoked when clicking on the "Windows ...
0 votes
0 answers
29 views

Apply policy to non-administrative users using PowerShell

I have disable the use of removable media to non-administrator users using MMC console to apply a local policy and setting Removable Disks: Deny read access for non-administrators. I'd like to set ...
  • 121
0 votes
0 answers
34 views

I need to write a script that removes all printers, but leaves behind the print to PDF + Fax. It also needs a sanity check, eg found 6 removed 6

I need a little help making a script that removes all printers, ports and drivers apart from the default microsoft offerings such as fax and print to pdf, and any epson printers as those are for ...
  • 3
2 votes
2 answers
59 views

Set Console Colors when Creating Shortcut with PowerShell

I can use code like this to create a shortcut file in PowerShell: $WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$PSScriptRoot/myshortcut.lnk") $...
  • 1,068
1 vote
1 answer
30 views

How to determine whether a Windows 10 workstation is connected to the LAN via hard-wire and/or wi-fi?

Our company uses many Microsoft Access applications in various departments and workgroups for data gathering and reporting. With more of the desktop workstations being replaced with laptops, we run ...
  • 13
0 votes
1 answer
20 views

Get an error Remove-Item : Cannot bind parameter 'ErrorAction' after deactivating conda environment

Windows 7, Anaconda 2019.10, python 3.11.0 hcf16a7b_0_cpython conda-forge. After activating the env and then deactivating in powershell it I get this error: Remove-Item : Cannot bind parameter '...
0 votes
1 answer
34 views

Powershell script to stop services and set to manual

I hope this is in the correct place. I know this question has been asked a lot before but I can't quite find what I need. I am looking for a script to run on several remote servers at once to stop a ...
0 votes
1 answer
65 views

WIndows 11: Is it possible to run Powershell command as Administrator on Startup?

I've just installed Windows 11, and I'm using Chocolatey for package management. For this, I would like to run an auto-upgrade of applications when Windows is starting up. So at startup, I need to run ...

1
2 3 4 5
108