• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer

danblee.com

Tutorials & Knowledge Base Articles for System Administrators who wear many, many hats.

  • Home
  • About
  • Ask Me
  • DBLHost.com

Beginner’s Commands for PowerShell

January 27, 2015 by Dan B. Lee Leave a Comment

There are a few commands in PowerShell that will help you right off the bat.

Checking the status of a setting or property

Most of the time when I’m using PowerShell it’s because I need to first look something up, then make a change. We don’t normally just start making changes all willy-nilly, so knowing how to see the properties and changes is the first step in determining how you plan to make a change.

Format-List

Let’s say, for instance, you want to know the ID of a service. Your first command will be:

1
2
3
 
get-service
 

But that will list all of the properties of all of the services:

If you want to see just one of the properties, such as the display name, then you’d send the get-service through the “pipeline” with a Format-List. You can start with formatting the list using the property, only showing the property you want. In this case it will be “displayname”

1
2
3
 
get service | format-list -property displayname
 

This will show only the property “displayname” as shown below:

You can do multiple properties:

1
2
3
 
get-service | format-list -property status, displayname
 

Will show you the displayname and that status:

The more properties you have available, the more options you can see and things you can change based on the commandlets.

But what if I don’t know the properties? get-member to the rescue:

get-member will show you everything property an item has you can format the list with. Here’s how it’s used:

1
2
3
 
get-service | get-member
 

This shows you all of the available properties:

That doesn’t mean that all of these properties have values in them. For example if you did this:

1
2
3
 
get-service | format-list -property site
 

It may return blank.

And don’t forget, you can write these commands faster when you learn the shortened syntax of some of the commands.

For example this:

1
2
3
 
get-service | fl -p displayname
 

Will give you the same as it’s lengthier command:

1
2
3
 
get-service | format-list -property displayname
 

I hope this helps a little bit. There’s a lot more to finding what you need before acting on it, but it’s a better idea to first find a way to look something up for actually changing something.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: PowerShell Tagged With: CMD, command line, Command Prompt, PowerShell, syntax

Primary Sidebar

Categories

  • Active Directory
    • Group Policy
  • Adobe Photoshop
  • Browsers
    • Chrome
  • Cloud Based Technology
    • Citrix XenApp
  • ConnectWise
    • LabTech
  • Dell
  • Internet Service Providers (ISPs)
  • iPhone
  • Linux
    • CentOS
    • OpenVPN
    • SaltStack
    • Ubuntu
  • Microsoft Office
    • Lync
    • Microsoft Excel
    • Microsoft Outlook
    • Microsoft Word
  • Microsoft Windows
    • Active Directory
    • PowerShell
    • Windows 7
    • Windows 8 Preview & Release
  • Networks
  • News
  • Off Topic
  • Office 365
  • Peripherals
    • Monitors
  • Printers
    • Local Printers
    • Network Printers
  • Programming
    • Python
  • Riverbed
  • Security
  • Sharepoint
  • Social Media
  • Splunk
  • Storage
  • Switching & Routing
    • Cisco
    • Fortinet
  • Technology Culture
    • Opinion
  • Uncategorized
  • Virtualization
    • VEEAM
    • VMware
  • WAMP
  • Web Hosting
    • WHMCS
  • Website Design
  • Windows Server
    • Exchange 2003
    • Exchange 2010
    • Exchange 2013
    • Microsoft SQL
    • Windows Server 2003
    • Windows Server 2008 R2
    • Windows Server 2012
  • WordPress

Footer

Recent Activity

  • VSS Volume Shadow Copy Service - Intro - on Diskshadow, VSSAdmin’s best friend
  • Confluence: Wiki on Diskshadow, VSSAdmin’s best friend
  • Migrating VEEAM Backup Data — danblee.com on Using ROBOCOPY switches for faster, more reliable data moves
  • How to Handle Email Spam From Yourself - TrendsEvo on Anti Spoofing for Domains in Exchange 2016
  • How To Handle Email Spam From Yourself | Lifehacker Australia on Anti Spoofing for Domains in Exchange 2016

Dan Lee

Dan B. Lee works at SyApps, LLC., a Managed Hosting Solutions Firm, as a Senior Network Engineer. Dan has a decade of IT experience and specializes in a number of different disciplines including Virtualization, Web Site Hosting and Design, Network Security, Data Center Architecture, Local and Remote Server Hosting, and Backup & DRS Solutions. Read More…

Links

  • Home
  • About Dan B. Lee
  • Ask Me
  • Privacy Policy

Copyright © 2019 · Genesis Sample Theme on Genesis Framework · WordPress · Log in