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
18
votes
4 answers

How can a standard Windows user change their password from the command line?

On Windows Server 2008 R2, I have a standard (non-administrator) local user (not an Active Directory account, though the server is in a domain) who has access to the server only via PowerShell Remoting. The user cannot login via RDP. I would like…
elijahbuck
  • 450
  • 1
  • 3
  • 8
18
votes
6 answers

Enabling Powershell Remoting, Access is denied?

I am trying to enable Powershell remoting on a Windows 2008 R2 Server, running in workgroup mode. I ran the command Enable-PSRemoting in the PowerShell Console. PS C:\Windows\system32> Enable-PSRemoting WinRM Quick Configuration Running command…
Peter Lundsby
18
votes
2 answers

Cause of Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes

Steps Launch PowerShell 7 on Windows 10. Actual result PowerShell 7.0.0 Copyright (c) Microsoft Corporation. All rights reserved. https://aka.ms/powershell Type 'help' to get help. Warning: PowerShell detected that you might be using a screen…
17
votes
3 answers

Powershell module 'servermanager' not found on Windows 10

I am running windows 10 on a virtual machine and I would like to list the windows feature available by running the following commands on powershell: Import-Module ServerManager Get-WindowsFeature Already running the first command produces: The…
diegus
  • 283
  • 1
  • 3
  • 7
17
votes
7 answers

Powershell: How do I query pwdLastSet and have it make sense?

I need to get the last password change for a group of account in an Active Directory security group, and I feel like this is something PowerShell should be good at. Right now, I'm already stuck at how to read the pwdLastSet attribute from the AD…
Bob
  • 2,569
  • 3
  • 26
  • 22
17
votes
4 answers

PowerShell DSC copy from network share

I am trying to use PowerShell DSC to copy folder contents from a network share. Here is the code: Configuration TestSetup { Node localhost { File Test { SourcePath = "\\Server\SomeShare\SomeFolder" DestinationPath…
Richard
  • 836
  • 2
  • 8
  • 21
17
votes
5 answers

Powershell delete files only from directory

I'm trying to delete all files (but not directories) in D:\MyTemp folder, I've tried: Remove-Item "D:\MyTemp" Remove-Item "D:\MyTemp\*" However, when I check, all the files are still there. What am I missing?
SteB
  • 989
  • 6
  • 15
  • 31
17
votes
5 answers

Why does PsExec hang after successfully running a powershell script?

The script is fairly straight forward. Simply tries to start a bunch of windows services. Execution locally works fine when on the target machine. The script is actually executing fine as well when done via PsExec, it just never returns until I…
Matt
  • 3,241
  • 9
  • 30
  • 33
17
votes
5 answers

Writing a powershell script to copy files with certain extension from one folder to another

I would like to write a powershell script that gets the following parameters as input: Folder to copy from, extensions allows, folder to copy to and a boolean indicating if the change should restart IIS, username and password. What cmdlets should I…
the_drow
  • 322
  • 2
  • 4
  • 11
17
votes
4 answers

What are Runspaces in Windows PowerShell 2.0?

Today I listened to a HanselMinutes podcast about PowerShell 2.0. Scott Hanselman interviewed Hal Rottenberg and Kirk Munro at TechEd 2009. They talked about RunSpaces in PowerShell 2.0. Can somebody please explain the concept behind them and give…
splattne
  • 28,508
  • 20
  • 98
  • 148
16
votes
13 answers

What's your favorite Powershell command or script for system administration?

What's your top Powershell command? Let's make a list and vote up the best ones!
Jon Galloway
  • 1,506
  • 1
  • 17
  • 20
16
votes
1 answer

Using defaultAuthenticationType with PowerShell Web Access

PowerShell web access lets you choose the authentication type. By default, it uses a value of Default, which ends up being Negotiate. I have set up CredSSP to allow logging into the PSWA server itself with CredSSP, so that network authentication…
briantist
  • 2,545
  • 1
  • 19
  • 34
16
votes
2 answers

How to persist credentials in a remote Powershell session?

I have an Azure File Share and would like to use this from my Azure VMs - after persisting the credentials on the VMs with cmdkey and mounting with net use. This was tested by running these commands in a local Powershell session on Windows Server…
Razvan Zoitanu
  • 655
  • 1
  • 11
  • 26
16
votes
3 answers

Windows Server 2012 GUI went missing after removing Active Directory

I'm sorry but i'm stuck in figuring out a problem i'm facing here. I removed the AD feature from server manager and after rebooting, my server 2012 gui wasn't there anymore. There's only command prompt to deal with. I tried to enable back gui based…
mfmz
  • 169
  • 1
  • 1
  • 6
16
votes
8 answers

Method to integrate Powershell scripts with non-Windows workflow?

I love the smell of new machines in the morning. I'm automating a machine creation workflow that involves several separate systems across my infrastructure, some of which involve 15 year old perl scripts on Solaris hosts, PXE Booting Linux systems,…
Matt Simmons
  • 20,396
  • 10
  • 68
  • 116