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.

learn more… | top users | synonyms

2
votes
1answer
3k views

How can I sort objects by third column in Powershell?

I've a text file like this: 4108689096 2531 ./ssss/132432.odt 481446057 2293 ./abc/a.txt 3157353085 1096 ./dsjvbjf/c.docx 653380669 1824 ./bcd/x.avi And I'd like to achieve in Powershell to sort ...
15
votes
2answers
9k 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 ...
7
votes
3answers
2k views

Get definition of function and echo the code

I've defined a dynamic function in powershell, like this: > function test { dir -r -fil *.vbproj | ft directory, name } Then I can just type test and run that function, piping it to other ...
0
votes
2answers
2k views

Not able to run powershell script from autosys

I am new to powershell and using 1.0version and am trying to write a powershell script that I can execute using autosys scheduler. When the I run the command in autosys powershell -command "& { %...
4
votes
3answers
3k views

How to quickly save what is currently shown in cmd.exe to a file

I am asking if there is a quick way/command to save the current standard output from cmd.exe or powershell to a file. For example, I have run a bunch of commands in cmd.exe which generating like ...
0
votes
2answers
2k views

How do I cd to a symlink in PowerShell?

I've created a symbolic link like so: PS C:\dev\bin> cmd /c mklink "wd" c:\dev\code symbolic link created for wd <<===>> c:\dev\code OK, simple. So then I try to cd to it: PS C:\...
1
vote
1answer
81 views

how can I make a sym link that is available anywhere (via command line) in Windows 7?

In Ubuntu I've been using: cd ~/theApp to get to a frequently used directory. Is there a Windows equivalent? I'm looking for a sym link (via mklink) that is available no matter where I am. Would ...
1
vote
1answer
364 views

PowerShell prompt here

I'm using this small script from here to append an entry to opening PowerShell from the context menu when clicking on a folder. However, I'd like to change its behaviour in order to open the ...
16
votes
3answers
7k 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 ...
1
vote
0answers
566 views

How do I add fileversion to an object containing a number of filenames?

I have loooked for an answer to this question, but cannot find out how to add into an object creating a data-set pair of file name and version, and the related original wsp or cab filename. I have a ...
1
vote
1answer
1k views

Loop through several servers, find specific dlls , get the dll version, internal filename and path?

I am new to Powershell, and using PS v2. I can see the massive potential it has, but I just can't get the following code to work fully. I am trying to end up with a csv file that contains the wild ...
19
votes
2answers
21k 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 ...
0
votes
2answers
1k views

can I get powershell to properly copy multiline text like Bash in Ubuntu does?

I use an Ubuntu VM at home for Rails development and I've gotten a bit spoiled by Bash. When I copy multiline text from Bash, it seems like it's pretty good about knowing that text is single line or ...
4
votes
1answer
6k views

is there equivalent of rsync in MS powershell?

Rsync is very useful, I don't have to copy all files in a directory. It updates only the newer files. I use it with cygwin but I think there are some inconsistencies, which are not the main focus of ...
42
votes
6answers
87k views

Copy and paste in Windows PowerShell

How do I effectively copy and paste input and output in the Windows PowerShell?
0
votes
2answers
2k views

How do I run “dir pattern /s /b” in powershell?

I want to achieve the same output in Powershell as I would get by running dir [pattern] /s /b in cmd.exe. Recursive directory search, with a filter, printing out just the full file paths of found ...
1
vote
2answers
2k views

Powershell - save output to file without “…”

I have properties in my SharePoint web application, and I'd like to save them to text file. After calling $webApplication.Properties, I can see something like this: Name ...
9
votes
5answers
26k views

How to rename multiple files in multiple folders with one command

We want to rename our *.html files to *.php but (sadly enough) have not enough knowledge to do it with a cmd prompt command and/or batch file. The problem is that each file is in separate folder – ...
1
vote
1answer
2k views

How do obtain additional process information in PowerShell?

In powershell, if I do 'get-process', I get PS C:\Documents and Settings\Hello\Desktop> get-process -name excel Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- -----...
1
vote
1answer
1k views

How to run script as administrator?

I'm looking to do what's asked in this question: how to run a powershell script as administrator The accepted answer says to use a shortcut. I'd like to do that, but when I get into Advanced ...
1
vote
1answer
515 views

Two PowerShell commands together?

How can I execute two PowerShell commands such that I only send text to the prompt once and the second command executes only after the first command has executed successfully?
3
votes
1answer
2k views

What permission is needed to enable PowerShell Remoting?

I am trying to enable PowerShell Remoting on my desktop where I am an Administrator. I have setup Powershell Remoting on my laptop and it works (going from my laptop to a remote server). On my ...
0
votes
2answers
2k views

Passing a powershell variable as output directory in 7zip

I need to execute something like 7za e $file_path -oC:\Destination inside a powershell script, but substitute destination folder (C:\Destination) with a variable. Some like: 7za e $file_path -o$...
3
votes
3answers
6k views

How to use powershell to search registry?

I am totally new to Powershell. Just started to pick up yesterday. When I found that resource 'Learn Powershell before it is emergence', I realised how apt is the title. Powershell has already ...
0
votes
1answer
645 views

How to install VirtualCloneDrive silently with PowerShell

.\SetupVirtualCloneDrive5450.exe /S I wrote this command. Then, Windows Security popup came on screen. It asked me "install?" or "don't install?" How can i install this programme silently with ...
3
votes
4answers
7k views

Change directory in batch file with PowerShell

I need to changed directory using batch file in PowerShell. Let's say the batch file named go.bat has the two lines of code. And I'm in q: directory. c: cd c:\abc\def When I run go.bat, I'm ...
5
votes
2answers
13k views

Convert text files recursively to UTF-8 in PowerShell

I have a folder with text files which includes other folders in it, and these also contain some text files. I need to recursively convert all these files to UTF-8 encoding in PowerShell and preserve ...
1
vote
1answer
844 views

Msbuild does not recognize mapped network drive

We have a project that builds and has a post build event. The post build event copies the output DLL to a directory F. The system is supposed to place all DLLs in the F drive. In my system, I cannot ...
1
vote
3answers
4k views

Is there a way to start or stop a service from powershell and block until the service starts?

I have to reset a sequence of services on a group of servers in a certain order. sc.exe is asynchronous, it will return when the service is in the START_PENDING or STOP_PENDING state. Start-Service/...
14
votes
2answers
25k 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 ...
2
votes
1answer
731 views

How to add a string to remote file with plink

I'm writing a new backup script in [Powershell][1] to backup our [Azure SQL][2]. After the backup, I need to write into a logfile on a remote linux server. I thought about using plink (the [putty][3]...
3
votes
1answer
260 views

Updating the last write time for a symbolic link in Windows

Is it possible to update the last write time for a symbolic link in Windows? I can use the following powershell command to update the last write time of a directory, but it doesn't work for a ...
2
votes
2answers
471 views

How do you run an executable with the same name as an alias in powershell?

sc.exe is a command line tool for manipulating services on windows. E.g. to list all the services on your machine you can type sc query from a command prompt. However, if you do it from powershell, it ...
8
votes
3answers
3k views

How can I follow a windows shortcut in power shell?

I am using powershell and I have a shortcut to my destination directory in the current directory. I want to change the current directory to the one pointed to by the shortcut. Logically what I want to ...
1
vote
1answer
918 views

cmd to powershell transition in batch-script

Is there a way of writing a batch-script that's executed via C:\>cmd.exe a.bat to switch into powershell.exe and run the remaining lines of code? 1. | echo "Hi. I'm cmd.exe." 2. | powershell 3. | ...
2
votes
1answer
305 views

Git, Powershell, %HOME% and multiple repos

I'm going to start off by saying that I'm not particularly good with either git or Windows. However, I've been successfully using msysgit on Windows 7 for a while now, keeping track of a number of ...
3
votes
2answers
3k views

Programmatically adding entries to Windows 7 Start Menu?

How does one add entries to the Windows 7 start menu for All Users programatically? For example I might want to add the folder MyApps containing a shortcut to myapp.exe and a URL for www.myapp.com. ...
2
votes
4answers
21k views

Reset Bluetooth Components Without Having to Reboot

Sometimes the bluetooth on my laptop fails to connect properly (either not at all, or sometimes with terrible quality) to a pair of stereo headphones. Often times I've been able to recover normal ...
0
votes
2answers
198 views

Powershell tab completion: How does it decide which file to suggest?

I have two files functions.txt and functions.ps1. At the PS command prompt, when I press tab in the directory, the first choice that comes up is "functions.txt". However, if I type "del " and then ...
2
votes
1answer
5k views

Is there a solution to replace Account Unknown (S-1-5-21-*) SIDs with existing SID

I have a typical "Account Unknown" on many files from old/other Windows installations and there are a ton of typical answers everywhere. However, I'm not looking for typical takeown, subinacl, xcacls ...
4
votes
2answers
11k views

How to use Volume Shadows Copy and Robocopy on Win7?

I’d like to backup my system with Robocopy and Powershell, but Robocopy is not able to copy open files. Volume Shadows Copy seems a solution but I can’t find any clear and simple explanation on how to ...
2
votes
1answer
10k views

How can I copy a file on a network share using a different login with powershell or batch file?

I have a file in a shared location that I want to copy over to my local hard drive. However I will not be running as a user that has access to the share. So I want to be able to authenticate under a ...
0
votes
1answer
1k views

xcopy files created this month in PowerShell

I wrote this code to copy files, what I need is a way to make it copy just the files created this month or created last 31 days? $a = "L:\EndMonths\" $a +=get-date -format MMMM xcopy "L:\28*.zip" $a /...
4
votes
1answer
12k views

Office365 Exchange: Cannot open shared two calendars in Outlook

The problem: Outlook won't open the calendars on another user's mailbox and and a room mailbox, even when users have permission. Note: This problem is affecting more than one account on more than one ...
6
votes
2answers
25k views

Powershell Access to the path denied

I'm sure this has been asked a million times, but I can't figure out why I can't run this simple command in powershell: PS> new-item -path c:\users\me\desktop\testfolder -name (get-date).txt -...
3
votes
1answer
2k views

How to start a Windows XP Virtual PC application using Powershell from Windows 7?

This is a shortcut target of an application I launch from Windows 7 that starts a program in Windows XP Mode. %SystemRoot%\system32\rundll32.exe %SystemRoot%\system32\VMCPropertyHandler.dll,...
5
votes
3answers
3k views

How do I set a environment variable from a powershell command?

I want to have a environment variable that contains the day of week in cmd.exe. When I run this command I get the result I want. C:\Users\tisc>powershell (get-date).dayofweek Friday Here I'm ...
2
votes
0answers
604 views

PowerShell stops executing commands/programs

Sometimes my PowerShell stops executing programs and I have yet to find out why. In this state, when I enter the name of an EXE file, the PowerShell immediately returns to a command prompt without ...
3
votes
1answer
5k views

How to create a shortcut on the desktop with PowerShell

I have been referring to answer number three of this post to write my PowerShell script, but it doesn't appear to be working. $linkPath = Join-Path ([Environment]::GetFolderPath("Desktop")) "...
10
votes
1answer
9k views

How can I get a property of an object in powershell without using parentheses?

I often find that I have to surround a command in parentheses and then use the property access operator (dot-syntax) to get the value of a property. This is rather annoying since I have to go back to ...