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)

20
votes
1answer
3k 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
68k 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 ...
2
votes
2answers
378 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
548 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!
93
votes
10answers
91k views

How to zip/unzip files in Powershell?

Is there a one-liner that will zip/unzip files (*.zip) in PowerShell?
11
votes
1answer
7k 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
10k 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 ...
12
votes
2answers
6k 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 ...
6
votes
11answers
27k 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 ...
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 ...
1
vote
1answer
2k 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?
5
votes
4answers
9k 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> ...
4
votes
4answers
816 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 ...
1
vote
1answer
3k 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
147 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
3answers
7k 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 > ...
0
votes
1answer
795 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
321 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
2k 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 ...
41
votes
22answers
16k 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. ...
13
votes
7answers
56k 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 ...
44
votes
7answers
42k 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 ...
11
votes
8answers
3k 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 ...
5
votes
3answers
13k 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 ...
4
votes
6answers
30k views

Execute program on remote computer using PowerShell

How can I execute a program on a remote machine using powershell?
8
votes
2answers
3k 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 ...
4
votes
2answers
955 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 ...
9
votes
4answers
12k views

PowerShell remove force

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 I:\Documents ...
7
votes
2answers
12k 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. ...
6
votes
2answers
8k 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 ...
6
votes
6answers
7k 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
2k 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
10k 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
627 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 ...
18
votes
3answers
4k 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
4k 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 = ...
7
votes
3answers
9k 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
1answer
5k 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
3answers
22k 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
1answer
3k 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 ...
4
votes
6answers
1k views

Powershell assistance for Active Directory Cleanup

I just started a contract to clean up an Active Directory system for a large company. I was told it would be quite the busy work but after reviewing the system and seeing how disorganized and messy it ...
4
votes
5answers
2k views

Is there a way to get PowerShell 2's remoting features to work between Windows XP machines?

PowerShell 2.0 has some super-snazzy remoting features. However, I'm unclear if they can be made to work with / between Windows XP machines, or if you need Windows Vista or Windows 7. ...
3
votes
2answers
670 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 ...
3
votes
1answer
704 views

Strange format-list behavior in this PowerShell script

I have a weird behavior with format-list. When I paste the following code directly into the shell - everything works like a charm: @("Administrator","SomeUser","SomeOtherUser") |% { ...
3
votes
2answers
8k views

Dismount USB External Drive using powershell

I am attempting to dismount an external USB drive using powershell and I cannot successfuly do this. The following script is what I use: #get the Win32Volume object representing the volume I wish to ...
2
votes
2answers
2k views

Powershell scan for network attached printers

Currently I'm working on creating a PS script to scan a network and retrieve all of the Windows Servers, their product keys, SQL Server product keys, CPU, RAM, Network Shares and Services on all the ...
2
votes
2answers
7k views

Using Powershell to bulk change the Home folder path of AD objects - %username"?

I have done a lot of searching on this, and still cannot find the answer. I have created a script which will bulk move all user objects in one OU to another OU. This works fine. Now I am trying to ...
2
votes
2answers
2k views

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 ...
2
votes
1answer
891 views

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