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

13
votes
7answers
15k views

Powershell font too small on Windows 8.1 - how to adjust?

Question: On my Windows 8.1 machine, I need powershell to configure office web apps. When I start powershell, for a blink of a second, it shows as it should, but then it gets resized, and the font ...
2
votes
1answer
461 views

Making PowerShell assume the working directory of a called Batch file

I regularly work interactively with a batch script that I can't easily change. One of the features of this script is as a navigation aid - it understands my company/product's code layout conventions ...
1
vote
2answers
6k views

How to reset TCP/IP on Windows 8.1?

The following netsh command is not working on Windows 8.1. netsh int ipv4 reset It give “Access Denied” error and it is a VERY known issue, many people complaining about it all ove online forums. ...
0
votes
0answers
144 views

Need PowerShell or BAT to delete PST if over certain size for GPO

I'm trying to delete "Internet Calendar Subscriptions.pst" from %LOCALAPPDATA%\Microsoft\Outlook using a BAT file. I can do this fine. But how do I delete only if it is over a certain size? When end ...
0
votes
1answer
1k views

Running RSAT Tools as another user using Powershell

What I try to accomplish is running some RSAT Tools out of a Powershell-Script as another user (Domain-Admin). Here is my run code: Start-Process -FilePath "C:\Windows\system32\mmc.exe" ...
5
votes
4answers
714 views

Color empty files in Windows

I face a need to show empty (0 bytes size) files in color in Windows Explorer. (I get them over sftp and need to know whether they're empty to prevent data loss - an application creates empty files ...
1
vote
0answers
571 views

Can not create process with elevated permissions from LocalSystem account

I am running a build server on windows server 2008 (team city). The builds are run by the Team city agent that runs as a windows service under LocalService account. One of the builds need to copy a ...
1
vote
3answers
1k views

Executing PowerShell script via explorer context menu on items containing ampersands in their names

I'm using a slightly modified version of the technique given in this answer to create a context menu item in Windows' file explorer that allows me to run a PowerShell script against specific folders. ...
1
vote
2answers
266 views

Any way to set the default width for out-file?

In Powershell, redirection to file can be done with eith > or out-file, and from what I read > is basically a shortcut for the latter. The problem is that, by default, out-file wraps lines at ...
0
votes
2answers
157 views

Why does running Powershell script line by line work, but the same thru executing script file - does not?

In Windows 7 Prof, executing in Windows Powershell_ISE (as administrator) the Powershell (ver. 3) commands produces expected result (of adding a domain user to local/machine Administrators group) but ...
2
votes
1answer
779 views

Can the default PowerShell terminal keep a command history?

Is there a way to have PowerShell remember commands entered during the previous sessions? That is, after closing the window and opening it again, can PowerShell be setup to remember the commands?
3
votes
1answer
4k views

PowerShell - copying a file to multiple locations

I need assistance with a simple PowerShell script. I'm only a beginner with this language, so forgive me for any mistakes in language. I need a script to copy a file (which is in the same directory ...
6
votes
2answers
816 views

Equivalent of bash's Ctrl-r in PowerShell

does anybody knows of a way to have the backward command search feature of bash [Ctrl-r] (and [Ctrl-o]) that are so useful, in windows powershell ? C-r is a more powerful arrow up history ...
1
vote
2answers
413 views

How to set colors in PSReadLine in PowerShell

PSReadLine in PowerShell has syntax coloring, but how do you specify the colors?
10
votes
0answers
1k views

Why doesn't windows command prompt still support ctrl + v? [closed]

This is just one of those things that I started wondering about. Why aren't the copy/paste keyboard shortcuts (that we all love) in command prompt not aligned with the rest of the software ...
0
votes
1answer
324 views

Powershell Script to Return Directories Without a Zip File Created/Modified Within the Last 7 Days

I have a series of folders on a server that needs to be regularly checked that they are being backed up correctly. We like to have at least 1 backup in that folder that is no less than 7 days old. The ...
2
votes
1answer
419 views

Why does ForEach-Object behave differently when called as foreach?

In PowerShell, foreach and % are default aliases to ForEach-Object. However, it seems the command behaves differently depending upon how it is called. Particularly, I have a hard time getting the ...
1
vote
1answer
460 views

Run a script with an interactive prompt on login

I am trying to run a script in Windows Server 2012 on login. I used the group policy editor to assign a .ps1 powershell script which runs fine. However it does not get assigned a command prompt. I ...
10
votes
3answers
465 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?
0
votes
3answers
5k views

How to run “winrm quickconfig” on all LAN computers remotely

I want to start doing my remote LAN work using powershell, but it seems I need to run winrm quickconfig on all LAN computers before I can remotely connect to them. How can I run that command on all ...
2
votes
1answer
507 views

How to lock Powershell ISE console output scroll?

I'm using Powershell ISE for running some batch scripts. The outputs will be long and these programs will run for quite a some time. The problem I'm facing is I'm unable to lock the console output to ...
1
vote
0answers
232 views

Extend partition windows powershell

I want to create a Windows Powershell script to extend my partition through WMI (remotely), IP Address of my host id 10.10.10.10 $pass = convertto-securestring "abc123#" -asplaintext -force $mycred ...
4
votes
2answers
40k views

Concatenating Variables within Powershell

I'm trying to concatenate two variables within Powershell to form a complete file path and file name to save a text file. I have two variables $Log_path and $Log_name I'm trying to join the two ...
0
votes
1answer
845 views

Execute Backup-SqlDatabase cmdlet remotely

When I run the following script line locally on an SQL Server machine, it executes perfectly: Backup-SqlDatabase -ServerInstance $serverName -Database $sqldbname -BackupFile ...
0
votes
1answer
2k views

Adding many IP addresses to Windows Firewall using CLI fails partially

I have a PowerShell script which adds IP addresses to Windows Firewall using the "netsh advfirewall" command. (As described in this question: How to append netsh firewall rules, not just replace). ...
0
votes
2answers
72 views

How can I use numeric names in a PowerShell hash table?

When I create a hash table entry with a numeric name, it seems impossible to address it like I can when I use text strings for names. Why is this? Is there a simple workaround, or is this error by ...
6
votes
1answer
4k views

Can't exclude a directory pattern recursively

I'm trying to get child items of a folder recursively. However the folder contains noise files and folder (actually, this is a Visual Studio project folder). Here what I have: $root = Get-Item ...
1
vote
1answer
97 views

How is the powershell $profile resolved?

The operations department has changed the location of the home network storage and with that my powershell profile stopped loading. If I print ´$PROFILE´ I get ...
1
vote
1answer
497 views

Powershell mapped network drive doesn't persist

I'm trying to create a script that maps a network drive whenever I connect to a VPN, then disconnects the drive when I disconnect from the VPN, using Task Scheduler to launch the script when the event ...
0
votes
1answer
434 views

%HOMEPATH% Posh-Git error in Powershell, in ConEmu on Windows 7 64-bit

I am always getting the following error in Posh-Git in Powershell, in ConEmu on Windows 7 64-bit: Resolve-Path : Cannot find path 'C:\wamp\www\MobileApps\Backbone\%HOMEPATH%' because it does not ...
-1
votes
1answer
2k views

Get windows events for a day

I'm trying to create a PowerShell Cmdlet that runs daily and shows me the errors that occured on the previous day. I can make it show the last 100. Instead I'd like to see just the one that occured ...
2
votes
2answers
422 views

Powershell script not logging as expected when run from command line

I have a simple powershell script that opens a ur and logs whether it was successful: $LogFile = ".\userLoad.log" $Date = Get-Date Try { $Request = ...
3
votes
1answer
524 views

Powershell systemroot in $env:path different when AC elevated

I have a strange behavior with the environment variables at my Windows XP SP3. When I logon as Administrator, the %SystemRoot% strings in PATH are substituted to C:\WINDOWS, the value of the variable ...
2
votes
1answer
2k views

How to avoid wordwrap in powershell ise output pane

When I execute a command that gives huge output, infact it is log of a running server, I see that PowerShell ISE output pane is automatically wrapping the text to around half of the screen width when ...
0
votes
1answer
261 views

Powershell, renaming specific .xml data and saving changes

I've been doing quite a bit of searching/experimenting, and I know similar problems have been solved, but I'm struggling with this problem specifically and am reaching out for another pair of eyes. My ...
1
vote
0answers
477 views

copy|move sparse files on NTFS with Windows

How can I copy or move a sparse file from one NTFS volume to another NTFS volume while maintaining the sparseness using the native tools included with Windows? If there is no way to do this with the ...
2
votes
2answers
1k views

How to install WinRM service on Windows 7 if removed from installation image?

I have a freshly installed trimmed-down version of Windows 7 Ultimate SP1 and I'm trying to get back my CredSSP functionality for PowerShell remoting. I cannot remote to another server from this ...
3
votes
2answers
1k views

How can I start/stop a Windows Service through a Linux bash script?

I want to create a script that will be kicked off through an SSH server to start/stop a Windows service. The SSH user is part of the Administrator group. However, when I execute the script, I get an ...
0
votes
1answer
223 views

create folder in powershell with previous date

I need a Powershell script which helps me to create a folder on destination with one previous date. Currently, I am using the code below. It helps me to create a folder on destination place with ...
0
votes
2answers
424 views

Powershell, automatically add “\” before certain characters

I wrote a script that grabs each line in a .txt file, one line at a time, and before moving on to grab the next line, an action is performed. Let's say this is the text file: [Foo] (Bar) To make it ...
0
votes
1answer
467 views

Pipeline input to executable with PowerShell

I need to execute the following command in PowerShell: %windir%\system32\inetsrv\appcmd add site /in < c:\mywebsite.xml I am trying to do it like this: $appCmd = ...
3
votes
1answer
2k views

How to get site physical path with appcmd

I am trying the following appcmd commnad: appcmd list app /site.name:"misechko.com.ua-DEV" /xml | appcmd list vdir /in /text:physicalPath misechko.com.ua-DEV is a correct site name in IIS. appcmd ...
17
votes
1answer
5k 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, ...
3
votes
1answer
267 views

Select proceeding characters after an identifying character in Powershell

I have a very large folder of files, of which I organize with a script of mine that refines the files just down to what I need. These items are named similarly to the following examples: Foo ...
4
votes
1answer
3k views

What version of PowerShell comes with Windows 7?

I am attempting to create a solution to launch remote processes in an environment which is very stable, and I know the user base will have Windows 7 - most will have no updates to it though. ...
1
vote
2answers
3k views

Download entire directory from a website using Powershell

I have been using the following command to pull back files from a web server and store them on my local machine: $client = New-Object System.Net.WebClient ...
1
vote
1answer
142 views

adding file size of two or more files in powershell

Why is the following snippet only adding the byte-size of the last file to 0 and not the size of all files matching? $sizeOfVhds = 0 (Get-Item "\\blahhh.com\foo\bar\*.vhd") | ForEach-Object { ...
1
vote
0answers
766 views

Install Windows Store App package (*.appx) for all users

I know there are several posts where users want to install Windows Store Apps for all users. Answers were to use DISM. In my case I can not use DISM because all clients are already deployed. If a ...
1
vote
1answer
655 views

How to run programs and scripts NOT in the background on a remote machine? [closed]

I have been trying to remotely execute some scripts and run some programs on a remote virtual machine on a server. The command I have been using is Invoke-command After going through all the troubles ...
3
votes
1answer
4k views

What is the Start Screen Control in Windows 8.1 Enterprise

I have read different things on the new Windows 8.1 Enterprise RTM. One of the feature is the Start Screen Control. Start Screen Control: This feature allows you to control the look of the Start ...