Wednesday 20 November 2013

PowerShell Basics

Back to ConfigMgr main menu

Back to ConfigMgr & PowerShell menu

Windows PowerShell is Microsoft's task automation and configuration management framework, consisting of a command line shell and associated scripting language built on .NET Framework. It is a valuable administration tool as it combines the speed of a command line with the flexibility of a scripting language.

PowerShell commands are referred to as Cmdlets. All cmdlets are made up of two parts: a verb and a noun.  They are separated by a hyphen ‘-‘ character.

Some cmdlets are integrated with Windows, and others are installed with programs like ConfigMgr.

Launch PowerShell by clicking on this icon on the taskbar. (Open PowerShell as Administrator by right clicking - you should do this as most of the cmdlets you will be using will require this)




You can also search by typing PowerShell.




(Note that we need the x86 version - the ConfigMgr Admin Console is a 32-bit application)

Note the PS telling you that you are running PowerShell




Some useful commands

get-command gives you a list of all available PowerShell commands




See the verbs that can be used in cmdlets. Each verb can be used with in conjunction with various nouns to create powerful cmdlets

Add 
Block
Clear
Close
Connect
Copy
Disable 
Disconnect
Dismount
Enable
End
Export
Format
Get
Grant
Initialize
Import
Install
Invoke
Join
Limit
Measure
Merge
Mount
Move
New
Open
Optimize
Publish
Register
Remove
Rename
Repair
Reset
Resize
Resolve
Restore
Restart
Resume
Revoke
Save
Select
Send
Set
Show
Start
Stop
Suspend
Sync
Test
Unblock
Undo
Uninstall
Unregister
Update
Use
Wait
Write

get-command -verb Get

This will list all the Get cmdlets




Example

Get-service




Try this (use a service that you are allowed to stop - requires PowerShell to be run as administrator)

Get-Service -name WsusService
Stop-Service -name WsusService
Get-Service -name WsusService 



Start the service again

Start-Service -name WsusService

Verify that it is started

Get-Service -name WsusService


4 comments:

  1. Have you had a chance to use the Powershell cmdlets with ConfigMgr2012? They're pretty sweet. It took them awhile to finally get some native cmdlets available!

    - Adam
    adamtheautomator.com

    ReplyDelete
  2. I use them often Adam. They're pretty cool.

    ReplyDelete
  3. What I'm having trouble understanding is the difference between cmdlets and custom console extentions.

    ReplyDelete
    Replies
    1. Sorry for the late response. I've been on vacation.

      They really are two different things. Powershell cmdlets allow you to carry out tasks via command line that you would normally do with the ConfigMgr GUI. You can use the pipe command do carry out multiple tasks.

      Custom console extensions (aka right click tools) add additional GUI functionality.

      Delete