Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
Manuel Meyer | Trivadis AG
www.manuelmeyer.net
@manumeyer1
21.09.2016
Powershell für .NET Entwickler
Ü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
Agenda
1. Powershell Grundlagen
2. Advanced Powershell
(Remoting, WMI, COM, .NET,…)
3. Powershell Use Cases
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.
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
The Basics
• Verb-Noun Commandlets
Get-Process
Get-NetFirewallProfile
Set-Acl
Set-AuthenticodeSignature
Add-PhysicalDisk
Show-EventLog
More Basics
• Comparison: -eq, -ne, -lt, -gt, -le, -ge, -contains,
-notcontains
• Arrays, HashTables
• If-else, switch
• For, foreach, while,
do-while
• Functions
Agenda
1. Powershell Grundlagen
2. Advanced Powershell
(Remoting, WMI, COM, .NET,…)
3. Powershell Use Cases
PS Remoting
• Enter-PSSession -Computername LTMME02
• Invoke-Command –Computername LTMME01,
LTMME02, LTMME03 –Scriptblock { <cmd>}
WMI
Windows Management Instrumentation
“…a set of extensions to the
Windows Driver Model that
provides an operating system
interface…”
Providers
• Get-PSProviders
– Environment
– FileSystem
– Registry
– Certificate
– IIS
– SqlServer
– …
PS Workflows
• Based on .NET Workflow Foundation
• Long-running, persistable
• Interrupt, suspend, resume
• Sequence, Parallel, Foreach, etc…
Agenda
1. Powershell Grundlagen
2. Advanced Powershell
(Remoting, WMI, COM, .NET,…)
3. Powershell Use Cases
Git
• PoSh-Git
– https://github.com/dahlbyk/posh-git
– http://haacked.com/archive/2011/12/13/better-git-with-
powershell.aspx/
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 $_}
IIS
• Add, change, remove
– Application pools
– Web Sites
– Virtual Directories
– Web Applications
– Website Bindings
• Backup & Restore
– Web Configuration
Import-Module WebAdministration
Sql Server(oder SSMS)
• Execute T-SQL
• Backup & Restore DBs
• Generate Scripts for DB, Tables, Procedures.
Import-Module SQLPS
TFS
• Get info
– Work Items
– Source Control
• Manage
– Workspaces
– Changesets, Shelvesets, Pending Changes
– Build Definitions
– …
Microsoft Azure
• Manage
– Storage
– VMs
– WebSites
– Active Directory
– …
• Create multi-tier IaaS environments
• KUDU.
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
Manuel Meyer | Trivadis AGwww.manuelmeyer.net
@manumeyer1
Powershell für .NET Entwickler