Skip to main content

Get That Server

PowerShell 1.0 introduced us to some very handy cmdlets, like Get-Process and Get-Service. Unfortunately, they only worked locally. If you wanted to run Get-Process and filter out the high memory processes on a remote server, you had to go to that server, logon, open PowerShell and run your command. Or figure out how to do it using Get-WMIObject.

Happily, these cmdlets in PowerShell 2.0 now sport a long needed -Computername parameter:

PS C:\> get-service -computername File01

You can now run the Get-Process command from your desktop, like this:

PS C:\> ps -ComputerName JDHIT01 | sort ws -desc | select -first 10


Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
388 9 4328 162140 181 472 services
1172 44 22528 31876 125 936 svchost
960 86 25580 30540 97 484 lsass
5199 777 23300 22760 70 1352 dns
522 48 9944 13996 95 1508 inetinfo
612 65 9268 13216 64 424 winlogon
303 331 8464 11532 102 1788 tcpsvcs
351 8 7836 11464 83 2028 iexplore
211 8 5340 8092 47 1172 spoolsv
239 16 6156 7104 89 1716 wins

These parameters do NOT require that PowerShell 2.0 be installed on the remote machine. However you probably still will need it, as you'll run into some limitations. For example, the Stop-Service cmdlet does not have a -computername parameter, so you can't do this, for example:

PS C:\> gsv spooler -computername "jdhit01" | stop-service

Well, technically you can run this without error, as it will stop the spooler service on your machine. If you tried this, it will definitely fail:

PS C:\> gsv spooler -computername "jdhit01" | stop-service -computername "jdhit01"

The Stop-Service cmdlet simply doesn't support it.

The other limitation, before you get too excited, is that cmdlets like Get-Service and Get-Process, while now connecting to remote computers, can't use alternate credentials. The cmdlets will use the current credentials. If you need alternate credential support, you'll have to turn back to Get-WMIObject.

What I really want you to take away from this lesson is that you should re-read the help documentation for cmdlets in PowerShell 2.0 -- even those you have used in the past. You might be surprised by a new parameter or two.
===
About the Author Jeffery Hicks (MCSE,MCSA,MCT) is a Microsoft MVP and an IT veteran with almost 20 years of experience, much of it spent as an IT consultant specializing in Windows server technologies. He works today as an independent author, trainer and consultant. Jeff has co-authored or authored several books, courseware, and training videos on administrative scripting and automation. His latest book is Managing Active Directory with Windows PowerShell: TFM (SAPIEN Press 2008). You can follow Jeff at twitter.com/jeffhicks and jdhitsolutions.com/blog.

Popular posts from this blog

Alternative Social Networks

If you are planning to create your social network e.g. similar to Facebook. Here's a short list of alternative software's:

Open Source and Free​
http://buddypress.org/ - Wordpress (Open Source and Free)http://elgg.org/ - (Open Source and Free)Commercial Social Networks software
http://www.socialengine.com/ ($299 Stand Alone, $29/mo Cloud)http://www.jomsocial.com/ (run with Joomla, need to know CMS)http://www.boonex.com/ (very expensive, $399 for Standard)http://www.anahitapolis.com/http://www.oxwall.org/http://sharetronix.com/http://www.moosocial.com/http://www.jcow.net/http://phpdolphin.comhttp://www.grou.ps (from free to Commercial, I left my networks and they are selling it http://www.phpfox.com/ (I used this before, it's hard to maintain. I moved to NING but left too after it was sold to another company)http://www.ning.com (I don't recommend using this service, it's hard to export your data when it's time to move)Something to check when selecting your next soc…

Example of Out of Office Reply for Terminated Employee

This is a sample message that I used for terminated employees, unless HR staff specified a different message.
=== Example for KING.NET Employee === John Doe (employee or consultant) is no longer with KING.NET effective June 1, 2008 (termination date). For matters relating to "Project Name here" please direct your concerns to John Smith at johnsmith@king.net (Manager or Supervisor). For all other matters, please direct your email to Mary Smith HR at marysmith@king.net.
Please call our main office 703-345-6789 if you have other concerns.
Thank you.
=== end of message ===

Frequent Account Lockout in Active Directory

I have a user in Windows Pro 7, and Windows Server 2003 environment that is frequently account locked out. I tried many different scenarios to resolve this account lockout issue, from resetting his password, changing a new password, remove and re-join the domain, rebooting the workstation and active directory servers.

I tried to use the command prompt utility to run "rundll32.exe keymgrdll, KRShowKeyMgr" (case sensitive) to delete the account in Windows 7 password cache, and still no luck.

Still searching for answer ... Let me know if you encounter a similar issue in Windows Pro 7 and Windows Server 2003.

Continue reading updated post here:
http://www.whaddya.com/2011/09/windows-needs-your-credentials.html