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
20
votes
5 answers

What version of Windows Management Framework is installed?

How do you check to see what version of Windows Management Framework (WMF) is installed? It seems like it should be a simple thing to find out, but I cannot. Even Googling a bunch of different versions of the question turns up little to…
Loduwijk
  • 565
  • 3
  • 5
  • 15
20
votes
4 answers

How to create Active Directory user account with powershell

I am constantly setting up research and development environments that require active directory accounts. Since we place these environments in isloated networks each environment needs its own active directory. How can I create a new active directory…
Rob Murdoch
  • 303
  • 1
  • 2
  • 4
20
votes
3 answers

How do I delete this orphaned Active Directory computer object (preferably with PowerShell)?

I'm working from a Windows 7 workstation, with PowerShell v2.0, and trying to delete a particular (orphaned?) object from the LostAndFound container in a 2008 R2 FL forest and domain with the Active Directory Recycle Bin enabled, and having no luck…
HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
20
votes
3 answers

Can Remote Desktop Services be deployed and administered by PowerShell alone, without a Domain in WIndows Server 2012 and 2012 R2?

Windows Server 2008 R2 allowed deployment of Terminal Server (Remote Desktop Services) without a domain, and without any insistence on domains. This was very useful, especially for standalone virtual or cloud deployments of a server that is managed…
Warren P
  • 1,195
  • 8
  • 21
  • 35
20
votes
1 answer

Redirect standard error to a variable in PowerShell

I would like to script a dcdiag test to alert me if it finds any errors. I thought I may able to do this in PowerShell by... $test = dcdiag 2>$err I don't have any errors from dcdiag at the moment, so I couldn't test that directly, but I wrote…
Matt
  • 1,142
  • 1
  • 12
  • 32
20
votes
8 answers

PowerShell Quickstart

What is the best way you jump-started your Powershell adoption? What resources, tips, scenarios got you up to speed quickly?
Brett Veenstra
  • 1,497
  • 5
  • 18
  • 27
19
votes
8 answers

Import-Module Azure fails

I am trying to work with Windows Azure PowerShell module on Windows 8.1. I have downloaded and installed the Azure module and in start I can run and use the "Windows Azure PowerShell" which is a PS that just loads Azure. When I open just a plain PS…
itaysk
  • 395
  • 2
  • 4
  • 9
19
votes
5 answers

Run remote powershell as administrator

Before I dive into the question, I have found several other questions that seem similar to mine, but they have not been able to solve my problem. Here are links to them: Remotely run a script invoking "Run As…
Jon
  • 351
  • 1
  • 2
  • 3
19
votes
14 answers

What are some good resources for learning PowerShell scripting?

Are there online resources or books that you would recommend as an introduction to PowerShell scripting? The resources I've found primarily focus on interactive use.
dmo
  • 2,100
  • 1
  • 16
  • 22
19
votes
3 answers

Change owner recursively with Powershell?

I'm trying to use Powershell to change owner of a folder, recursively. I'm basically using this code: $acct1 = New-Object System.Security.Principal.NTAccount('DOMAIN\Enterprise Admins') $profilefolder = Get-Item MyFolder $acl1 =…
Mikael Grönfelt
  • 677
  • 3
  • 7
  • 14
19
votes
4 answers

PowerShell Script to find AD users with adminCount > 0

I've recently discovered the "adminSDHolder" feature of Active Directory. I need a quick way to identify all users who will be affected by it, namely a script to dump the user accounts.
Chris S
  • 77,945
  • 11
  • 124
  • 216
19
votes
6 answers

Adding a user to the local Administrator group using powershell

I would like to use PowerShell to add a specific user to the local administrator group on a machine. I would be running the PowerShell script in the context of a user that has Administration rights on the local machine.
Rihan Meij
  • 547
  • 1
  • 4
  • 10
18
votes
7 answers

PowerShell prompt to continue execution of code

I have a script I am using to automate WSUS processes, and the last stage of it goes on to remove all old/unnecessary files/objects. I would like to prompt 'Press 'Enter' to continue with removal or any other key to stop' before the cleanup stage to…
Abraxas
  • 1,229
  • 1
  • 16
  • 25
18
votes
2 answers

Powershell's equivalent to Bash's process substitution

Bash has <(..) for process substitution. What is Powershell's equivalent? I know there is $(...), but it returns a string, while <(..) returns a file the outer command can read from, which is what it expects. I'm also not looking for a pipe based…
IttayD
  • 1,087
  • 4
  • 11
  • 14
18
votes
2 answers

How do you manually set PowerShell's OneGet repository source to Chocolatey?

The OneGet PowerShell module should ship with the default repository being Chocolatey. This is shown in the documentation found here. However when I run Get-PackageSource it returns PSGallery and MSPSGallery as the sources. How can I manually set…
NoAgenda33
  • 181
  • 1
  • 1
  • 4