Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET...

29
BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH Powershell für .NET 07.04.2016 Trivadis Late Lounge Manuel Meyer, Trivadis AG www.manuelmeyer.net @manumeyer1

Transcript of Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET...

Page 1: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF

HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH

Powershell für .NET07.04.2016 Trivadis Late Lounge

Manuel Meyer, Trivadis AG

www.manuelmeyer.net

@manumeyer1

Page 2: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Agenda

1. Powershell Basics

2. Advanced PowershellRemoting / WMI / COM / .NET

3. PS IntegrationWindows / IIS / SQL Server / TFS / Azure / Sharepoint

4. Demo Twitter

Page 3: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Powershell Basics

Page 4: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Key Features

Automation

PS Remoting

PS Workflow

.NET, COM, WMI, Perfcounters, EventLog, etc.

Integration in Products

–Windows, IIS, SQL Server, TFS, Microsoft Azure, Sharepoint.

Page 5: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

The Shell

Powershell.exe

ISE

Page 6: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Basics

Verb-Noun Commandlets

Get-ProcessGet-NetFirewallProfile

Set-AclSet-AuthenticodeSignature

Add-PhysicalDiskRemove-BitLockerKeyProtector

Show-EventLog

Page 7: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Basics

Help

Objects

Pipelining

Output

Page 8: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

More Basics

Powershell@MSUGS

Comparison: -eq, -ne, -lt, -gt, -le, -ge, -contains, -notcontains

Arrays, HashTables

If-else, switch

For, foreach, while, do-while

Functions

Page 9: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Demo Basics

Page 10: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Advanced Powershell

Page 11: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Powershell Remoting

Enter-PSSession

…-Computername LTMME02

Invoke-Command –Computername LTMME01, LTMME02, LTMME03 –Scriptblock { <cmd>}

Page 12: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

COM Interop

Speech

Excel Interop

Page 13: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Windows Management Instrumentation

(WMI)

“…a set of extensions to the

Windows Driver Model that

provides an operating system

interface…”

Page 14: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Basics: Providers

Get-PSProviders

–Environment

–FileSystem

–Function

–Registry

–Certificate

– IIS

–SqlServer

–…

Page 15: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

.NET

Powershell@MSUGS15

Acess any class from .NET

Web Services

Load Assembly and Show UI

WPF Samples

Page 16: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

PS Workflows

Based on .NET Workflow Foundation

Long-running, persistable

Interrupt, suspend, resume

Sequence, Parallel, Foreach, etc…

Page 17: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

PS Integration

Page 18: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Working with Windows

Roles & Features

Get-WindowsFeature/Install-WindowsFeature/Uninstall-WindowsFeature

Install-WindowsFeature Web-Server-IncludeAllSubFeature -IncludeManagementTools

'WebSrv01', 'WebSrv02', 'WebSrv03'| ForEach-Object{Install-WindowsFeature Web-Server-IncludeAllSubFeature -IncludeManagementTools -ComputerName $_}

Page 19: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Working with Windows

Install-WindowsFeature-ConfigurationFilePathd:\WebServerConfigFile.xml

Page 20: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Working with IIS

Import-Module WebAdministration

Add, change, remove

–Application pools

–Web Sites

–Virtual Directories

–Web Applications

–Website Bindings

Backup & Restore

–Web Configuration

Page 21: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Working with SQL Server

Import-Module SQLPS or launch fromSSMS

Execute T-SQL

Backup & Restore DBs

Generate Scripts for DB, Tables, Procedures

Page 22: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Working with TFS

Get info

–Work Items

–Source Control

Manage

–Workspaces

–Changesets, Shelvesets, Pending Changes

–Build Definitions

–…

Page 23: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Working with Sharepoint

Install Sharepoint

Manage

–Site Collections

–Lists

–…

Import/Export

Page 24: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Working with Microsoft Azure

Manage

–Storeage

–VMs

–WebSites

–Resources

–Active Directory

–…

Create multi-tier IaaS environments

Page 25: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint
Page 26: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Demo KUDU

Page 27: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint
Page 28: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Bezeichnung Präsentation28

Demo Twitter

Page 29: Powershell für · Agenda 1. Powershell Basics 2. Advanced Powershell Remoting / WMI / COM / .NET 3. PS Integration Windows / IIS / SQL Server / TFS / Azure / Sharepoint

Q & AManuel Meyer

[email protected]

http://www.manuelmeyer.net