Follow this blog:
RSS
Email Alert

TR Dojo

Video: Five must-know PowerShell commands for Windows administrators

Takeaway: Bill Detwiler shows you how to use the Get-Help, Set-ExecutionPolicy, Get-ExecutionPolicy, Get-Service, and ConvertTo-HTML PowerShell commands.

Over the last few years, Microsoft has tried to make PowerShell the Windows management tool of choice. As a Windows administrator, you need to be familiar with the basics of using PowerShell. And during this week’s TR Dojo episode, I show you how to use the following five basic PowerShell commands:

  1. Get-Help
  2. Set-ExecutionPolicy
  3. Get-ExecutionPolicy
  4. Get-Service
  5. ConvertTo-HTML

May 2, 2011, 8:48 AM PDT | Length:00:00:00

View Transcript

Do you use PowerShell to manage your Windows servers and desktops?

Check out the following links for more PowerShell resources:

For those who prefer text to video, click the View Transcript link below the video player windows or check out Brien Posey’s article, “10 PowerShell commands every Windows admin should know,” on which this video is based.

You can also sign up to receive the latest TR Dojo lessons through one or more of the following methods:

Get IT Tips, news, and reviews delivered directly to your inbox by subscribing to TechRepublic’s free newsletters.

Bill Detwiler

About Bill Detwiler

Bill Detwiler is Head Technology Editor of TechRepublic. Previously, he worked as a Support Tech and IT Manager in the social research and energy industries.

Bill Detwiler

Bill Detwiler
Bill Detwiler is Head Technology Editor for TechRepublic. Previously he worked as a Technical Support Associate and Information Technology Manager in the social research and energy industries. Bill is a Microsoft Certified Professional with experience in Windows administration, data management, desktop support, and system security.

Bill Detwiler

Bill Detwiler
Bill Detwiler has nothing to disclose. He doesn't hold investments in the technology companies he covers.

Transcript

Bill Detwiler: PowerShell is fast becoming the managementtool of choice for Windows Admins. And if you haven’t jumped on the bandwagon,now’s the time.

I'm Bill Detwiler, and during this episode of TR Dojo, I'llgive you five basic PowerShell commands Windows admins should know.

Over the last few years, Microsoft has tried to makePowerShell the management tool of choice. As a Windows administrator, you needto be familiar with the basics of using PowerShell. So to get you started,TechRepublic blogger Brien Posey put together a list of PowerShell commandsevery Windows admin should know. I’m going to share five of those during thisepisode and I’ll link to Brien’s full list in the TR Dojo blog.

The first PowerShell cmdlet every Windows admin should learnis Get-Help.

You can use this command to get help with any other command.For example, if you want to know how the Get-Process command works, you cantype:

Get-Help -Name Get-Process

and Windows will display the full command syntax.

You can also use Get-Help with individual nouns and verbs.For example, to find out all the commands you can use with the Get verb, type:

Get-Help -Name Get-*

Although you can create and execute PowerShell scripts,Microsoft has disabled scripting by default in an effort to prevent maliciouscode from executing in a PowerShell environment. This is where the secondcommand on our list comes into play.

You can use the Set-ExecutionPolicy command to control thelevel of security surrounding PowerShell scripts.

Now there are four levels of security:

    Restricted — Restricted is the default execution policyand locks PowerShell down so that commands can be entered only interactively.PowerShell scripts are not allowed to run.

    All Signed — If the execution policy is set to AllSigned then scripts will be allowed to run, but only if they are signed by atrusted publisher.

    Remote Signed — If the execution policy is set to RemoteSigned, any PowerShell scripts that have been locally created will be allowedto run. Scripts created remotely are allowed to run only if they are signed bya trusted publisher.

    Unrestricted — As the name implies, Unrestricted removesall restrictions from the execution policy.

You can set an execution policy by entering theSet-ExecutionPolicy command followed by the name of the policy. For example, ifyou wanted to allow scripts to run in an unrestricted manner you would type:

Set-ExecutionPolicy Unrestricted

And, if you’re working on an unfamiliar server, you’llprobably need to know what execution policy is in use before you attempt to runa script or change the policy using the set-ExecutionPolicy command.

You can find out by using the third command on our list:Get-ExecutionPolicy

Fourth on our list is the Get-Service command, whichprovides a list of all of the services that are installed on the system.

If you are interested in a specific service you can appendthe -Name switch and the name of the service (wildcards are permitted) When youdo, Windows will show you the service’s state.

PowerShell can provide a wealth of information about thesystem, but sometimes you need to do more than just view the informationonscreen. Sometimes, it’s helpful to create a report that you can print orshare with a fellow admin.

Luckily the fifth command on our list, ConvertTo-HTML canhelp you do just that.

To use this command, simply pipe the output from anothercommand into the ConvertTo-HTML command. You’ll have to use the -Propertyswitch to control, which output properties are included in the HTML file andyou’ll need to provide a filename.

To see how this command might be used, consider the previouscommand I showed you—Get-Service.

When entered Get-Service creates a list of every servicethat’s installed on the system and displays in on the screen.

But wouldn’t it be a handy to have an HTML report that liststhe name of each service along with its status (regardless of whether theservice is running). To do so, you could use the following command:

Get-Service | ConvertTo-HTML -Property Name, Status >C:\services.htm

Well that does it for this episode of TR Dojo, be sure tocheck out the TR Dojo blog for links to Brien’s complete list of PowerShellcommands and more PowerShell resources..

And as always, for more teachings on YOUR path to becomingan IT Ninja, visit trdojo.techrepublic.com, sign-up for our newsletter, orfollow me on Twitter.

Thanks for visiting the TR Dojo.

5
Comments

Join the conversation!

Follow via:
RSS
Email Alert