top 10 powershell features in 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
Thomas Lee – [email protected] MVP
10 Cool PowerShell V3 Features in Windows 8 and Server 2012
Agenda
• PowerShell v3 in Windows 8/Server 2012• My Top 10• Summary
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
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!
10 – PowerShell Web Access
≥ Enabled you to access PowerShell via IIS≥ A bit like Terminal Services Gateway
How it works
What it Looks Like
What it Looks Like
What it Looks Like
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
PowerShell Module Autoload Demo
(n09.ps1-S1)
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
Robust Remoting Demo(n08.ps1 – s1)
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
Updatable Help Demo(n07.ps1 – host)
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”
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
Simplified Syntax Demo(n06.ps1 – HOST)
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
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
ISE Script Explorer
≥ Free add-on tool≥ Created by Microsoft≥ Allows you to explore for scripts≥ A great starting point
Getting Script Explorer
Improved ISE
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
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.
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
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
LOTS of New stuffDemo
(N02.Ps1 – S1)
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
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
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
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
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
Call To Action - 2
≥ Evaluate the following expression• “Learn PowerShell Version 3” -OR• “Learn to smile and say: ‘Want fries
with that?’”