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)

8
votes
2answers
140 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
1answer
4k 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
1answer
352 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
2answers
674 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
4answers
12k views

How to properly add .NET assemblies to Powershell session?

I have a .NET assembly (a dll) which is an API to backup software we use here. It contains some properties and methods I would like to take advantage of in my Powershell script(s). However, I am ...
8
votes
2answers
1k 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 ...
8
votes
2answers
778 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 ...
7
votes
8answers
294 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
499 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
7answers
32k 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 ...
7
votes
3answers
3k 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
29k views

Is ServerManager module available on Windows 7?

Is ServerManager module available on Windows 7 Ultimate ? I think (but I'm not sure because I never looked at output before) the PS script that I have worked before but after some problems with IIS7 ...
7
votes
3answers
19k views

Adding a user to the local Administrator group using powershell

I would like to use powershell to add a spesific 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
389 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
3answers
675 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
2k views

How can I compare installed hotfixes between two Windows servers using PowerShell?

I need to compare the installed patches between a dev and production environment using PowerShell. How can I do this?
7
votes
2answers
6k 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
2answers
1k 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
3k 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
6answers
3k 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 ...
6
votes
11answers
24k 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
1answer
522 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
4k 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') { ...
6
votes
2answers
2k views

Where do you share or find useful powershell, bash, batch, vbs, scripts?

I just wrote a quick little powershell script to make my life easier for a task that I was facing. I thought it would be nice to put it on the Internet, where someone else may also find it useful. The ...
6
votes
2answers
508 views

Invoke-Restmethod breaks script in PS 4.0

I had a Powershell script that used Invoke-RestMethod that was working in powershell 3.0. However, I upgraded to powershell 4.0 to fix a bug in powershell 3. When I did so, my script seems to have ...
6
votes
2answers
578 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 ...
6
votes
3answers
2k 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 ...
6
votes
3answers
847 views

How to get a user's privileges?

I can get the logged in user's privileges in powershell like so: whoami /priv How do I do this for a user I'm not logged in as?
6
votes
5answers
4k views

Query schtasks using Powershell

On a Windows7 machine I am trying I can run a query to view all the scheduled tasks using schtasks.exe This is fine but I would also like to filter the result set using something like schtasks ...
6
votes
2answers
5k 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
1answer
172 views

How can I generate a list of the security groups a set of users belong to?

I have been asked to generate a list of the security groups (so specifically not the distribution groups) that a list of approximately 50 users belong to. I have a list of users, users.txt that ...
6
votes
1answer
364 views

Evaluating current ACEs on NTFS ACLs with PowerShell

We have a document management system that has million of files on a NTFS file system accessed through a network share. A single service account needs full permission to all of these files and the ...
6
votes
1answer
475 views

How to override the default dir alias in Powershell?

I wanted to see colorized filenames when I typed dir in Powershell. So, I added the Set-ChildItemColor function from here to my profile file. I also added this line at the end of the profile file to ...
6
votes
3answers
2k views

powershell how to remove broken symlink

PS C:\> cmd /c mklink /d testlink non-existent-dir symbolic link created for testlink <<===>> non-existent-dir PS C:\> rm .\testlink Remove-Item : C:\testlink is a NTFS junction ...
6
votes
1answer
273 views

DSC, how to know if after running the configuration a reboot is required

So I'm using DSC Push mode I have about 200 deployments per day to several environments (DEV/INT/QA/PROD) Every time that I deploy I want to make sure that each server is configured correctly So ...
6
votes
1answer
13k 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 ...
6
votes
2answers
261 views

Managing Windows Powershell from Linux terminal

I manage some Windows Server 2012. I'm learning PowerShell to manage this servers through command line. My workstation runs Ubuntu and I connect via ssh to manage Linux servers. There is a way that I ...
6
votes
2answers
99 views

Managing multiple PowerShell prompts

If I have multiple Powershell Prompts to different machines, it can get confusing. While, the command prompts all show the machine I am at, I was trying to find a solution that changed the titlebar ...
6
votes
2answers
887 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 ...
6
votes
3answers
4k views

Find files across all drives using Powershell

I know how to search for files using dir/gci, but that only works across one drive AFAIK. Is there a way to search across all drives on the computer? Is there a way without manually enumerating then ...
6
votes
1answer
1k 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 ...
6
votes
1answer
2k views

PowerShell 3.0 x64 bit broken after installing KB2506143

I have searched using all kinds of variations on relevant terms and I cannot find a single other instance of someone else having this excact same problem, so I am hoping someone here may have a clue. ...
6
votes
3answers
5k 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 ...
5
votes
6answers
2k views

How do I monitor who's logged in?

We in our department are implementing a new admin policy: everyone in a department which we support will receive admin access to their computers. We need to know (while we are performing this "pilot ...
5
votes
11answers
62k views

Windows command prompt: how to get the count of all files in current directory?

What command would you use in cmd.exe to find the number of files in the current directory? Is there a powershell option here? Update: I was hoping to avoid dir, as I know there are 10,000+ files in ...
5
votes
3answers
3k 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 ...
5
votes
6answers
14k views

How do I set an environmental variable from a powershell command?

I want to have a environment variable that contains the day of week in cmd.exe. When I run this command I get the result I want. C:\Users\tisc>powershell (get-date).dayofweek Friday Here I'm ...
5
votes
2answers
6k views

Install .NET 4 via command line or PowerShell?

How do I install .NET 4 on Windows Server 2008 R2 from the command line or PowerShell? This post shows how to do it for .NET 3.5 using dism.exe and PowerShell. I am guessing that, since the .NET 4.0 ...
5
votes
3answers
5k 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.
5
votes
4answers
17k views

Creating a Share with Permissions with Windows Powershell

Using Powershell how can I create a share and set access permissions. For example as follows Create share called "public" that maps to the "path c:\shares\foo" Allow DOMAIN1\Users to have ...