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
2
votes
1 answer

Task Scheduled Powershell Script Not Shutting Down machine

I have a task running on a Hyper-V server setup as such: schtasks /CREATE /TN AutoShutdown /RU "SYSTEM" /TR "Powershell \"C:\AutoShutdown.ps1\"" /SC ONSTART It runs properly (as far as I can tell) however the script has a line to shutdown the…
2
votes
1 answer

Install RSAT-Hyper-V-tools fails on Windows Server 2012 R2 Server Core

When I try to install Rsat-Hyper-v-tools with powershell command: add-windowsfeature rsat-hyper-v-tools -includeAllSubFeature It fails with error saying that: The source files could not be downloaded. Error: 0x800F0906 Also : CategoryInfo:…
2
votes
1 answer

How can I input password to manage-bde -pw option via windows powershell

I am trying to encrypt Data volume (for example E:) with the following command: manage-bde -protectors -add E: -pw When I execute the above command, it will ask for the password, so I entered it. It is successfully encrypting my data volume. Now, I…
2
votes
1 answer

Powershell v1 Search String from Variable

I am trying to search a variable which holds a list of files, gotten from get-childitem, and list all matches to a specific search string but can't seem to get the result I want, what am I doing wrong? $TargetFiles = Get-Childitem -OutBuffer 2500…
Nick W.
  • 167
  • 9
2
votes
1 answer

ADDS: Mandatory Profiles through powershell

Intro I'm a networking student from Belgium and I just got assigned a big project. Basicly i'm responsible for the ADDS. We have to create several OU's and every OU needs at least 20 users or more. 1 of these OU's is called "Guests" and has 20+…
2
votes
1 answer

Reset or delete remote Powershell sessions

I run a remote Powershell script to add a machine to a domain. Machine reboots, is added to the domain, all good. $Uri = Get-AzureWinRMUri -ServiceName $ServiceName -Name $VMName -Verbose $PSSession = New-PSSession -ConnectionUri $Uri -Credential…
Razvan Zoitanu
  • 655
  • 1
  • 11
  • 26
2
votes
2 answers

Importing users to AD with CSV, cannot get some fields to work

Been trying to build a CSV file to import users into Active Directory. I can get everything to populate, except for E-mail, Password, and Enabling the user. Just using this cmdlet in Powershell. Import-CSV…
Matt Fogleman
  • 95
  • 1
  • 8
2
votes
2 answers

powershell v2 remoting - How do you enable unecrypted traffic

I'm writing a powershell v2 script that I'd like to run against a remote server. When I run it, I get the error : Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Unencrypted…
Peter Walke
  • 153
  • 1
  • 3
  • 7
2
votes
1 answer

Is the file current.mof a bottleneck when using the DSC module?

The msutter DSC module (PowerShell Defined State Configuration) seems to have a bottleneck. Every class that uses a DSC resource generates intermediate Powershell/DSC code that creates a file called current.mof in the same directory. When I run…
Paul Chernoch
  • 155
  • 1
  • 6
2
votes
2 answers

Restrict user account to 'only' remote Powershell sessions

Is it possible to only delegate a enough permissions for a user to only be able to utilize a Remote Powershell session? I have a limited set of scripts that I want to run from a central location against a set of servers using a designated service…
mhouston100
  • 412
  • 1
  • 5
  • 20
2
votes
3 answers

Powershell script not working when launched from SSH (or winexe) from a Mac or Linux Client

I have a Powershell script to backup MSSQL on a Windows Server 2008 R2 box. It backs up a specific DB to a local disk, then moves the backup to a Network mounted CIFS volume. It works 100% fine when run locally no matter how I invoke it. I…
sed_and_done
  • 183
  • 8
2
votes
1 answer

Powershell Workflow Parallel

I recently determined that I am able to run a workflow as parallel without using foreach. Syntax is below. workflow Get-OS { parallel { Get-WmiObject -Class Win32_OperatingSystem } } Is it possible to throttle this workflow without using…
Acerbity
  • 95
  • 2
  • 9
2
votes
2 answers

powershell format a value that's already a string

I have some values that I want formatted in a specific way. To be very clear, its an IP address octet and I want it in a "xxx" format. For example if I have a octet value of "20" I want to display it as "020" not "20". I'm ultimately going to have…
Eric C. Singer
  • 2,329
  • 16
  • 17
2
votes
1 answer

Create shared folder on share automatically

I know there is a group policy where I can map a specific share. What if I want the group policy to create a folder on that share and map it during log on? I know there must be a way to do this in PowerShell. Or would I not have to even worry about…
2
votes
0 answers

Viewing Storage Space allocation for physical disk

I have a server that had four disks (2x 4TB and 2x 3TB drives) in a Server 2012 R2 Storage Pool. There are two virtual disks in the pool - a parity disk and a mirrored disk. The idea was to add two more 4TB disks, retire the mismatched 3TB drives…
Mark Henderson
  • 68,823
  • 31
  • 180
  • 259