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

How to ONLY get property value

I want to retrieve IP Addresses from computer names but I ONLY want the IP nothing more. $computer = 'Server1' $computer = [System.Net.Dns]::GetHostAddresses($computer) | select IPAddressToString Returns @{IPAddressToString=x.x.x.x}. How do I…
Delonte Johnson
  • 341
  • 2
  • 4
  • 13
12
votes
1 answer

Windows Remote Management Over Untrusted Domains

I am currently trying to enable Windows Remote Management (specifically, Powershell Remoting) between 2 untrusted domains, and having no luck. A brief description of my setup: domain1 - my workstation is on this domain domain2 - the server I wish…
Nick DeMayo
  • 297
  • 4
  • 14
12
votes
3 answers

Access already mapped network drive in PowerShell

I am running a Windows Server 2012 installation inside VMWare Workstation. I have shared folders enabled, so drive Z: is mapped to \\vmware-host. I can correctly access this drive in Explorer (I can access Z: inside the "normal" `cmd) and I can…
gen_Eric
  • 211
  • 1
  • 5
  • 17
12
votes
4 answers

Enable Certificate Enrollment Policy and Request a Cert using PowerShell

Right now, I'm doing the following to request a cert from a CEP server: Open gpedit.msc Under Computer Configuration > Windows Settings > Security Settings > Public Key Policies, double click "Certificate Services Client - Certificate Enrollment…
12
votes
2 answers

SSL Certificate management with Powershell DSC

I have a third-party issued certificate that I need to ensure is running on all targets in a given domain. Is there a way to ensure this certificate is installed by way of DSC?
omencat
  • 225
  • 2
  • 8
12
votes
2 answers

What do the contents of PowerShell's $PSVersionTable represent?

If I echo $PSVersionTable in PowerShell, I get what appears to be multiple bits of version information. The name's of the properties…
Loduwijk
  • 565
  • 3
  • 5
  • 15
12
votes
8 answers

Expire Files In A Folder: Delete Files After x Days

I'm looking to make a "Drop Folder" in a windows shared drive that is accessible to everyone. I'd like files to be deleted automagically if they sit in the folder for more than X days. However, it seems like all methods I've found to do this, use…
Brett G
  • 2,033
  • 2
  • 28
  • 45
12
votes
5 answers

Exchange 2010 Powershell command to check if an email address exists in the system

I'm looking for an Exchange 2010 command that would do the following: Given an email address (fully-qualified with domain and all) check if the email address is associated to some mailbox or group in the system; (Ideally) show which entity owns…
tacos_tacos_tacos
  • 3,250
  • 18
  • 63
  • 100
12
votes
2 answers

Best way to add HKCU keys and values for all existing users and all new users?

I need to add HKCU keys and values to all machines in a specific OU, for all existing user profiles and to the default profile. What's the best way to approach this? I could enumerate and iterate through all the NTUSER.DATs, loading the hive,…
Doug Chase
  • 753
  • 3
  • 12
  • 22
11
votes
5 answers

Public Key Authentication Windows Port of OpenSSH

I have been attempting to get Public Key Authentication working with the PowerShell port of OpenSSH onto a VM running Windows Server 2012 R2. I have faithfuly followed the installation instructions and have assured that my file permissions are…
Foo Barberger
  • 111
  • 1
  • 1
  • 6
11
votes
7 answers

How do I turn windows features on or off using powershell or commandline in windows 7?

I have scripted against sysocmgr in Windows XP, servermanagercmd in server 2008, and now I find that I have to use a new PowerShell module servermanager to install features on Server 2008 R2 and so I would expect that I would use the same module in…
Chris Magnuson
  • 3,771
  • 10
  • 42
  • 46
11
votes
1 answer

Can I change the update descriptions in WSUS?

On each Microsoft patch day, I have a pretty large amount of new updates I want to approve to my clients. But instead of 'Approve all updates and continue', I gather information on each update at its Knowledge Base article to decide, if this is an…
11
votes
1 answer

In what context do SCCM Powershell detection scripts run in?

I have finally had success using PowerShell detection scripts on clients with AllSigned execution policy. (hint: It started working after installing the latest service pack and using Adam Meltzer's workaround.) Now that it's practical to use…
alx9r
  • 1,643
  • 3
  • 17
  • 38
11
votes
2 answers

Powershell: A parameter cannot be found that matches

I am new to the Powershell world. Below is my first script $sServer = "Fully.Qualified.Computer.Name" $os = Get-WmiObject -class Win32_OperatingSystem -computername $sServer $object = New-Object –TypeNamePSObject $object | Add-Member…
Black Dynamite
  • 523
  • 2
  • 5
  • 16
11
votes
4 answers

Use Powershell to start a GUI program on a remote machine

There are two Windows 7 machines setup on the same network. I enabled everything needed so that they could communicate with winrm. When I run the following command: Invoke-Command -ComputerName REMOTE-PC -ScriptBlock { Start-Process calc.exe…
Trevor Hickey
  • 213
  • 1
  • 2
  • 6