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

powershell call operator with multiple arguments?

I am trying to use the powershell call operator to essentially run the following command: "C:\Program Files (x86)\PuTTY\plink.exe" "-v -agent -m C:\Scripts\idrac_powerup_commands.txt root@[servername]" Current Code $runputtyscript =…
2
votes
1 answer

How to change all users Ad Email contact using powershell

I need a script that will change all of my ad users email contact field information. The format will be the "SAMAccountName + @domain.com". I am a powershell noob and need a little help on the syntax. Any help would be appreciated.
user157877
  • 21
  • 1
  • 1
  • 2
2
votes
1 answer

Powershell script on the hidden file share not accesible on the workstation

We have a PowerShell script script.ps1 on a hidden shared folder \\Server\Share$. We have a bat file Initiator.bat, which executes the script. The shortcut to the batch file is placed on the user's desktop, which is where they run it…
Darktux
  • 827
  • 5
  • 21
  • 36
2
votes
2 answers

Automate running Cisco VPN Client and RDP

I am trying to automate running the Cisco VPN Client and then a RDP session. What is a good way to do this? Batch File? Powershell? Other I have played with a batch file and this kind of works. cmd.exe /c "C:\Program Files\Cisco Systems\VPN…
Gerhard Weiss
  • 131
  • 2
  • 6
2
votes
1 answer

Powershell VMWare Script not running from Scheduled Task

Background / Goal I am attempting to create a scheduled task that will: Run at the specified time (once) Run a PowerShell script that: Logs all of its output as a transcript Connects to my vCenter server using encrypted, stored credentials Shuts…
SeanKilleen
  • 1,083
  • 8
  • 25
  • 38
2
votes
1 answer

PowerShell script not completing what it should do when scheduled with Windows Task Scheduler

I found a script that can delete files over X days old and changed it a bit so that I will scan different network folders to see if there are files that are older than X days. Now when I run the script with PowerShell ISE the script is working fine…
Yves Strobbe
  • 21
  • 1
  • 2
2
votes
2 answers

Remove email addresses by policy

Is there any elegant way to remove email addresses from users using automation, Powershell or Exchange Email Address Policies? The platform in question is Exchange 2007. I would like to modify email addresses of departed users so that their address…
2
votes
1 answer

Uninstalling KB2506143 (WMF 3.0) from Windows 2008R2 with Exchange 2010 SP2 doesn't work

KB2506143 was installed on Exchange 2010 SP2 machine on Windows 2008 R2. Since WMF 3.0 was installed Rollup Updates cannot be installed as they fail on starting some PowerShell scripts. Normal scenario assumes that uninstalling that patch works and…
MadBoy
  • 3,725
  • 15
  • 63
  • 94
2
votes
2 answers

SQL Agent Powershell Job Failing with Non-Admin Proxy

I'm attempting to create a SQL Agent job that will run a PowerShell script that is saved on my system. However, the job fails with the following error: A job step received an error at line 1 in a PowerShell script. The corresponding line is…
MaddHatter
  • 21
  • 1
  • 4
2
votes
1 answer

Mirror directory, only purging files in destination directory older than 7 days

I would like to mirror a directory, but only delete files in the destination directory older than 7 days. Situation: - Directory A is mirrored to Directory B. - A file from Directory A is deleted I would like for that file to remain in Directory B…
user1905482
  • 21
  • 1
  • 2
2
votes
3 answers

Exchange 2010 - Mailbox Export much larger than actual size

I issue this command to export the mailbox of a user: New-MailboxExportRequest -Mailbox "user" -FilePath "\\server\share\user.pst" After 2 minutes or so, this file have been generated: Notice the size of the export file, and now this is the actual…
2
votes
1 answer

(Powershell) Method to return a list of groups where a specific user has 'write member' security

We use a piece of web-based software that users can log on to in order to manage access to shares controlled with AD groups. The list of groups a user can manage are the groups on which they have 'Write Members' security. This allows users to…
2
votes
1 answer

Specify Powershell to run on .NET 3.5 after WMF 3.0 install

I just installed the .NET Framework 4.0 and WMF 3.0 on a Server 2008 R2 SP1 machine that has SharePoint Foundation 2010 installed on it. Now, when I go to Start - All Programs - Microsoft SharePoint 2010 Products - SharePoint 2010 Management Shell…
GemCer
  • 175
  • 1
  • 6
2
votes
2 answers

Powershell Get-Process cannot connect to remote computer

I've been struggling with this for a few hours and can't figure this out. I have two Windows 7 computers. One is my workstation that is using Powershell to do administrative maintenance. The other is the machine I'd like to use Powershell remoting…
amandion
  • 323
  • 2
  • 4
  • 7
2
votes
2 answers

Powershell wait for compressing to finish

I have written a PowerShell script that zips the contents of a folder and sends it to a server for backup. The issue is that the copy process doesn't wait for the zip process to finish. I have tried using Out-Null and Wait-Process, and nothing…
Patrick
  • 147
  • 3
  • 11