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
3 answers

Can I pass a multi-line string to svn in PowerShell?

I have the following line in a script: svn propset svn:externals $newExternals $path Now for the first time $newExternals is a multi-line string (there are several svn:external properties) and svn barks at me in a way that seems to indicate that it…
sbi
  • 463
  • 2
  • 4
  • 12
2
votes
2 answers

Using PowerShell Restart-Service cmdlet with a service that has an instance name

I want to restart a service on a remote machine using PowerShell. The service has both a displayname and an instancename. Can I use the Restart-Service cmdlet to do this? I don't see an instancename parameter, and I can't seem to make the…
dthrasher
  • 207
  • 2
  • 7
2
votes
1 answer

How does the "Last Result" column of Scheduled Tasks in Windows Server 2003 get set from a process or script?

The Last Result column of the Scheduled Tasks Window on Windows Server 2003, displays the result of the execution of the .exe, .vbs, .ps1, .bat, .cmd, etc... that has been run at the scheduled time. There is also an archived history of this value…
leeand00
  • 4,869
  • 15
  • 69
  • 110
2
votes
1 answer

Filesize monitoring powershell script safe to run against a multiuser Access 2003 database?

I'm try to monitor the size of an MS Access Database file which corrupts when the size reaches 2GB. I found the following powershell script which monitors the size of a file, and then runs a command. The script uses (Get-ChildItem…
leeand00
  • 4,869
  • 15
  • 69
  • 110
2
votes
1 answer

Powershell Error recovery

First a confession, I am still quite green with powershell. Anyway I have a powershell script, very similar to PowerShell Script to Loop Over All Users in a Group It has been working fine (the script looks for members of a group and sets an AD…
Alistair
  • 21
  • 1
2
votes
1 answer

Using PowerShell to create user accounts from a CSV

How can I create a domain user account and set the default password in PowerShell from a CSV? Note that I know how to do this, I'm writing this as a self-answered question to share this knowledge. If anyone has a better answer, please chime in!
MDMarra
  • 100,734
  • 32
  • 197
  • 329
2
votes
1 answer

How to list all Active Directory Users and their group membership

I'd like a single scripted line to export to CSV all the users in my AD with all the groups they are members of. I'd prefer it to be done in powershell, but dsquery/dsget is a fine alternative really. EDIT: i have trying to do something like…
user131509
  • 23
  • 1
  • 1
  • 4
2
votes
1 answer

How do I configure permissions for a cluster share using Powershell on 2008?

I have a cluster resource of type "file share" but when I try to configure the "security" parameter I get the following error (excerpt): Set-ClusterParameter : Parameter 'security' does not exist on the cluster object Using cluster.exe I get a…
Andrew J. Brehm
  • 1,611
  • 7
  • 37
  • 57
2
votes
2 answers

How do I restrict sending to a distribution group to an external address?

The AcceptMessagesOnlyFrom parameter takes only a RecipientIdParameter[], which means it's got to be an AD Object. So, I tried creating a Contact Object with the external address specified, but emails are still being bounced. What is the correct…
slipsec
  • 190
  • 2
  • 9
2
votes
1 answer

Exchange 2007 Mailbox Cleanup - Exporting Mailboxes Script

I have been assigned a task to cleanup our Exchange server by exporting the mailboxes of users who have left the company. We want to keep a copy of the mailbox for 90 days, just in case HR or management needs it later. I have over 130+ mailboxes to…
Jake A
  • 454
  • 2
  • 10
  • 22
2
votes
1 answer

Console dump of a DCOM configuration for a given GUID?

Is there a way to dump the DCOM settings for a given DCOM object on the command line, if the GUID is known? (Maybe using PowerShell)
mjn
  • 933
  • 2
  • 12
  • 26
2
votes
1 answer

Using PowerShell switch command with changing values

I am trying to use the switch command to select something out of an array. The array can change sizes depending on information from another spread sheet. For example: C:\> $Test = A C:\> $ListA Item_One Item_Two -------- …
Nick
  • 256
  • 1
  • 5
  • 20
2
votes
2 answers

Removing many Exchange full access permissions on a mailbox

I'm trying to use Powershell to remove certain full access permissions on an account as part of a disable user process. I need to remove all full access permissions on the account except for: NT AUTHORITY\SELF and DOMAIN\svcEnterpriseVault How can…
chris
  • 125
  • 1
  • 5
2
votes
2 answers

Powershell Command to Export Sent Items Count in Exchange 2010

I'm looking to get a count of all sent items for each user in our organization. We are doing an audit of all users to find out which culprit has been sending out tons of emails, so this is why I'm asking. If anyone has a cmdlet or syntax that will…
Jimmy Jones
  • 31
  • 1
  • 2
2
votes
1 answer

Exchange 2010 powershell - select custom attributes

How do I select the custom attribute from the Exchange powershell command get-mailboxstatistics? I would have expected to use something along the lines of get-mailboxstatistics -server dbserver | select DisplayName, ItemCount,…
marcwenger
  • 235
  • 1
  • 6
  • 21