Top 10 PowerShell Features in Server 2012

34
Thomas Lee – [email protected] PowerShell MVP 10 Cool PowerShell V3 Features in Windows 8 and Server 2012

description

This is from a webcast I did in September 2012 for Idera. It looks at 10 of the cooler PowerShell V3 features of Server 2012. It is a quick look at some of the cooler features and how you can leverage PowerShell v3.

Transcript of Top 10 PowerShell Features in Server 2012

Page 1: Top 10 PowerShell Features in Server 2012

Thomas Lee – [email protected] MVP

10 Cool PowerShell V3 Features in Windows 8 and Server 2012

Page 2: Top 10 PowerShell Features in Server 2012

Agenda

• PowerShell v3 in Windows 8/Server 2012• My Top 10• Summary

Page 3: Top 10 PowerShell Features in Server 2012

The Journey to PowerShell 3

• PowerShell v3 has been a long journey• Monad Manifesto in 2002• V1 with Windows Vista/Server 2008/Exchange 2007 • V2 with Windows 8 and Server 2008 R2• V3 ships with Windows 8 and Server 2012

• Key themes• Improving the usability• Increasing the surface area• Providing plumbing for more, more, more

Page 4: Top 10 PowerShell Features in Server 2012

My Top-10 List

• PowerShell v3 is vast• There are hundreds of new features

• This list is arbitrarily• But things I like

• The order is arbitrary• But all 10 are cool!

Page 5: Top 10 PowerShell Features in Server 2012

10 – PowerShell Web Access

≥ Enabled you to access PowerShell via IIS≥ A bit like Terminal Services Gateway

Page 6: Top 10 PowerShell Features in Server 2012

How it works

Page 7: Top 10 PowerShell Features in Server 2012

What it Looks Like

Page 8: Top 10 PowerShell Features in Server 2012

What it Looks Like

Page 9: Top 10 PowerShell Features in Server 2012

What it Looks Like

Page 10: Top 10 PowerShell Features in Server 2012

9 - Module Auto-load

• Modules added to PowerShell in v2• No modules in v1

• In v2, modules had to be loaded manually

• In v3, if modules are in standard module locations (i.e. defined in $env:PSmodulePath), Powershell can find the module the cmdlet is defined in and then load it auto-magically

Page 11: Top 10 PowerShell Features in Server 2012

PowerShell Module Autoload Demo

(n09.ps1-S1)

Page 12: Top 10 PowerShell Features in Server 2012

8 - Robust Remoting• Remoting added in v2

• But was not robust• Remoting broke at the first sign of trouble• Once broken, often stayed broken• Could be hard to fix

• Under the covers – v3 has benefited from lots of work• Simple errors no longer become fatal

• Remoting a highly key part of Server 2012• Remoting + Workflow are the basis for the new server

manager tool

Page 13: Top 10 PowerShell Features in Server 2012

Robust Remoting Demo(n08.ps1 – s1)

Page 14: Top 10 PowerShell Features in Server 2012

7 - Updatable Help• Help a key feature of PowerShell since V1

• Both on line and in the box• Great writing team• Fix bugs

• All components shipped with Windows Server 2012 can only be updated via normal update mechanism

• Is it important enough to raise a critical fix for?• Is it important enough to raise a recommended hot fix?• Is it important enough to be fixed in a Service Pack

• Solution• No help ‘in the box’ – but…• Update-Help to fix that

Page 15: Top 10 PowerShell Features in Server 2012

Updatable Help Demo(n07.ps1 – host)

Page 16: Top 10 PowerShell Features in Server 2012

6 – Simplified Syntax

≥ PowerShell had a scripting ‘wall’ Get-Process Get-Process| Sort CPU Get-Process| Sort CPU| Select Name, Cpu

≥ But what about where Get-Process| Where {$_.name –match "power"}

$_, {}, OH MY!

≥ In v3 – for SINGLE expressions Get-Process | Where name –match “power”

Page 17: Top 10 PowerShell Features in Server 2012

6 - More Simplified Syntax

≥ Calling an object method in a pipeline meant using Foreach in v2 Get-Process | where {…} | foreach {$+_.kill()}

≥ Now, really simple Get-Process | where {…} | kill # NOTE NO ()!

≥ And how about this: Dir –AD Dir +Hidden

Page 18: Top 10 PowerShell Features in Server 2012

Simplified Syntax Demo(n06.ps1 – HOST)

Page 19: Top 10 PowerShell Features in Server 2012

Break for Breath

≥ 10 through 6 so far 10 - PowerShell Web Service 9 - Module auto-load 8 - Robust Remoting 7 - Updatable Help 6 - Simplified Syntax for Where/Get-ChildItem

≥ These all make life easier for the IT Pro Simplify what you type Get better help More reliable/robust features Extend PowerShell access via the DMZ

Page 20: Top 10 PowerShell Features in Server 2012

5 – ISE Enhancements≥ In v2 – the ISE was functional

The minimum upgrade from Notepad for unicode users You still wanted 3rd party tools ISE could be extended ($PsIse variable)

≥ In v3 – ISE is now nearly at a feature parity with 3rd party tools

≥ Some key new features 2-pane design (in V2 there were 3 panes) Intellisense Wrapping of regions Script Explorer

Page 21: Top 10 PowerShell Features in Server 2012

ISE Script Explorer

≥ Free add-on tool≥ Created by Microsoft≥ Allows you to explore for scripts≥ A great starting point

Page 22: Top 10 PowerShell Features in Server 2012

Getting Script Explorer

Page 23: Top 10 PowerShell Features in Server 2012

Improved ISE

Page 24: Top 10 PowerShell Features in Server 2012

3 - Workflows≥ Remoting added in v2

But was not robust Remoting broke at the first sign of trouble Once broken, often stayed broken Could be hard to fix

≥ Under the covers – v3 has benefited from lots of work Simple errors no longer become fatal

≥ Remoting a highly key part of Server 2012 Remoting + Workflow are the basis for the new server

manager tool

Page 25: Top 10 PowerShell Features in Server 2012

More about Workflows≥ A workflow is effectively a rich, long-running script that can

survive reboots

≥ PowerShell workflow based on Windows Workflow Foundation In effect, Powershell scripts become workflows

≥ Workflows are used, under the covers, with remote uses of Server Manger

≥ Workflows are complex and require an entire session (a day?) on their own.

Page 26: Top 10 PowerShell Features in Server 2012

Workflows

≥ Workflows similar to PowerShell functions Many restrictions owing to work flow

architecture

≥ Complex to create, especially multi-machine work flows

≥ Demo left as an exercise for the reader

Page 27: Top 10 PowerShell Features in Server 2012

2 – Lots of new Modules/Cmdlets

≥ Lots of new modules added! Win 8 Server 2012

≥ Lots of CIM cmdlets You can create cmdlets from XML and CIM

Page 28: Top 10 PowerShell Features in Server 2012

LOTS of New stuffDemo

(N02.Ps1 – S1)

Page 29: Top 10 PowerShell Features in Server 2012

1 – PowerShell in Server Core

≥ In Server 2008, Server Core did not support PowerShell

≥ In Server 2008 R2, you could add PowerShell and .NET to Server Core Use Sconfig 42 to install

≥ In Server 2012, PowerShell installed by default Serve Core starts by defaul in CMD.EXE You need to do registry hack to start PowerShell

Page 30: Top 10 PowerShell Features in Server 2012

Changing the Shell to PowerShell≥ $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\

SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"

≥ Set-ItemProperty -Confirm  -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable'

≥ Reboot-Computer

Page 31: Top 10 PowerShell Features in Server 2012

Adding / Removing The GUI

≥ In Server 2012, you can add/remove the GUI Turn Server Core into full GUI and back

≥ Just a simple PowerShell command But beware of sources

Page 32: Top 10 PowerShell Features in Server 2012

Summary

≥ Lots and lots of new features This list barley scratches the surface

≥ Windows 8 and Server 2012 not have PowerShell V3 by default You can download v3 for Server 2008/R2 and

Win 7

Page 33: Top 10 PowerShell Features in Server 2012

Call To Action

≥ Upgrade where possible to latest Operating Systems Server 2012/Windows 8 Possibly using Windows 7 as a client

≥ With Downlevel clients – upgrade to PowerShell V3

≥ Get PowerShell training Attend the PowerShell PowerCamp event

See Http://tfl09.blogspot.com for details

Page 34: Top 10 PowerShell Features in Server 2012

Call To Action - 2

≥ Evaluate the following expression• “Learn PowerShell Version 3” -OR• “Learn to smile and say: ‘Want fries

with that?’”