Questions tagged [powershell]

An interactive shell, scripting and programming language, and surrounding environment from Microsoft. Commonly used by system administrators managing Microsoft software (including Windows, Exchange, SharePoint, and cloud services Azure and Office 365), PowerShell is included by default with Windows, and takes over from previous languages such as VB Script.

PowerShell exists to create a more powerful shell than Command Prompt, a more capable language than VBScript, and an environment with built-in support for remote servers and code documentation. Since its introduction, Microsoft added support for PowerShell scripting to many of their core products.

This comment by Jeffrey Snover, one of the original designers of PowerShell, explains the ideas and intent behind the language, and why it was developed instead of porting something like Bash from a Unix environment.

PowerShell provides a vastly improved scripting environment for Windows compared to previous .bat and .vbs methods; it includes PowerShell ISE - an editor and debugging environment, on the language side it has easy support for using lists, hashtables and regular expressions for pattern matching, as an interactive shell it has tab completion for command parameters and interactive help via Get-Help, and it can natively work with COM objects, WMI, registry values, call out to any .Net Framework method or library, and create and use modules written in PowerShell code.

Microsoft Software that supports PowerShell for management includes: Windows Server (and many roles and features - Active Directory, IIS, DNS Server), Exchange Server, SQL Server, SharePoint Server, Windows Azure, and Office 365 components. Here is a full list of PowerShell modules included in Windows Server 2012 and Windows 8.1.

First released in 2006 as a downloadable addition to Windows XP and Server 2003, PowerShell has been significantly upgraded in 2009 (v2) with the addition of remote execution of scripts, and in 2012 (v3), 2014 (v4), and 2016 (v5). In 2018 Microsoft released PowerShell Core (v6) which was open sourced and runs cross-platform on Windows, Mac, and Linux.

4084 questions
26
votes
3 answers

How can I programmatically cause a new Windows user's profile to be created?

I'm creating a (local) user for a Windows service to run as. I've got good reasons for not wanting to use NETWORK SERVICE, LOCAL SERVICE, or LOCAL SYSTEM. I create the user via net user foobar "Abcd123!" /add - this works fine. At this point,…
Peter Mounce
  • 1,253
  • 5
  • 16
  • 29
26
votes
5 answers

Windows Powershell Vim Keybindings

Is there a way to get vim keybindings in powershell as you would in bash or zsh with a command like set -o vi
Bryan Ward
  • 425
  • 1
  • 5
  • 10
25
votes
2 answers

Is there a way to loop through Windows 8 Apps and remove them all?

Windows apps are annoying and I would like to remove them. Been playing around with Powershell and scripting and I wanted to know if there was a way I could make Powershell to loop through all the apps and remove them. # List of Applications that…
Jason
  • 3,931
  • 19
  • 66
  • 107
24
votes
4 answers

How to edit Local Group Policy with a script?

I have to set the local group policy settings and the the local security policy for a couple of machines which are not in a Windows domain. Until now, I've done that by manually setting the keys in gpedit. Due to the transition to Windows 10, I…
P. Egli
  • 341
  • 1
  • 3
  • 4
24
votes
1 answer

How to override the default dir alias in Powershell?

I wanted to see colorized filenames when I typed dir in Powershell. So, I added the Set-ChildItemColor function from here to my profile file. I also added this line at the end of the profile file to override the dir alias: Set-Alias dir…
Ashwin Nanjappa
  • 341
  • 2
  • 5
24
votes
4 answers

How to set ExecutionPolicy: access to registry key denied

I'm running Windows Server 2008 as admin and I tried to set ExecutionPolicy as Remotesigned for PowerShell v2 like this: Set-ExecutionPolicy RemoteSigned But I got this error: Set-ExecutionPolicy : Access to the registry key…
atricapilla
  • 615
  • 6
  • 12
  • 15
22
votes
4 answers

Set service StartType to Automatic - Delayed

Using Set-Service, I'm able to change the StartType of my services between the accepted values of Boot, System, Automatic, Manual, Disabled. Using services.msc, I'm able to set some services to startup with a Priority of Automatic (Delayed Start).…
Peter Vandivier
  • 393
  • 1
  • 2
  • 12
22
votes
5 answers

Powershell equivalent of Ctrl+R?

In bash I can do Ctrl+R and start typing a command to have it search my history. How do I do that in powershell? Is there a way to bind a key to something like? function GH($str) {get-history | select-string $str} But I would need to re-read the…
red888
  • 4,183
  • 18
  • 64
  • 111
22
votes
3 answers

How do I convert a vhd to a wim file?

I just setup and sysprepped a nice new VM, now I need to convert it to a wim real quick, to upload to my sccm server. For some reason, I can't change the VM properties to boot from a legacy nic for pxe, which is how I usually capture my images using…
MDMoore313
  • 5,581
  • 6
  • 36
  • 75
22
votes
3 answers

Add a binding to an IIS site using powershell

I'm trying to control bindings in an IIS app using powershell. I'd like to create a site with both a http and https binding using a script. This is what I have thus far: Param( [Parameter(Mandatory=$True,Position=1)] [string]$hostname, …
Khanzor
  • 331
  • 1
  • 2
  • 5
22
votes
3 answers

How do I change my default PowerShell profile / digitially sign my $profile file?

I tried creating an ultimate setup for my powershell environment. I created "Microsoft.PowerShell_profiles.ps1" with a bunch of statements to setup my default profile. When I start a PowerShell session though, I get: File C:\Documents and…
Brett Veenstra
  • 1,497
  • 5
  • 18
  • 27
21
votes
2 answers

HALP! I've inherited a permissions nightmare for redirected folders/home directories

My new employer has folder redirection setup for its hundreds of users, and the person who set it up didn't really know what he was doing. As a result, the best practices for permissions on redirected folders/home directories was not followed. The…
21
votes
7 answers

command line - switch to administrator mode

Is it possible to switch from normal mode to administrator mode in command line? I don't want to open command line by right clicking and selecting "run as administrator". Thanks
culter
  • 507
  • 2
  • 9
  • 16
21
votes
5 answers

How do I install an app from Windows Store using Powershell

I know if I have .appx package file, I can install it via powershell with the Add-AppxPackage cmdlet. However, I simply want to download & install Microsoft Store packages by name. I don't want to have to go to the Microsoft Store page, start…
David Wilson
  • 323
  • 1
  • 2
  • 5
20
votes
4 answers

Why does Powershell take so long to init?

When I fire up powershell it takes ~10-15 seconds to init and give me a prompt. Anyone know what it's doing when you first fire it up that might contribute to that? This is XP Pro, 2 GB of memory, only Outlook and Firefox running interactively,…
squillman
  • 37,883
  • 12
  • 92
  • 146