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)

9
votes
1answer
22k views

How to ignore an error in Powershell and let it continue?

I am trying to see if a process is running on multiple servers and then format it into a table. get-process -ComputerName server1,server2,server3 -name explorer | Select-Object ...
9
votes
1answer
1k views

What the heck is going on with this AD filter in PowerShell?

I recently wrote this answer and stumbled on something interesting. get-aduser -filter {-not (description -eq "auto")} | measure-object and get-aduser -filter {description -ne "auto"} | ...
9
votes
2answers
2k views

ESXcli command timeout at 30 minutes

I am working on a powercli script to loop through each datastore in our environment and reclaim space on the thin provisioned LUNs. All LUNs in the environment are Dell Equal Logic. vCenter ...
8
votes
7answers
38k views

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

Detecting AD Site options using PowerShell

How can I use PowerShell to find AD site options like +IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED in PowerShell? I've been playing around with the following command, but can't get it to spit out anything ...
8
votes
2answers
7k views

Import-Module Azure fails

I am trying to work with Windows Azure PowerShell module on Windows 8.1. I have downloaded and installed the Azure module and in start I can run and use the "Windows Azure PowerShell" which is a PS ...
8
votes
3answers
5k views

How can I add ACL permissions for IIS APPPOOL\* accounts via Powershell?

I want to be able to set the IIS account for new websites to have modify permissions. I have the following script: function Set-ModifyPermission ($directory, $username, $domain = 'IIS APPPOOL') { ...
8
votes
6answers
594 views

Powershell challenge

I've been challenged by a friend to do the following: "Find the quickest and easiest way of sorting a directory listing by the LAST character of the filenames." He's done it on Linux using the ...
8
votes
1answer
252 views

Is there a version of the AD tools that provide the PowerShell output, similar to the Exchange tools?

The Exchange administration tools output the exact PS commands they will (or just did) execute. Is there a different version of the AD tools (primarily AD Users & Computers) that have similar ...
8
votes
3answers
336 views

PowerShell: Get-ADUser Properties with åäö

I'm trying to extract select sets of users with Get-ADUser. The users belong to companies whose names include non-ASCII characters, e.g. "Gåäördet". Unfortunately, we do have to use the company ...
8
votes
1answer
3k views

How do you manually set Powershell's OneGet repository source to Chocolatey?

The OneGet Powershell module should ship with the default repository being Chocolatey. This is shown in the documentation found here. However when I run Get-PackageSource it returns PSGallery and ...
8
votes
2answers
592 views

Powershell Remotely Delete PKI Certificates

I recently rebuilt my PKI and I would like to delete the certificates that were issued to all client machines across my network. Sounds like a job for Powershell! So I wrote this script to be ...
8
votes
2answers
6k views

Remotely renaming a domained Win 7 computer

I'm having a hard time figuring out how to rename a Windows 7 computer remotely. This is for automating Win 7 builds in a vSphere 5 environment, and I'm trying to get it as hands-off as I can. So far ...
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 ...
8
votes
1answer
589 views

How to accept EULAs for Software updates deployed through SCCM using Powershell

I'm trying to use the Start-CMSoftwareUpdateDeployment cmdlet to deploy a software update group to an existing collection. PS WHO:\> Start-CMSoftwareUpdateDeployment -SoftwareUpdateGroupName ...
8
votes
4answers
787 views

Test-Cluster Powershell cmdlet List vs Validate

The Powershell cmdlet Test-Cluster queries a myriad of data and performs validation tests which it wraps into a pretty report. If you run Test-Cluster -List you get a list of item's you can ...
8
votes
2answers
801 views

Using Diskpart in a PowerShell script won't allow script to reuse drive letter

I built a script that mounts (attach) a VHD using Diskpart, cleans out some system files and then unmounts (detach) it. It uses a foreach loop and is suppose to clean multiple VHD using the same ...
8
votes
2answers
2k views

Is there a way to show an RDP session's encryption level from the commandline/Powershell?

For Windows 2008, I need to create a script that will show whether connected RDP sessions are set at "high" encryption or something else (e.g., "compatible"). Does anyone know of a way to get this ...
7
votes
6answers
8k 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.
7
votes
8answers
302 views

Is Vanilla Powershell Enough of a Language for Windows & DB Server Admins?

Does a clean install of PowerShell on its own have enough functionally to Admin a Windows domain environment and/or SQL Servers? If not what are good, free or pay for, third party add-ons?
7
votes
3answers
834 views

AD reset user passwords for a security group

I'm not quite sure if this is possible or not, but I need to force a certain security group's users to have their passwords expire so they'll be forced to change them on next login. The reason for ...
7
votes
3answers
238 views

PowerShell - Install-WindowsFeature (and family) missing on Windows 10?

We have some Powershell scripts used to set up various dev/test/prod environments and one of them installs and configures IIS. Unfortunately these scripts don't appear to be working under Windows 10 ...
7
votes
3answers
4k views

How can we check PowerShell v2.0 is installed on a list of servers?

How can I check if PowerShell v2.0 is installed on a list of servers? The list of servers is a combination of Windows Server 2003 and Windows Server 2008. A vbscript or PS script would be wonderful. ...
7
votes
3answers
23k 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 ...
7
votes
1answer
801 views

How to rejoin domain when trust relationship is lost

I have a number of virtual machines which have snapshots applied by using a PowerShell script. Occasionally, the virtual machines lose their "trust relationship" with the domain. This breaks the ...
7
votes
1answer
295 views

How to edit Active-Directory Site properties via Powershell?

I am having trouble accessing the location property of my Active-Directory's Site via Powershell. (Windows Server 2012 R2) The following command returns no value: > (Get-ADReplicationSite ...
7
votes
2answers
575 views

What's the difference between Remove-WindowsFeature and Uninstall-WindowsFeature?

What's the difference between Remove-WindowsFeature and Uninstall-WindowsFeature? I've used Add- and Remove- on Windows 2008 R2 boxes, but there is now an Install- and Uninstall- which according to ...
7
votes
2answers
3k views

How to print out information about Task Scheduler in powershell script?

I am trying to print out information from the Task Scheduler from the local computer in a PowerShell script so other users can print out this information as well and not have to access the Task ...
7
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 ...
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
848 views

Delete a windows group in Active Directory

I am doing a cleanup of some AD groups that are no longer used. One of the AD groups I could not delete because it seems that a member has this group set as the primary group (which I assume someone ...
7
votes
1answer
366 views

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 ...
7
votes
2answers
13k 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. ...
7
votes
4answers
5k views

How to find the creation date of a local user account?

I would like to get the creation date of a local user account (Win 7 if it matters). I've looked at the following WMI objects (and google of course): Win32_UserAccount Win32_NetworkLoginProfile The ...
7
votes
3answers
1k views

Cannot set Powershell ExecutionPolicy for CurrentUser

Here is a sample of the commands I am running: PS C:\> Get-ExecutionPolicy -List Scope ExecutionPolicy ----- --------------- MachinePolicy Undefined UserPolicy ...
7
votes
2answers
2k views

powershell: How to check if S.M.A.R.T is enabled on remote machines

I was attempting to get disk info of remote machines, including whether or not SMART is enabled on the drive by using the win32_diskdrive class. This is trickier than I thought. While it's easy ...
7
votes
2answers
2k views

Test for Localhost in Powershell?

I have a powershell script that calls Get-WmiObject with -Credential. However, this errors out if I am running it against the local machine: Get-WmiObject : User credentials cannot be used for local ...
7
votes
2answers
5k views

Using namespaces in Powershell

Thought about it while answering this question. How can you avoid the need to fully qualify every single type in a namespace? It's really, really tedious to write ...
7
votes
2answers
1k views

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

PowerShell Remoting w/ Exchange 2010: Value cannot be null

I'm having difficulty running Exchange 2010 cmdlets through remote PowerShell sessions. I start my local PowerShell session as Administrator and issue the following commands -- PS ...
7
votes
3answers
10k 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 ...
6
votes
3answers
6k views

How do I diff two folders in Windows Powershell?

I'm trying to find differences in the content of two folder structures using Windows Powershell. I have used the following method to ensure that the file names are the same, but this method does not ...
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 ...
6
votes
5answers
8k views

How to run a PowerShell script from Cygwin SSH session?

Hi I have Windows Server 2003 with CopSSH installed on it ( Cygwin + sshd ). W would like to be able to run a PowerShell script via SSH session command and then use it's output. Is there such ...
6
votes
1answer
3k views

PowerShell: How to customize prompt?

I like to define the env variable PROMPT as $p$_$g so prompt starts in a new line. But seems to be not applying to my PowerShell prompt :-( dir function:/ shows that a name "prompt" is already ...
6
votes
2answers
19k views

Run Elevated Powershell prompt from command-line

Is there a way to run a Powershell Prompt with Elevated privileges from a command linein Server 2012? Problem is this is 'Minimal Server Interface' mode without full server-gui installed so I can run ...
6
votes
1answer
682 views

Why does ForEach behave differently than % even though they are both aliases of ForEach-Object in Powershell?

For some reason the % alias for ForEach-Object throws an exception when using the ( $Thing in $Things) syntax while the ForEach alias works fine. Here are two examples: Using the % alias: $ints = ...
6
votes
3answers
207 views

Is it possible to create a generalized configuration file for installing Windows features using PowerShell?

I'm currently trying to automate the build of a VM running Windows Server 2012 R2. At the moment the challenge is automating the addition of roles and features. Within the roles and features wizard ...
6
votes
2answers
207 views

Automating WSUS via PowerShell

I have written a script with the intention of quickly managing the WSUS process, and I have a few things I hard coded in, but would rather get with PowerShell. In particular, the 'Target' groups for ...
6
votes
3answers
27k views

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