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
16
votes
6 answers

How to run a PowerShell script from Cygwin SSH session?

I have Windows Server 2003 with CopSSH installed on it ( Cygwin + sshd ). I would like to be able to run a PowerShell script via SSH session command and then use its output. Is there such a capability? How to do it?
malloc4k
  • 831
  • 2
  • 9
  • 16
15
votes
5 answers

How can I use PowerShell to enable NTFS compression, in place, on log files older than x days?

I have an application server, running Windows 2012 R2, which generates a high volume of log files, to the point that it runs the application volume out of free space on a semi-regular basis. Due to restrictions from the application itself, I can't…
HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
15
votes
6 answers

Remote PS session fails on non-domain server

I'm trying to connect to a non-domain joined remote Win2008R2 server using PS from a Win8 host (same subnet, it's a local VM). Tried everything I could find, nothing works. SERVER: PS C:\Users\Administrator> winrm quickconfig PS…
Dendory
  • 333
  • 1
  • 4
  • 13
15
votes
3 answers

Launch remote PowerShell session using saved ps1 file

I am trying to create a couple of files that I can save on my local desktop to launch PowerShell sessions. The Windows Server 2008 and Windows Server 2012 are both Server Core installations. Currently, I can open Powershell and type: Enter-PSSession…
Anthony Fornito
  • 9,546
  • 1
  • 34
  • 124
15
votes
3 answers

In which version of Windows is PowerShell installed by default?

I just installed XP SP2 and I was expecting to have PowerShell 1.0 installed; however, it isn't. It seems I have to manually install it. If I upgrade to SP3 do I get PowerShell. From Wikipedia article: PowerShell 1.0 was released in 2006 for…
user1088352
  • 291
  • 1
  • 2
  • 4
15
votes
5 answers

List All Groups and Their Members with PowerShell on Win2008r2

I am new to powershell, but I've been reading manuals and practiced a little bit. My objective is to List all users in all Security Groups under specified path. I have found the way to do it: get-adgroup -Filter * -SearchBase…
Alec T
  • 463
  • 1
  • 9
  • 21
15
votes
1 answer

Unzip File With Powershell in Server 2012 Core

I need to unzip a file with powershell. The typical way I've seen everyone do this is by automating the shell with a script. $shellApplication = new-object -com shell.application $zipPackage =…
vcsjones
  • 722
  • 1
  • 8
  • 21
15
votes
4 answers

How do I add a Title to a powershell window?

I have many PowerShell windows open, with a command history specific for a task. In the good old Batch file days I would use Title finance dpt or Title Email Admin. How can I accomplish this in PS?
makerofthings7
  • 8,911
  • 34
  • 121
  • 197
15
votes
3 answers

Dismount USB External Drive using powershell

I am attempting to dismount an external USB drive using powershell and I cannot successfully do this. The following script is what I use: #get the Win32Volume object representing the volume I wish to eject $drive = Get-WmiObject Win32_Volume…
JB.
  • 253
  • 1
  • 2
  • 6
14
votes
1 answer

Why isn't MacTripleDes algorithm output in PowerShell stable?

I am checking the file hashes using several different algorithms in powershell. When I use MacTripleDes, I always get different hashes. All of the others, such as SHA256 or MD5 always give reliable answers. You may be able to replicate the…
user6722022
  • 176
  • 5
14
votes
1 answer

Import Powershell AD Module during MDT Task Sequence

I have written this short powershell script to rename a computer as part of an MDT task sequence: Import-Module ActiveDirectory $AdminUsername = 'domain.com\administrator' $AdminPassword = 'password' | ConvertTo-SecureString -asPlainText…
Mx Gorply
  • 141
  • 1
  • 4
14
votes
1 answer

Is it possible to enable MSMQ from PowerShell on Windows 8?

Is it possible to enable MSMQ from PowerShell on Windows 8(.1)? If so, how does one do this?
aknuds1
  • 2,095
  • 3
  • 17
  • 23
14
votes
5 answers

How do I diff two folders in Windows Powershell?

I'm trying to find differences in the content of two folder structures using Windows Powershell. I have used the following method to ensure that the file names are the same, but this method does not tell me if the contents of the files are the…
David Smith
  • 249
  • 1
  • 2
  • 7
14
votes
2 answers

Sudo !! equivalent in PowerShell

"Sudo !!" invokes previously executed command with administrator privileges in *nix shell. Is there an equivalent in PowerShell?
BlueGene
  • 2,241
  • 9
  • 30
  • 33
14
votes
10 answers

How to enable volume shadow copy using Powershell?

How to enable volume shadow copy on specific drive (D:, E:,...) and set up schedule using Powershell ? I just need some hints how to start.
Primoz
  • 397
  • 3
  • 7
  • 16