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, ...

learn more… | top users | synonyms (1)

27
votes
1answer
6k views

Sometimes PowerShell stops sending output until I press enter. Why?

Periodically I notice PowerShell seems to take forever to finish doing whatever it is I told it to do until it occurs to me to "wake it up" by pressing enter. This is not the fault of any one process ...
17
votes
4answers
75k views

How to create Active Directory user account with powershell

I am constantly setting up research and development environments that require active directory accounts. Since we place these environments in isloated networks each environment needs its own active ...
14
votes
2answers
9k views

How can a standard Windows user change their password from the command line?

On Windows Server 2008 R2, I have a standard (non-administrator) local user (not an Active Directory account, though the server is in a domain) who has access to the server only via PowerShell ...
2
votes
2answers
1k views

Reporting SCEP update and scan

I am using Microsoft System Center Endpoint Protection on all of the workstations I manage. For all three major platforms, it is a pain to get it to report on when it was last updated and last ...
1
vote
2answers
1k views

Set NTP server on all AD members (old and newly connected) using w32tm or PowerShell?

I am looking for a PowerShell script that I run one time only on the DC. I found w32tm but I don't know how to use it. Thanks in advance!
97
votes
11answers
106k views

How to zip/unzip files in Powershell?

Is there a one-liner that will zip/unzip files (*.zip) in PowerShell?
12
votes
1answer
14k views

How do I run my PowerShell scripts in parallel without using Jobs?

If I have a script that I need to run against multiple computers, or with multiple different arguments, how can I execute it in parallel, without having to incur the overhead of spawning a new PSJob ...
11
votes
2answers
12k views

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 ...
8
votes
11answers
29k views

Scripting - How to disconnect Remote Desktop sessions?

I am looking for a way to close all active Remote Desktop sessions on a computer (local computer). Windows includes a couple of commands (rwinsta, qwinsta, etc.) to look at the active sessions, but I ...
6
votes
3answers
17k views

How to use a config file (ini, conf,…) with a Powershell Script ? Is it possible?

Is it possible to use a configuration file with a PowerShell script ? for example, the configuration file: #links link1=http://www.google.com link2=http://www.apple.com ...
8
votes
2answers
11k views

How do I grant permissions to remotely start/stop a service using Powershell?

We have a PowerShell script that restarts a service on another computer. When we use PowerShell's built-in service control cmdlets, like so: $svc = Get-Service -Name MyService -ComputerName ...
0
votes
1answer
2k views

Parse wevtutil XML into a database?

I'm by no means an XML expert. Ergo, I'm having trouble importing Windows event XML from wevtutil into an SQL database. Prior to Server 2008, we exported event log data to the database directly ...
7
votes
4answers
16k views

Enabling Powershell Remoting, Access is denied?

I am trying to enable Powershell remoting on a Windows 2008 R2 Server, running in workgroup mode. I ran the command Enable-PSRemoting in the PowerShell Console. PS C:\Windows\system32> ...
2
votes
1answer
4k views

Possible to upgrade PowerShell 2.0 to 3.0 without a reboot?

Is it possible to upgrade powershell without reboot from 2.0 to 3.0 using Windows Server 2008?
1
vote
1answer
524 views

MailboxExportRequest ContentFilter is “Received -ne $null” when querying by date

I am trying to export a mailbox to a PST. All email that was received before yesterday is what I am trying to export. $y = ((get-date).addDays(-1)).ToShortDateString() $exportRequest = ...
6
votes
4answers
1k views

Is it possible to disable msiexec help GUI?

I'm automating unattended retrieval & installation of specified .msi packages with a powershell script but if the command is invoked with syntax errors the msiexec will wait indefinitely for an OK ...
4
votes
1answer
778 views

With powershell get exactly the same application list as in Add/Remove programms

There are various methods to find installed applications on the system but to my knowledge none returns exactly the same list as control panel item Add Remove Programs. Some of the ways I tried are: ...
1
vote
0answers
39 views

How do I extend the timeout value for long-duration playbooks ran against Windows servers?

I have Ansible playbooks that can transfer files to Windows servers. I have Ansible playbooks that can run small PowerShell scripts. But I cannot get an Ansible playbook to run a long-running ...
1
vote
3answers
13k views

Can I use Powershell to configure Local group policy settings in windows server 2008 r2

in Windows server 2008 r2 , for this manual process open run >gpedit.msc > computer configuration > windows templates > windows update > specify intranet microsoft update service location > ...
1
vote
1answer
5k views

replacing a line or date in a text file using powershell

I am trying insert today's date on a text file at line 59. How do i do this? Line 59 has like 30 spaces and then reads like this. After the PowerShell script runs it will change the date so it has to ...
0
votes
2answers
292 views

Powershell script to display all groups and their users

I'm currently trying to write a script that displays each group and user in the domain. Import-Module ActiveDirectory $Groups = (Get-AdGroup -filter * | Where {$_.name -like "**"} | select ...
0
votes
1answer
1k views

PowerShell Script to Move ADUser to appropriate group based on its Department ID attribute

I am new to PowerShell and AD, I have a small task which I am finding difficult to complete. Can someone please help me here ? The task is as follows: There are 3 groups defined in AD, namely ...
0
votes
1answer
518 views

Auto-Tagging EC2 Instances in AWS (Windows Servers only)

I am looking for some guidance from the serverfault community. We are spinning up several new AWS instances (windows server 2008/2012) over the next few days. We have a naming convention in place for ...
0
votes
2answers
3k views

PowerShell script works from command line, not from Task Scheduler. Why?

My PowerShell script works from the command line, but not from Task_Scheduler. This is PowerShell v1 on Windows Server 2008 R2 Enterprise. From the command line, I type: c:\> powershell -File ...
42
votes
22answers
17k views

PowerShell? Do you use it? Can you show me some cool system administration things I can do with it? [closed]

I keep reading everywhere that PowerShell is the way of the future. When it was first released I did a whole bunch of virtual labs, but since then I still haven't used it in a production environment. ...
52
votes
8answers
54k views

How do I diff two text files in Windows Powershell?

I have two text files and want to find the differences between them using Windows Powershell. Is there something similar to the Unix diff tool available? Or is there another other way I haven't ...
15
votes
7answers
66k views

Powershell: How do I query pwdLastSet and have it make sense?

I need to get the last password change for a group of account in an Active Directory security group, and I feel like this is something PowerShell should be good at. Right now, I'm already stuck at ...
11
votes
8answers
4k views

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 ...
6
votes
3answers
21k views

Cannot get CredSSP authentication to work in PowerShell

In attempting to create a PowerShell script using remoting I ran into what I believe is the double-hop problem. In that article, Perriman gives a succinct description of the problem as well as the ...
5
votes
6answers
38k views

Execute program on remote computer using PowerShell

How can I execute a program on a remote machine using powershell?
14
votes
3answers
25k views

What is the literal escape character in Powershell?

When including a literal quote character inside a quoted string in Powershell, how do I escape the quote character to indicate it is a literal instead of a string delimeter?
12
votes
7answers
20k views

Force-remove files and directories in PowerShell fails sometimes, but not always

I am trying to delete a directory recursively with rm -Force -Recurse somedirectory, I get several "The directory is not empty" errors. If I retry the same command, it succeeds. Example: PS ...
10
votes
2answers
4k views

Issues with patching servers remotely using winrm and Microsoft.Update.Session

I have a network with windows 2003, 2008 and 2008r2 servers. I have a powershell script that I wrote to patch a local machine using the "Microsoft.Update" com objects. (Similar to Windows Update ...
5
votes
1answer
279 views

Possible to use Powershell to detect if an HP server has a bad drive?

I'm trying to use Powershell to detect certain hardware failures. Can Powershell hook into normal HP events/logs/alerts to detect if a drive failed?
4
votes
2answers
972 views

NTFS formatted removable storage, safely remove / unmount via command line?

We've just setup some removable storage for a file server we run in one of our offices (only supporting less than 10 work stations), one of our backup solutions is a removable harddrive that will ...
3
votes
1answer
1k views

How can I get a static download link for a Microsoft MSDN Subscriber Download?

I need to be able to download MSDN ISO files directly from power shell, and therefore I am wondering how can I do this? I can view the downloads site at ...
8
votes
2answers
20k views

Server 2012 Server Core powershell not installed

In server core, after a restart powershell was all of a sudden not installed, what do I do to reinstall it? I do not have remote administration set up yet so I cannot use that to re-install it. ...
8
votes
1answer
7k views

Redirect stderr to variable in powershell

I would like to script a dcdiag test to alert me if it finds any errors. I thought I may able to do this in powershell by... $test = dcdiag 2>$err I don't have any errors from dcdiag at the ...
7
votes
6answers
11k views

How to enable volume shadow copy using Powershell?

How to enable volume shadow copy on specific drive (D:, E:,...) and set up schedule using Powershell ? I just need some hints how to start.
4
votes
2answers
3k views

Remotely run a script invoking “Run As Administrator”

This is as close to the exact question that I have, but looks like he found another way that fits the needs so it has been marked as answered: I have a Powershell script running on server A that I ...
4
votes
3answers
13k views

Why does my PowerShell script hang when called in PSEXEC via a batch (.cmd) file?

I'm trying to remotely execute a PowerShell script using PSEXEC. The PowerShell script is called via a .cmd batch file. The reason we do this is to change the execution policy, run the powershell ...
3
votes
2answers
711 views

Connecting to Exchange PowerShell from a Linux machine

We currently have a Python script that automates user creation tasks on our servers. This script provisions users in OpenLDAP and ActiveDirectory by using python-ldap. Now, I want to modify some ...
2
votes
1answer
82 views

Automatically run PowerShell script at first boot

We use Hyper-V + SCVMM to host Windows Server 2012 (R2) virtual machines. Currently our deployment procedure includes a lot of PowerShell commands that we have to copy/paste after the VMM template is ...
18
votes
3answers
7k views

How do I delete this orphaned Active Directory computer object (preferably with PowerShell)?

I'm working from a Windows 7 workstation, with PowerShell v2.0, and trying to delete a particular (orphaned?) object from the LostAndFound container in a 2008 R2 FL forest and domain with the Active ...
10
votes
1answer
6k views

Unzip File With Powershell in Server 2012 Core

I need to unzip a file with powershell. The typical way I've seen everyone do this is by automating the shell with a script. $shellApplication = new-object -com shell.application $zipPackage = ...
8
votes
3answers
15k views

Run remote powershell as administrator

Before I dive into the question, I have found several other questions that seem similar to mine, but they have not been able to solve my problem. Here are links to them: Remotely run a script ...
7
votes
3answers
26k views

Adding a user to the local Administrator group using powershell

I would like to use PowerShell to add a specific user to the local administrator group on a machine. I would be running the PowerShell script in the context of a user that has Administration rights ...
6
votes
1answer
6k views

Looking to add the “Log On as a service” right to an account via the command line

I am looking to make a user from the command line with minimal rights to run a service. cmd.exe or powershell.exe are both options, but cmd.exe is preferable. So far I got this: net user /add ...
4
votes
2answers
3k views

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 are CLRVersion BuildVersion PSVersion WSManStackVersion ...
4
votes
1answer
6k views

Running PowerShell scripts as an Application in MDT 2013

Is there a way to make powershell scripts run under the applications list so that when you install from the MDT image you can select which scripts you want to run? I can run the scripts fine as ...