Top Banner
Manuel Meyer | Trivadis AG www.manuelmeyer.net @manumeyer1 21.09.2016 Powershell für .NET Entwickler
29

Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

May 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Manuel Meyer | Trivadis AG

www.manuelmeyer.net

@manumeyer1

21.09.2016

Powershell für .NET Entwickler

Page 2: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Über mich

• Consultant & Trainer für .NET

bei der Trivadis AG

• MVP für Visual Studio

• C# / XAML, Integration, Azure,

Troubleshooting & Performance

Management

Manuel Meyerhttp://manuelmeyer.net

@manumeyer1

Page 3: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Agenda

1. Powershell Grundlagen

2. Advanced Powershell

(Remoting, WMI, COM, .NET,…)

3. Powershell Use Cases

Page 4: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Key Features

• Scripting

• Automation

• PS Remoting

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

• Integration in Products

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

Exchange, Skype, Sharepoint.

• Open Source & Cross-Platform.

Page 5: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

The Shell

• Powershell.exe

• ISE

• ISESteroids (commercial)

– http://www.powertheshell.com/isesteroids/

• PS Tools for Visual Studio

• PowerGUI

– https://software.dell.com/products/powergui-freeware/

• VS Code

Page 6: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

The Basics

• Verb-Noun Commandlets

Get-Process

Get-NetFirewallProfile

Set-Acl

Set-AuthenticodeSignature

Add-PhysicalDisk

Show-EventLog

Page 7: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Demo

Page 8: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

More Basics

• 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 .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Agenda

1. Powershell Grundlagen

2. Advanced Powershell

(Remoting, WMI, COM, .NET,…)

3. Powershell Use Cases

Page 10: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

PS Remoting

• Enter-PSSession -Computername LTMME02

• Invoke-Command –Computername LTMME01,

LTMME02, LTMME03 –Scriptblock { <cmd>}

Page 11: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

COM Interop

• Speech

• Excel Interop

Page 12: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

WMI

Windows Management Instrumentation

“…a set of extensions to the

Windows Driver Model that

provides an operating system

interface…”

Page 13: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Providers

• Get-PSProviders

– Environment

– FileSystem

– Registry

– Certificate

– IIS

– SqlServer

– …

Page 14: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

.NET

• Access any .NET Class

• Web Services

• Load Assembly and Show UI

• WPF Samples.

Page 15: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

PS Workflows

• Based on .NET Workflow Foundation

• Long-running, persistable

• Interrupt, suspend, resume

• Sequence, Parallel, Foreach, etc…

Page 16: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Agenda

1. Powershell Grundlagen

2. Advanced Powershell

(Remoting, WMI, COM, .NET,…)

3. Powershell Use Cases

Page 17: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Powershell Use Cases

• PoSh-Git

• Windows Server

• IIS

• Sql Server

• TFS

• Sharepoint

• Azure

Page 18: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Git

• PoSh-Git

– https://github.com/dahlbyk/posh-git

– http://haacked.com/archive/2011/12/13/better-git-with-

powershell.aspx/

Page 19: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Windows Server

• Roles & FeaturesGet-WindowsFeature/Install-WindowsFeature/Uninstall-WindowsFeature

Install-WindowsFeature Web-Server -IncludeAllSubFeature -IncludeManagementTools

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

Page 20: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Windows ServerInstall-WindowsFeature-ConfigurationFilePathd:\WebServerConfigFile.xml

Page 21: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

IIS

• Add, change, remove

– Application pools

– Web Sites

– Virtual Directories

– Web Applications

– Website Bindings

• Backup & Restore

– Web Configuration

Import-Module WebAdministration

Page 22: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Sql Server(oder SSMS)

• Execute T-SQL

• Backup & Restore DBs

• Generate Scripts for DB, Tables, Procedures.

Import-Module SQLPS

Page 23: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

TFS

• Get info

– Work Items

– Source Control

• Manage

– Workspaces

– Changesets, Shelvesets, Pending Changes

– Build Definitions

– …

Page 24: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Sharepoint

• Install Sharepoint

• Manage

– Site Collections

– Lists

– …

• Import/Export.

Page 25: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Microsoft Azure

• Manage

– Storage

– VMs

– WebSites

– Active Directory

– …

• Create multi-tier IaaS environments

• KUDU.

Page 26: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Microsoft Azure

Page 27: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Die Basics

Page 28: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

More…

• Powershell Invaders

• PSCX Powershell Community Extensions

– http://pscx.codeplex.com/

• PoShServer: A Powershell Web Server

– http://poshserver.net/

• PoShConsole: A WPF PS Console

– https://poshconsole.codeplex.com

Page 29: Powershell für .NET Entwickler - manuelmeyer.net · Über mich •Consultant & Trainer für .NET bei der Trivadis AG •MVP für Visual Studio •C# / XAML, Integration, Azure, Troubleshooting

Manuel Meyer | Trivadis AGwww.manuelmeyer.net

[email protected]

@manumeyer1

Powershell für .NET Entwickler