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
2 votes
0 answers
369 views

Running code . in WSL / Command Prompt opens two instances of VS Code [closed]

I'm working with WSL2 with Visual Studio Code by running code . in Ubuntu terminal. I'm creating an application, in the code of this application I'm using winsock2.h header. The Visual Studio Code ...
Asaf's user avatar
  • 51
-1 votes
1 answer
708 views

How can I remove the powershell banner in vscode?

Everytime I use the terminal for a code, vscode sents this banner. How can I remove it? It says: Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Install the latest ...
Saverio's user avatar
5 votes
1 answer
6k views

What is the ampersand sign (&) before commands in PowerShell?

I was trying out a command by typing the path to it, and when I hit TAB, this happened: C:\> C:\Program Files\KeePassXC\keepass<TAB> # became this: C:\> & 'C:\Program Files\KeePassXC\...
toraritte's user avatar
  • 748
1 vote
1 answer
451 views

Powershell batch command: Cannot escape backslash by doubling it when using "notlike"?

This Powershell command works in a batch file to remove all lines from %tempFile% that contain the text string foo powershell -NoProfile -ExecutionPolicy Bypass -Command "gci %tempFile% | foreach ...
bat_cmd's user avatar
  • 541
1 vote
1 answer
538 views

How to import a module in PowerShell from a String variable?

I have a PowerShell script stored as a variable in memory: $v = Invoke-WebRequest -Uri http://url/with/module.ps -UseBasicParsing $s = $v.toString() I'd like to now do something like Import-Module $s....
TMOTTM's user avatar
  • 219
0 votes
1 answer
93 views

How can I make gitlab suppress powershell input from the job log?

I’ve set up a runner on a Windows 10 laptop. Worker type shell. In all steps of the job we can see under-the-hood gitlab commands being executed with local echo on the terminal. Included here are ...
Nilzor's user avatar
  • 4,519
-1 votes
2 answers
3k views

Does Windows Server 2022 support Powershell Version 7?

Does Windows Server 2022 support Powershell 7? Based on what I've seen so far, it looks like it supports 5.0 out of the box. I've googled around a bit and it looks like it's supported on Windows 10/11,...
John Buczkowski's user avatar
0 votes
1 answer
418 views

how to capture all commands being done from exe in powershell?

I have an exe file that making some commands on cmd and powershell I want to know this commands I have tried this notepad (Get-PSReadlineOption).HistorySavePath but it gave me my commands not the ...
Sycho AN's user avatar
0 votes
1 answer
628 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 ...
coder234's user avatar
1 vote
0 answers
1k 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 ...
user3330840's user avatar
4 votes
1 answer
1k 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?
ZYinMD's user avatar
  • 317
1 vote
1 answer
1k 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,,,/ ...
coder234's user avatar
2 votes
1 answer
74 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 ...
ZYinMD's user avatar
  • 317
1 vote
0 answers
204 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 ...
shintuku's user avatar
  • 113
1 vote
0 answers
164 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 ...
Thomas Richter's user avatar
1 vote
1 answer
1k 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&...
Err0r's user avatar
  • 87
3 votes
1 answer
144 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, ...
Abraham Zinala's user avatar
1 vote
1 answer
503 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 ...
Mastaxx's user avatar
  • 1,218
14 votes
1 answer
5k 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 ...
Dariusz Woźniak's user avatar
2 votes
1 answer
368 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 ...
Yoan Sredkov's user avatar
0 votes
2 answers
4k 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 ...
Nicholas Saunders's user avatar
1 vote
1 answer
820 views

Via Powershell Cannot Format Disk with File System NTFS?

Via Powershell Cannot Format Disk with File System NTFS? The following code works up until the format attempt. The script is run as administrator. Not the file system is NTFS. The block size is the ...
Jibun no Kage's user avatar
2 votes
1 answer
117 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 ...
EvanIT's user avatar
  • 23
2 votes
1 answer
1k 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-...
branpurn's user avatar
3 votes
2 answers
4k 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 ...
michal roesler's user avatar
0 votes
0 answers
258 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 ...
Nick's user avatar
  • 1
0 votes
2 answers
1k 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 ...
Bra Tabs's user avatar
2 votes
1 answer
739 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 ...
YorSubs's user avatar
  • 919
0 votes
1 answer
811 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 ...
Russ's user avatar
  • 103
1 vote
2 answers
900 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 ...
Re1iant's user avatar
  • 13
0 votes
1 answer
625 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 $...
Ken's user avatar
  • 1
1 vote
1 answer
1k 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:...
Koen van der Borght's user avatar
1 vote
0 answers
866 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 ...
user1767525's user avatar
2 votes
2 answers
11k 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 ...
Jack's user avatar
  • 161
2 votes
1 answer
1k 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) ...
DrakeJest's user avatar
  • 197
2 votes
1 answer
374 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\...
Nicholas Saunders's user avatar
0 votes
1 answer
993 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?
Adam Arold's user avatar
2 votes
1 answer
667 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 ...
Eric's user avatar
  • 23
5 votes
1 answer
1k 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 ...
LPVOID's user avatar
  • 203
0 votes
0 answers
133 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 ...
RedOne's user avatar
  • 9
1 vote
1 answer
1k views

'Get-Service' fails to list *all* services due to one causing an issue

As a "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 described ...
0xC0000022L's user avatar
  • 7,062
1 vote
2 answers
102 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 ...
Mastaxx's user avatar
  • 1,218
0 votes
0 answers
3k 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 ...
Magic's user avatar
  • 1
2 votes
2 answers
3k 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 ...
anand8398's user avatar
2 votes
2 answers
4k 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
anand8398's user avatar
0 votes
0 answers
298 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 ...
Ray Tayek's user avatar
0 votes
0 answers
272 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 ...
Richard Driver's user avatar
4 votes
2 answers
1k 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 ...
Thomas.M's user avatar
  • 141
0 votes
0 answers
195 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 ...
anderZubi's user avatar
  • 121
0 votes
0 answers
726 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 ...
Sharpe's user avatar
  • 5

1
9 10
11
12 13
117