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

Creating a Share with Permissions with Windows Powershell

Using Powershell how can I create a share and set access permissions. For example as follows Create share called "public" that maps to the "path c:\shares\foo" Allow DOMAIN1\Users to have read-only access to the share (this does not mean setting…
user2666
  • 285
  • 2
  • 6
  • 8
9
votes
2 answers

What is different/better about DSC vs "regular" scripting?

I watched a video on ITPro.tv about PowerShell Desired State Configuration DSC. They introduce it, and effectively run a script. However, this was their first (real) introduction of scripting too, so I didn't pick up the difference between DSC and…
9
votes
4 answers

Download a file with powershell on Nano Server?

I've had some significant difficulties figuring out how exactly to download a file with PowerShell under Nano Server. The challenge is the following: There is no Invoke-WebRequest There is no System.Net.WebClient There is no…
9
votes
4 answers

Azure Powershell - Change Directory

When I login to the new Azure Portal I see a drop-down at the top right that lets me select a "Directory" from a list of 2. When I login to azure using powershell cmdlet "Login-AzureRmAccount" I am connected to the wrong directory. How can I change…
tr0users
  • 413
  • 3
  • 11
  • 16
9
votes
2 answers

Need to change system locale on Windows 2012 R2 from en-US to en-GB

When I start an Aws Ec2 Windows 2012 R2 instance it always comes with a default en-US locale. However I need to change two of the existing instances to be en-GB as if they were installed like that in the first place. Which is to say I need to…
Barbary
  • 91
  • 1
  • 1
  • 2
9
votes
1 answer

How to get SCCM to recognize return codes from Powershell script completion?

I'm using an SCCM 2012 application deployment to install software. The specific install type is scripted installer as SCCM kept failing for exe validation errors. The script is powershell and successfully installs the software even when executed…
Colyn1337
  • 2,397
  • 2
  • 23
  • 40
9
votes
4 answers

Retrieve internet proxy server address via PowerShell

I have to retrieve the proxy server address and port via PowerShell, so I can use the Invoke-Webrequest -uri http://some-site.com -Proxy command. The expected output should looks like http://proxy-server.com:port. I there a PowerShell function to…
Ob1lan
  • 190
  • 2
  • 5
  • 15
9
votes
3 answers

PowerShell: Get-ADUser Properties with åäö

I'm trying to extract select sets of users with Get-ADUser. The users belong to companies whose names include non-ASCII characters, e.g. "Gåäördet". Unfortunately, we do have to use the company property for this task and we also need it to work from…
Tanel Rebane
  • 161
  • 1
  • 7
9
votes
3 answers

powershell how to remove broken symlink

PS C:\> cmd /c mklink /d testlink non-existent-dir symbolic link created for testlink <<===>> non-existent-dir PS C:\> rm .\testlink Remove-Item : C:\testlink is a NTFS junction point. Use the Force parameter to delete or modify. At line:1 char:3 +…
Ian Kelling
  • 2,661
  • 6
  • 23
  • 21
9
votes
8 answers

Easy way to rename all files in a directory in Windows

Is there an easy way to rename all the files in a directory? Is PowerShell the way to go? I'd like to go from this: c:\family_pics\ img123.jpg img124.jpg to this: c:\family_pics\ family_pics_1.jpg family_pics_2.jpg Ideally, I'd like…
Even Mien
  • 657
  • 2
  • 12
  • 19
9
votes
1 answer

New-PSSession across domain boundaries

I am trying to bring up a virtual machine that needs to be able to create new sessions (with New-PSSession). The highly engaging about_Remote_Troubleshooting is my constant companion, of course! After bringing up a basic machine (Win 8.1…
Michael Sorens
  • 445
  • 2
  • 6
  • 17
9
votes
2 answers

Small issue with the Domain Name System (DNS) Server Cmdlets

I'm wondering if I need to clear some cache or something with the issue I'm having. I'm trying to remove A records from a DNS Zone and replacing them with a CName record that has the same host name. Remove-DnsServerResourceRecord -Zonename $line…
9
votes
2 answers

Powershell Remotely Delete PKI Certificates

I recently rebuilt my PKI and I would like to delete the certificates that were issued to all client machines across my network. Sounds like a job for Powershell! So I wrote this script to be distributed by GPO, ran from SysVol, and triggered on…
9
votes
3 answers

How to list out Virtual Directories in IIS from the all the websites in PowerShell

I have hit a complete roadblock and cannot figure out how to print out the virtual directories for each website in IIS 8. I keep retrieving Applications and empty null argument errors and just can't find a way around to get the virtual directories…
user38725
  • 369
  • 3
  • 5
  • 13
9
votes
3 answers

ESXcli command timeout at 30 minutes

I am working on a powercli script to loop through each datastore in our environment and reclaim space on the thin provisioned LUNs. All LUNs in the environment are Dell Equal Logic. vCenter version: 5.5.0_1750787 ESXi version: Dell…
Lars
  • 198
  • 1
  • 10