PowerShell and Property Value
In “PowerShell 101, Lesson 3” (April 2008,
InstantDoc ID 98177), the command
get-process | where \{($_.handles -gt 100) ` -and -not ($_.company -eq ` “Microsoft Corporation”)\}is supposed to return all non-Microsoft processes. But three of the listed process names (i.e., CSRSS, SYSTEM, and WINLOGON) look a little out of place. When I use PowerShell to query them for their Company property value, all three return nothing. Microsoft obtained the CSRSS process from Citrix a few years ago, so the recoding is most likely an oversight. But I’m still wondering about the SYSTEM and WINLOGON processes.
—Mike Piontkowski
You bring up an important concern. You’re getting these results because the Company property value is null for those processes. (PowerShell is indifferent to ownership history and cares only about the property value itself!) You can write your code to take this fact into account, as in:
get-process | where \{($_.handles -gt 100) ` -and -not ($_.company -eq ` “Microsoft Corporation” -or ` $_.company -eq $null)\}Now, only processes whose Company value isn’t Microsoft Corporation (or isn’t null) are returned.
The problem with this approach is that it assumes that only Microsoft uses null for the company name, so you must determine how you want to handle such situations. Whenever you’re using properties to create these Boolean expressions, be aware of the possible values for those properties. Write your expressions accordingly, and take into account the possibility of null values.
—Robert Sheldon
DNS Wisdom
I read the IT Pro Hero story, “Tried-and-True
DNS Wisdom” by Caroline Marwitz (April
2008, InstantDoc ID 98330). In the sidebar,
“A Sysadmin’s DNS Best Practices,” Apostolos
Fotakelis writes, “Get rid of NetBIOS over TCP
and WINS.” Every time I’ve ever attempted
to do that, I’ve lost mapped drives and have
been unable to connect to any servers. What
am I doing wrong? Also, if I disable NetBIOS
over TCP from the Local Area Connection
window, will it affect my WatchGuard VPN?
—Tony Sergi
Actually, in my article, I was referring to disabling NetBIOS over TCP via the Local Area Connection window. Disabling NetBIOS from Device Manager is a more drastic, problematic procedure that requires a reboot. Unfortunately, I have no experience with the WatchGuard VPN. However, disabling NetBIOS over TCP shouldn’t have any side effects on firewalls or VPN connections. That being said, you should always be aware of potential consequences. (See the article “How can I configure TCP/IP networking while NetBIOS is disabled in Windows 2000/XP/2003?” at www.petri.co.il/disable_netbios_in_w2k_xp_2003.htm for more information.) And, of course, be sure to test the change before effecting it in your environment.
—Apostolos Fotakelis
PC vs. Mac
I loved Mark Minasi’s Web-exclusive “No XP?
Say It Ain’t So, Ray!” (www.windowsitpro.com,
InstantDoc ID 99284). I, too, am a big fan of
XP, and I haven’t found Microsoft Vista all
that interesting. I did make the choice Mark
talks about. When it was time to replace my
Dell laptop (which was happily running XP), I
went for a shiny MacBook Pro running Tiger
(now Leopard). I have to say, I like my new
computer so much that I plan to replace my
five-year-old HP desktop system (happily running XP) with a new iMac running—
yep—Leopard! And courtesy of VMware
Fusion, I’ll pull the HP system’s XP installation
so that I can still run XP in its own little virtual
machine (VM) on the iMac. XP is a beautiful
thing, and forcing people to upgrade will
only help Microsoft’s competitors!
—Dan York
Server Core Commando
I just read Mark Minasi’s Windows Power
Tools column, “Go Commando with Windows
Server 2008’s Server Core” (June 2008,
InstantDoc ID 98715). At the end of the article,
Mark states that the only option for adding
the DNS suffix from the command line is
to modify the registry. However, you can also
use the Windows Management Instrumentation
Command Line (WMIC). First, find the
adapter you want:
wmic nicconfig listNext, add the DNS suffix. If the adapter’s index is 1, you’d type something like
wmic nicconfig 1 call setdnsdomain bigfirm.comYou can even perform this procedure remotely, as follows:
wmic /node:Server1 nicconfig 1 call setdnsdomain bigfirm.comWhen Server Core gets PowerShell support, you’ll be able to use
Get-WmiObject Win32_NetworkAdapter Configuration -ComputerName Server1 |Where-Object\{$_.IPEnabled -eq “TRUE”\}The object returned by this statement (System.Management.ManagementObject) supports the SetDNSDomain method.
—Aleksandar Nikolic