Skip to main content

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
560 votes
5 answers
786k views

How do I run multiple commands on one line in PowerShell?

In a cmd prompt, you can run two commands on one line like so: ipconfig /release & ipconfig /renew When I run this command in PowerShell, I get: Ampersand not allowed. The `&` operator is ...
David's user avatar
  • 9,444
508 votes
15 answers
2.5m views

How to enable execution of PowerShell scripts?

When I try to execute my PowerShell script I get this error: File C:\Common\Scripts\hello.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help ...
Pavel Chuchuva's user avatar
354 votes
12 answers
622k views

Native alternative to wget in Windows PowerShell?

I know I can download and install the aformentioned library (wget for Windows), but my question is this: In Windows PowerShell, is there a native alternative to wget? I need wget simply to retrieve ...
jsalonen's user avatar
  • 9,091
286 votes
6 answers
181k views

Equivalent of cmd's "where" in powershell

I can't seem to find anything about a Powershell equivalent of the where command from cmd. Should I just call it from cmd or is there something more elegant in PS?
user avatar
282 votes
14 answers
372k views

Equivalent of Linux `touch` to create an empty file with PowerShell [duplicate]

Is there an equivalent of touch in PowerShell? For instance, in Linux I can create a new empty file by invoking: touch filename On Windows this is pretty awkward -- usually I just open a new instance ...
jsalonen's user avatar
  • 9,091
220 votes
9 answers
638k views

PowerShell equivalent of curl

Is there an equivalent of curl in PowerShell? Does it have some similar built-in capability or is there a 3rd party cmdlet?
Borek Bernard's user avatar
197 votes
10 answers
138k views

PowerShell equivalent to the Unix `which` command?

Does PowerShell have an equivalent to the which command found in most (if not all) Unix shells? There are a number of times I'd like to know the location of something I'm running from the command ...
Herms's user avatar
  • 9,742
147 votes
6 answers
94k views

What is Windows' equivalent of the "which" command in Unix? Is there an equivalent PowerShell command?

In Linux, we have the "which" command to find out the path of an executable. What is its Windows equivalent? Is there any PowerShell command for doing that?
user avatar
138 votes
11 answers
432k views

Copy and paste in Windows PowerShell

How do I effectively copy and paste input and output in the Windows PowerShell?
orschiro's user avatar
  • 3,665
126 votes
16 answers
481k views

Delete all files from a folder and its sub folders

I want to remove all files from a folder structure, so I'm left with an empty folder structure. Can this be achieved in either batch or VBScript scripting? I have tried a very basic batch command, ...
RobN's user avatar
  • 1,692
109 votes
10 answers
530k views

how to run a powershell script as administrator

On my Windows 7 Desktop, I have script.ps1, which needs admin privileges (it starts a service). I want to click on this script and run it with admin privileges. What's the easiest way to ...
Sajee's user avatar
  • 6,529
107 votes
4 answers
257k views

have Powershell get-childitem return files only

I'd like to use get-childitem recursively, but only have it return files not directories. The best solution I have just doesn't seem natural: gci . *.* -rec | where { $_.GetType().Name -eq "FileInfo"...
Frank Schwieterman's user avatar
100 votes
9 answers
79k views

Turning off the cmd window beep sound

Is there a way to essentially mute the Beeping function of the Windows command shell? I'm working on a PowerShell script right now which ends up printing several lines of text to the screen. I'm ...
JaredPar's user avatar
  • 1,291
100 votes
18 answers
201k views

Linux "Top" command for Windows Powershell?

I am looking for a PowerShell cmdlet that can provide similar functionality to the Linux Top app. Something that refreshes at some given interval and displays the process list with CPU % util. I have ...
user avatar
94 votes
3 answers
56k views

Disable PowerShell beep on backspace

This feature seems to have been added in PowerShell version 5.1, as I don't find it on my laptop still running 5.0. When pressing Backspace in PowerShell, it will emit a 'beep' sound if there is no (...
FastEthernet's user avatar
  • 5,067
91 votes
2 answers
351k views

run powershell command from cmd

how i can run this command from cmd : powershell.exe "(get-process | ? {$_.Description -eq "Sysinter Process Explorer"}) | select processname | out-file $env:APPDATA\example.txt" i still get ...
Qassam Mahmoud's user avatar
85 votes
9 answers
129k views

How to copy text from PowerShell

Sometimes I want to copy a command from Powershell to paste in a document, or I want to copy the output? How can I select and copy text in Powershell? At least I know a way how to paste a text (or a ...
Anatoly Mironov's user avatar
72 votes
1 answer
22k views

I ran a PowerShell script. Was I hacked?

I was an idiot and was suckered into running a PowerShell script. What are the details about it? I have a feeling they only uploaded some files from my system. But I am worried there may be a backdoor ...
Moon's user avatar
  • 763
71 votes
4 answers
65k views

Detect if PowerShell is running as administrator

How can I tell in my scripts if PowerShell is running with administrator privileges? I need to know because I'm trying to run a program that requires the ability to open protected ports.
Boomerang's user avatar
  • 871
69 votes
5 answers
181k views

How to find WSL2 machine's IP address from windows

This question is related to my question about making a WSL2 address static. Since that looks like it isn't possible I am trying to come up with a workaround. I am thinking I can run a shell script in ...
Nick's user avatar
  • 1,463
68 votes
10 answers
64k views

Configure Windows PowerShell to display only the current folder name in the shell prompt

I'm using PowerShell on Windows 7. How can I configure PowerShell so that it only displays the current folder name (instead of the full path) in the shell prompt? For example, instead of C:\folder\...
Veera's user avatar
  • 837
68 votes
4 answers
62k views

Powershell equivalent of `grep -r -l` (--files-with-matches)

In Powershell, how do I list all files in a directory (recursively) that contain text that matches a given regex? The files in question contain really long lines of incomprehensible text, so I don't ...
Michael Kropat's user avatar
67 votes
2 answers
70k views

How do you create a new symlink in windows 10 using powershell (not mklink.exe)?

If there's docs on it, I'll take that. Any web searches for "symlink" "symbolic link" "windows [10]" "powershell" returns everything except the base command. Even the powershell docs site returns ...
monsto's user avatar
  • 1,558
67 votes
8 answers
56k views

pbcopy for Windows?

In MacOSX there's a command which can pipe the output of a command to the clipboard so that it can be pasted somewhere else in the GUI. How can this be done from cmd.exe or with a PowerShell cmdlet?
leeand00's user avatar
  • 22.7k
63 votes
8 answers
221k views

Nano alternative for windows powershell

I am looking for software similar to nano for linux bash but for windows powershell. Is there any built in so I do not have to install something? EDIT Nano is a text editor that runs within the bash....
John Demetriou's user avatar
61 votes
2 answers
102k views

Windows 10 Powershell tree command, how to show files

How do I list folders and files using the PowerShell tree command? Is it possible to color format the output for distinct files and folders?
Tuomas Toivonen's user avatar
61 votes
7 answers
297k views

netstat with process name?

Using netstat -a -o -n I can get the list of ports and PID then I need to go to task manager and add the PID and see who is it. (pretty frustrating) I was wonder if there is a CMD command which ...
Royi Namir's user avatar
  • 5,788
60 votes
5 answers
140k views

Changing last modified date or time via PowerShell

Is it possible to change a file or folders last modified date/time via PowerShell? I have a folder folder1/ and I want to change the last modified date and time of that folder and it's contents via ...
Jack's user avatar
  • 841
60 votes
2 answers
29k views

Configure Powershell to be conemu's default shell

Is it possible to configure Powershell to be conemu's default shell? I know I can add additional "tasks" to conemu but I want it to default to use Powershell instead of cmd.exe so that, for example, ...
nathanchere's user avatar
  • 2,376
59 votes
6 answers
40k views

Why does Powershell silently convert a string array with one item to a string

Consider the following Powershell script, which searches for folders in C:\ with a 'og' in their name: PS C:\> (ls | %{$_.Name} | ?{$_.Contains("og")}) PerfLogs Program Files setup.log Now I narrow ...
Jonas Sourlier's user avatar
56 votes
5 answers
23k views

How do I permanently remove a default Powershell alias?

For some unknown reason, the devs included "curl" as an alias for Invoke-WebRequest, even though it is not compatible with the proper implementation of curl, which means it gets in the way when I try ...
Nathan Ridley's user avatar
56 votes
1 answer
34k views

Does Powershell have any sort of .bashrc equivalent?

I have some functions I'd like to load by default when I open an administrative powershell. Is there any equivalent to say .bashrc or .profile that I could use to automatically import the scripts ...
leeand00's user avatar
  • 22.7k
56 votes
10 answers
30k views

Cannot change powershell default font to Lucida Console

This is a trivial problem, but it annoys me that I can't get to the bottom of it: I'm running Windows 8, Powershell version 3.0. By right-clicking on the title bar I can go into the Properties and ...
IHaveAStupidProblem's user avatar
55 votes
9 answers
65k views

Change directory to previous directory in Powershell

I am a Linux guy, but am trying to be open-minded and learn some Powershell. I miss the ability to cd - back to a previous directory, like in *nix shells. Is there a similar command in Powershell&...
Kazark's user avatar
  • 3,479
54 votes
3 answers
138k views

How do I set an executable's working directory via the command line, prior to executing it?

If I run a program on the command line whose location is resolved through the Path environment variable, the program's working directory is generally set to its installation directory. I would like ...
Steve Guidi's user avatar
53 votes
8 answers
137k views

Powershell to delete all files with a certain file extension

I want to scan a directory (there are no subs) and delete any file with an extension of .avi I tried this syntax, but no errors are thrown, and no files are deleted. This is the code I tried get-...
user2676140's user avatar
  • 2,095
52 votes
5 answers
95k views

Windows PowerShell equivalent to Unix/Linux `pwd`?

In follow-up to the cmd.exe question, what is the PowerShell equivalent to echo %cd%, or Linux/Unix pwd?
warren's user avatar
  • 10.2k
52 votes
2 answers
122k views

Is Windows PowerShell as powerful as the terminal of Unix/Linux? [closed]

Is Windows PowerShell as powerful and efficient as Linux' terminal? People offline tell me, without explaining much, that Windows PowerShell is an attempt to make Unix administrators feel more ...
kern's user avatar
  • 685
52 votes
3 answers
59k views

Programatically associate file extensions with application on Windows

I've just recently reinstalled Windows and in setting up my environment I've noticed that all my associations for the various programming languages I edit in Notepad++ have gone (naturally). I am ...
deed02392's user avatar
  • 3,072
52 votes
6 answers
56k views

How to maintain ssh-agent login session with Windows 10's new OpenSSH and PowerShell

On my Ubuntu machine, I simply use Keychain to maintain a single ssh-agent which stays logged in. I'd like something similar to that on Windows now that OpenSSH is natively included. I was using Git ...
Southclaws's user avatar
51 votes
7 answers
123k views

How do I get get-childitem to filter on multiple file types?

I'm trying to get a list of all the XSL and XSLT files in a directory. dir -recurse -filter *.xsl,*.xslt -name But the following error: Get-ChildItem : Cannot convert 'System.Object[]' to the ...
user avatar
51 votes
10 answers
179k views

Update Powershell through command line

I want to update a machine's Powershell version. Can this be done through the command line? My present need is to update from PS 4 to PS 5 on a Windows server 2012R2. I guess there is no catch-all ...
LosManos's user avatar
  • 843
50 votes
2 answers
10k views

How do Windows version numbers work?

I often come across texts where a Windows version is referred to as a four digit number, e.g. Microsoft is urging users of Windows 10 version 1903 to install this month's SSU or 'servicing stack ...
ProfK's user avatar
  • 2,651
49 votes
7 answers
85k views

Show human-readable file sizes in the default PowerShell ls command

How can I modify the default ls (Get-ChildItem) in PowerShell so that it displays human-readable file sizes, like ls -h on a *nix machine? ls -lh does simple logic with the file size, so that it ...
Tom Mayfield's user avatar
  • 1,487
47 votes
3 answers
31k views

Replacements for ampersand and double-ampersand in PowerShell

In Windows' native CMD processor, you can use & to string commands together so that one runs immediately after the other. A && will run the second command only if the first completes ...
Iszi's user avatar
  • 13.9k
47 votes
2 answers
268k views

Where is the known_hosts file for OpenSSH for Windows?

One of the servers I frequently log into via SSH has changed it's IP address. So, now I'm getting man in the middle attack warnings when I try to use SSH via Windows Powershell and OpenSSH for Windows....
anschauung's user avatar
46 votes
7 answers
70k views

tmux/screen alternative for powershell

Is there an alternative to tmux/screen that would work on Windows with Powershell? I'm aware of Powerscreen, but it seems dead for a long time. Cygwin wouldn't work with Powershell, would it? Console2 ...
sumek's user avatar
  • 697
46 votes
4 answers
58k views

tee for Windows?

Does Windows provide the basic tee facility for copying standard input to an arbitrary set of files and then back out to standard output? I generally download a generic tee program, but curious if ...
Jé Queue's user avatar
  • 930
44 votes
1 answer
58k views

Equivalent of bash's `source` command in Powershell?

To run a bash script line-by-line (so as to preserve environment variables, for instance), one does the following: $ . myscript.sh Or: $ source myscript.sh I have a PowerShell script that - among ...
Sridhar Ratnakumar's user avatar
44 votes
7 answers
98k views

How to enable Internet Connection Sharing using command line?

I can do it manually by right-clicking on a network connection, opening the Sharing tab and clicking on the "Allow other network users to connect through this computer's Internet connection" check box....
utapyngo's user avatar
  • 1,933

1
2 3 4 5
118