Windows PowerShell Deep Dive 1 Morgan Simonsen Ementor.

Slides:



Advertisements
Similar presentations
$$ Idea Updatable help system Method overload discovery HelpUri attribute support HelpFile property on FunctionInfo Simplified Where and.
Advertisements

Microsoft PowerShell Tom Roeder CS fa. Motivation.NET as a platform shell web server database access Native access to resources eaiser to manage.
MGT305 Windows PowerShell Next Generation Command Line Scripting Jeffrey Snover & Leonard Chung Windows Enterprise Management Division.
Jason Himmelstein, MVP Senior Technical Director,
James Boother Blog: INTRODUCTION TO POWERSHELL.
Basic.  Powershell scripts are flat text files that end with “.ps1” (e.g. myscript.ps1)  Similar to other scripting languages, whatever you can do on.
Neil Iversen Inetium
10.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure.
SharePoint 2010 Administration using PowerShell Brian Caauwe Senior Consultant – SharePoint – MCTS March 20, 2010.
PowerShell for SharePoint or Administrators Can Use the Object Model, Too 30 th October 2008 Sergey Zelenov Premier Field Engineer Microsoft Corporation.
INTRODUCTION TO POWERSHELL Neil Iversen. Points of Interest  Introduction  Getting Around  Basic Syntax  Making yourself at ~  Not-So-Basic Syntax.
Managing Active Directory with PowerShell JOSEPH MOODY.
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.
Basic.  PS is a command line interpreter/scripting environment  Designed for.Net  Similar to C#  Easy to instantiate.Net classes  Standardized syntax.
Around the data centre in 80 scripts Richard Siddaway MVP Microsoft Practice Leader Centiq Ltd.
POWERSHELL Dr. Sarah Gothard CEG 233 Spring 2010.
Daniel Petri MVP, Microsoft Infrastructure Manager John Bryce Training November 2007.
PowerShell: Drink the Kool-Aid!. Who we are…..Who we are…..
#BSidesCMH PowerShell Copyright (C) 2014 ColumbusBSides. PowerShell: Drink the Kool-Aid.
PowerShell Lessons Learned from Building an Automated SQL Installation and Patch Management Implementation Presented by: Fany Carolina Vargas, Microsoft.
Adding a Module The Import-Module cmdlet  Can be used to load any external module into PowerShell.  Uses the following syntax to add the ActiveDirectory.
Kirk Jackson Senior Developer, Xero Wellington.NET Users Group SVR308.
Module 2 Creating Active Directory ® Domain Services User and Computer Objects.
1 Monad – A New Command Shell Jeffrey Snover, Architect James Truher, Program Manager TLN303 Microsoft Corporation.
Managing Citrix Farms Using MFCOM and Powershell.
Presenters: Winfred Wangeci Jignash Reddy.  It is Microsoft's new task-based command- line shell and scripting language designed especially for system.
MS WINDOWS POWER SHELL CSE 535 Operating Systems.
Microsoft ® Official Course Module XA Using Windows PowerShell ®
PowerShell Basics. o PowerShell is a great way to manipulate server and/or workstation components o It’s geared toward system administrators by creating.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
Managing Systems with PowerShell Jeffrey P. Snover Partner Architect.
Ing. Ondřej Ševeček MCSM:Directory | MVP:Enterprise Security | Certified Ethical Hacker | MCSE:SharePoint | PowerShell.
Appendix A Starting Out with Windows PowerShell™ 2.0.
Virtual techdays INDIA │ august 2010 INVENTORY YOUR NETWORK AND CLIENTS WITH POWERSHELL Govindaraj Rangan │ Technology Strategist, Microsoft Corporation.
Section 1: Introducing Group Policy What Is Group Policy? Group Policy Scenarios New Group Policy Features Introduced with Windows Server 2008 and Windows.
Monad The New Microsoft Command Shell Peter Provost
Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based.
December, 21, 2010 Bartek Bielawski Sr IT Site Services Specialist Warsaw, Poland.
Good Morning and Thank You!.  Have some Fun!  Learn at least one thing new!  Make myself available to you So please …  Ask questions and enjoy!
Module 1: Configuring Windows Server Module Overview Describe Windows Server 2008 roles Describe Windows Server 2008 features Describe Windows Server.
Managing Windows Servers with PowerShell V2 James O’Neill: Evangelist, Microsoft UK Richard Siddaway MVP.
Module 2 Creating Active Directory ® Domain Services User and Computer Objects.
Troubleshooting Security Issues Lesson 6. Skills Matrix Technology SkillObjective Domain SkillDomain # Monitoring and Troubleshooting with Event Viewer.
PowerShell For SharePoint Developers Neil Iversen Inetium
Ed Wilson, MCSE, MCSD Microsoft Scripting Guy Microsoft Session Code: WCL314.
What’s New in SharePoint 2010 SharePoint 2010 Development Primer New Developer Tools for SharePoint 2010 SharePoint 2010 Integration with PowerShell.
Virtual techdays INDIA │ 9-11 February 2011 Monitoring and managing remote Windows 7 desktops with Windows PowerShell Ravikanth C │ Dell Inc.
Administering Group Policy Chapter Eleven. Exam Objectives in this Chapter  Plan a Group Policy strategy using Resultant Set of Policy Planning mode.
Windows PowerShell Introduction 1 Morgan Simonsen Ementor.
PowerShell for IT Administrators Richard Siddaway Perot Systems.
Company Confidential 1 A Course on Planning A Group Policy Management And Implementation Strategy Prepared for: *Stars* New Horizons Certified Professional.
 An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is.
11 PLANNING A GROUP POLICY MANAGEMENT AND IMPLEMENTATION STRATEGY Chapter 10.
POWERSHELL BASICS. BACKGROUND  Powershell is a task automation and scripting language based off the.NET framework  It provides the user full access.
 It is Microsoft's new task-based command- line shell and scripting language designed especially for system administration.  It helps Information Technology.
Windows PowerShell. What is Windows PowerShell? A command-line interface (CLI) A new way of developing Windows and other products to be more manageable.
PowerShell for Developers GOPAS: | | Ing. Ondřej Ševeček | GOPAS a.s. | MCM: Directory Services |
PowerShell Richard Siddaway Perot Systems. Welcome to this TechNet Event “Pick your Own Collateral” URL for on-line feedback is in your reminder .
Module 14: Advanced Topics and Troubleshooting. Microsoft ® Windows ® Small Business Server (SBS) 2008 Management Console (Advanced Mode) Managing Windows.
 Version 1.0[edit]edit  Version 1.0 was released in 2006 for Windows XP SP2/SP3, Windows Server 2003,
Ravikanth C.
PowerShell 5 & Windows 10. What are we covering today? What is PowerShell? Why is PowerShell important? Some simple demos on Windows 10.
Office PowerShell administration
PowerShell Introduction Copyright © 2016 – Curt Hill.
Getting Started with the Data ONTAP PowerShell Toolkit
PowerShell Best Practices for SQL DBA’s
08 | Getting prepared for automation
Microsoft 365 Business Technical Fundamentals Series
Presentation transcript:

Windows PowerShell Deep Dive 1 Morgan Simonsen Ementor

What Will We Cover? PS Security PS Drives, Providers and SnapIns PS Profiles Advanced management Exchange 2007 Management 2

Level 300 Helpful Experience Experience with PowerShell Command line experience; cmd.exe, BASH etc. Command line experience; parameters, output etc. Scripting experience (PERL, VBScript, JScript) etc.) 3

Introducing Windows PowerShell New Windows command-line shell designed for system administrators Inteactive prompt and scripting environment Built on.NET Common Language Runtime (CLR) and.NET Framework 4

PowerShell Security Execution Policies: –Restricted (default) –AllSigned –RemoteSigned –Unrestricted (bad idea) Exectuion Policy can be managed through Group Policy (PowerShellExecutionPolicy.adm) No default open for.ps1 files. 5

PS Profiles 4 profiles in PS (listed in load order): –%windir%\system32\WindowsPowerShell\V1.0\profile.ps1 –%windir%\system32\WindowsPowerShell\V1.0\Microsoft.PowerShell_profile.ps1 –%UserProfile%\My Documents\WindowsPowerShell\profiel.ps1 –%UserProfile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profiel.ps1 The most specific profile has precedent $profile Test-path $profile Execution policy must allow configuration files 6

PowerShell Console Files XML files for customizing the console.psc1 extension Cmdlet: Export-Console -psconsolefile ConsoleFileName variable

Working with processes Get-Process Stop-Process 8

Working with services Get-Service New-Service Restart-Service Resume-Service Set-Service Start-Service Stop-Service Suspend-Service 9

Working with the filesystem PS can navigate all Windows drives with a reconizable filesystem Aliases for common directory naviagtion commands (cd, dir) Get-ChildItem 10

PowerShell scripts.ps1 extension Does not run when double-clicked Requires full path (.\ ) Controlled by Execution Policy 11

Advanced Pipelining Manipulating objects in the pipeline: –Where-Object –ForEach-Object –Select-Object –Sort-Object 12

PS Variables Varable names always start with $ Set-Location variable: Clear-Variable Get-Variable New-Variable Remove-Variable Set-Variable 13

Working with functions PS supports creating functions Names can be assignes to script blocks 14

Redirecting data Out-Printer Out-Null Out-Host Out-File 15

Operators ilike / inotlike eq / ne gt / lt 16

Are you sure? WhatIf Confirm Suspend get-mailbox | where-object {$_.servername -eq “smbex01"} | mov box – targetdatabase"smbex02\Mailbox Store" -whatif 17

Working with Event Logs Get-Eventlog Get-EventLog –list Get-EventLog system -newest 3 18

Scripting with COM Access existing instrumentation Bind to COM objects $fso = New-Object -ComObject Scripting.FileSystemObject $m = [System.Runtime.InteropServices.Marshal] $word = $m::GetActiveObject("Word.Application") Invoke methods/access properties $fso.GetDrive(“C:”) $fso.VolumeName = “System Drive” Understand/extend instrumentation Extend and discover properties/methods Update-TypeData Office.Word.Types.ps1xml $fso | Get-Member Manipulate and format results Define and import custom formating Update-FormatData Office.Word.Format.ps1xml $word.RecentFiles | Sort name | Format-Table Allows more simpler/more powerful COM scripts because of utilities and formatting 19

Scripting with WMI PowerShell provides native WMI support Get-WmiObject Allows for inspection of WMI namespace Get-WmiObject –list [-Namespace xx] Get-WmiObject –Class xx –Namespace xx – Property xxx – Filter xxx –ComputerName xxx – Credential xxx Native language support [WMI] “\\JPSDESK10\root\cimv2:Win32_Process.Handle="0“ \\JPSDESK10\root\cimv2:Win32_Process.Handle="0 [WMICLASS] "ROOT\cimv2:WIN32_PROCESS" [WMISEARCHER]"select * from Win32_process WHERE Name = 'calc.exe'" 20

Scripting with ADSI PowerShell provides native access to ADSI Binding to ADSI object $objDomain = [ADSI]"LDAP://localhost:389/dc=NA,dc=fabrikam,dc=com” Creating ADSI object Creating ADSI object $objOU = $objDomain.Create("organizationalUnit", "ou=HR") $objOU.SetInfo() Modifying ADSI object $objOU.Put("description", "Human Resources") $objOU.SetInfo() Reading ADSI object $objOU.Get("description") Deleting ADSI object $objDomain.Delete(“organizationalUnit”, “ou=HR”) 21

Scripting Group Policy $gpm = New-Object -ComObject GPMgmt.GPM

Scripting with.NET PowerShell provides native access to any.NET class Create any object [reflection.assembly]::LoadWithPartialName("System.Windows. Forms") $d = New-Object System.DateTime 2006,12,25 Access Properties/Invoke Methods $d.DayOfWeek$d.AddDays(-30) Access Statics [DateTime]::Now[DateTime]::IsLeapYear(2006) Allows admins to easily access and leverage a huge API set because of scriptability, utilities and formatting 23

Scripting with XML PowerShell provides native XML support Native datatype $x=[xml]"<a><b><c>TEST</c></b></a>“ $b =[xml](type c:\i386\mssecure.xml) Native syntax to access “data” view of properties $b.BulletinDataStore.Bulletins.Bulletin[0] Access to XML methods $b.BulletinDataStore.SelectNodes(“//Patch”) XML properties available through PSBase property $b.BulletinDataStore.PSBase.innerXml 24

Scripting with Text Invoke existing tools Existing command run directly after variables are expanded Harvest data from existing tools Parse output into variables using text utilities. Pipe data to SELECT and use –FIRST and –LAST Select-String Select-String Dir | Select-String Dir | Select-String [DateTime]”12/25/2006 7:00” ([DateTime]”12/25/2006 7:00”).AddDays(-30) Use functions/scripts to wrap the commands and convert output to objects or provide standard syntax Safely process text Use CLR types via Windows PowerShell to safely parse text [URI]” Allows admins to get 2-10x more power out of existing commands because of scriptability 25

EXCHANGE 2007 MANAGEMENT 26

Reduced Complexity 27

PowerShell Add-ons PoshConsole PowerShell Plus: PowerGadgets:

For More Information Windows PowerShell Team blog at: Windows PowerShell ScriptCenter at: nter/hubs/msh.mspx nter/hubs/msh.mspx 29

Books about PS 30