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.

Comments

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.com http://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) S

Learning Vulnerability Scanning by KING.NET

Learning Vulnerability Scanning is fun and easy. So I hope you enjoy reading this short how to guide on how to use vulnerability scanning to secure your servers and networks. NMAP is the swiss tool that you need to learn if you're serious in Cyber Security profession. The NMAP tool can be use with NSE scripting (Nmap Scripting Engine) to automate your tasks. For example using NSE Script using a  single vulnerability (cold fusion)  to scan our test lab machine. root@kali:~# nmap -v -p 80  --script http-vuln-cve2010-2861  10.11.1.220 Starting Nmap 6.47 ( http://nmap.org ) at 2016-07-22 17:34 EDT NSE: Loaded 1 scripts for scanning. NSE: Script Pre-scanning. Initiating ARP Ping Scan at 17:34 Scanning 10.11.1.220 [1 port] Completed ARP Ping Scan at 17:34, 0.04s elapsed (1 total hosts) Initiating Parallel DNS resolution of 1 host. at 17:34 Completed Parallel DNS resolution of 1 host. at 17:35, 13.01s elapsed Initiating SYN Stealth Scan at 17:35 Scanning 10.11.1.220 [1 port] Comp