28
BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH Powershell@MSUGS 20.5.15 MSUGS Manuel Meyer, Trivadis AG

Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

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

HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH

[email protected] MSUGSManuel Meyer, Trivadis AG

Page 2: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

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

HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH

[email protected] MSUGSManuel Meyer, Trivadis AG

Page 3: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Agenda

Powershell@MSUGS3

1. Basic PSKey FeaturesMy First Script

2. Advanced PSWMI / COM / .NET

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

4. Real Life PowershellTurtle, PSI, System Checker.

Page 4: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Powershell@MSUGS4

Powershell Basics

Page 5: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Key Features

Powershell@MSUGS5

Automation

PS Remoting

PS Workflow

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

Integration in Products

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

Page 6: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

The Shell

Powershell@MSUGS6

Powershell.exe

ISE

Page 7: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Basics

Powershell@MSUGS7

Verb-Noun Commandlets

Get-ProcessGet-NetFirewallProfile

Set-AclSet-AuthenticodeSignature

Add-PhysicalDiskRemove-BitLockerKeyProtector

Show-EventLog

Page 8: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Basics

Powershell@MSUGS8

Help

Objects

Pipelining

Output

Page 9: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

More Basics

Powershell@MSUGS9

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

Arrays, HashTables

If-else, switch

For, foreach, while, do-while

Functions

Page 10: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Bezeichnung Präsentation10

Advanced Powershell

Page 11: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Basics: Providers

Powershell@MSUGS11

Get-PSProviders

–Environment

–FileSystem

–Function

–Registry

–Certificate

Page 12: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Windows Management Instrumentation

(WMI)

Powershell@MSUGS12

“…a set of extensions to the Windows Driver Model that

provides an operating systeminterface…”

Page 13: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

COM Interop

Powershell@MSUGS13

Speech

Outlook.com Login

Excel Interop

Page 14: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

.NET

Powershell@MSUGS14

Acess any class from .NET

Load Assembly and Show UI

WPF Samples

Web Services

Page 15: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

PS Workflows

Powershell@MSUGS15

Based on .NET Workflow Foundation

Long-running, persistable

Interrupt, suspend, resume

Sequence, Parallel, Foreach, etc…

Page 16: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Powershell@MSUGS16

PS Integration

Page 17: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Working with Windows

17

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 18: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Working with Windows

18

Install-WindowsFeature-ConfigurationFilePathd:\WebServerConfigFile.xml

Page 19: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Working with IIS

Powershell@MSUGS19

Import-Module WebAdministration

Add, change, remove

–Application pools

–Web Sites

–Virtual Directories

–Web Applications

–Website Bindings

Backup & Restore

–Web Configuration

Page 20: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Working with SQL Server

Powershell@MSUGS20

Import-Module SQLPS or launch fromSSMS

Execute T-SQL

Backup & Restore DBs

Generate Scripts for DB, Tables, Procedures

Page 21: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Working with TFS

Powershell@MSUGS21

Get info

–Work Items

–Source Control

Manage

–Workspaces

–Changesets, Shelvesets, Pending Changes

–Build Definitions

–…

Page 22: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Working with Microsoft Azure

Powershell@MSUGS22

Manage

–Storeage

–VMs

–WebSites

–Resources

–Active Directory

–…

Create multi-tier IaaS environments

Page 23: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Powershell@MSUGS23

Page 24: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Working with Sharepoint

Powershell@MSUGS24

Install Sharepoint

Manage

–Site Collections

–Lists

–…

Import/Export

Page 25: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Bezeichnung Präsentation25

Real Life Powershell

Page 26: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Real Life Powershell

Powershell@MSUGS26

.NET Development

–CleanAllProjects.ps1

–PublishAll.ps1

–QueueDeploymentBuilds.ps1

–InstallAppServer.ps1

–InstallWebServer.ps1

Page 27: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Real Life Powershell

Powershell@MSUGS27

Turtle

PSI

System Checker

Page 28: Powershell@MSUGS - Full Power AzureAzure, Sharepoint. The Shell 6 Powershell@MSUGS Powershell.exe ISE. Basics 7 Powershell@MSUGS Verb-NounCommandlets Get-Process Get-NetFirewallProfile

Q & AManuel Meyer

[email protected]

Powershell@MSUGS28