Powershell: Introduction and Practical Uses. Presentation URL:

Similar documents
A layman s guide to PowerShell 2.0 remoting. Ravikanth Chaganti

PowerShell for Forensics

POWERSHELL. Introduction COMP2101 Winter 2019

Essential PowerShell Survival Skills

TEC US 2011: PowerShell Deep Dive Aleksandar Nikolić Constrained PowerShell Endpoints

PowerShell Master Class

Product Page:

Executing PowerShell Agent Commands

PowerShell provider for BizTalk Server 2013

: 10961C: Automating Administration With Windows PowerShell

Executing PowerShell Agent Commands

Automating Administration with Windows PowerShell

PowerShell. Scripting in Windows Environments Gergő Ládi

Learn Windows PowerShell 3 in a Month of Lunches

Powershell. Working with Objects COMP2101 Winter 2018

This course incorporates materials from the Official Microsoft Learning Product M10961: Automating Administration with Windows PowerShell.

Microsoft Windows PowerShell v2 For Administrators

Corporate Training Centre (306)

Qlik Sense Cmdlet for PowerShell. Sokkorn CHEAV

Building Powerful Workflow Automation with Cherwell and PowerShell

POWERSHELL. Best Practices, Remote Management, Automation and More

Microsoft PowerShell for Security Professionals. Lab Guide Basics

Automating Administration with Windows PowerShell 2.0

Automated SQL Server 2017 Installation and Configuration Using PowerShell

"Charting the Course... MOC C: Automating Administration with Windows PowerShell. Course Summary

John Savill s PowerShell Master Class

The power of PowerShell

Multi-Environment PowerShell console AD, Exchange and PowerCLI in one happy place!

The Agenda. IIS Administration for the Reluctant Webmaster. Jason Helmick Senior Technologist

LCC Default Environtment Menu (lccdemenu) Manual

Automating Administration with Windows PowerShell

Tools for Running Administrative Tasks in IIS Executing Scripts for Administrative Tasks Managing IIS Tasks

Microsoft Automating Administration with Windows PowerShell

Govindaraj Rangan Technology Strategist Microsoft India

Automating Administration with Windows PowerShell (10961)

10961C: Automating Administration with Windows PowerShell

Part II: PowerShell s Basic Structure and Syntax... 47

Windows Server 2012 R2 Windows PowerShell Fundamentals

UNIT 2 LAB 4: CREATING LOOPING STATEMENTS

POWERSHELL TASK AUTOMATION FEATURES

Course 10961: Automating Administration with Windows PowerShell

Building Your First SQL Server Container Lab in Docker

Automating Administration with Windows PowerShell (M10961)

Automating Administration with Windows PowerShell

When Powerful SAS Meets PowerShell TM

Review of Fundamentals

COURSE 10961B: AUTOMATING ADMINISTRATION WITH WINDOWS POWERSHELL

Microsoft Windows PowerShell 3.0 First Look

Finding RDP sessions on servers using PowerShell

SAMPLE CHAPTER THIRD EDITION. Bruce Payette Richard Siddaway MANNING

Using Windows PowerShell scripts

CSC 360 Lab Assignment #6 Spring 2015 Due: March 13, 2015

Boulos Dib September 21, 2011

Resilient & Ready. May 21 23, 2018

Windows PowerShell. The next generation command line scripting

Automating Administration with Microsoft Windows PowerShell

Learning Windows IIS in a Month of Lunches

DRA PowerShell Usage and Examples

[MS10961]: Automating Administration with Windows PowerShell

Implementing Hyper-V. Lab Exercises FINAL

Lab Sample Solutions. Chapter 4 lab. Answers

Course Outline. Automating Administration with Windows PowerShell Course 10961B: 5 days Instructor Led

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

Automating Administration with Windows PowerShell V3

Module 1 Web Application Proxy (WAP) Estimated Time: 120 minutes

Iron Scripter 2018: Prequel 5 A commentary


Manual Script Windows Batch If Condition. Syntax >>>CLICK HERE<<<

LCCPowerShell GUI Administrator's Guide

How to Add a Favicon in Ruby on Rails Apps

How to Configure Impersonation for OneDrive for Business Data Sources

UTILIZING WINDOWS POWERSHELL

PowerShell 10961: Automating Administration with Windows PowerShell. Upcoming Dates. Course Description. Course Outline

Windows PowerShell Scripting and Toolmaking

INF220x Security Practical Exercises

RAP as a Service Active Directory Security: Prerequisites

DENICOMP SYSTEMS Copyright? 2003 Denicomp Systems All rights reserved.

Windows Server DHCP - Part 5 - backup and restore (GUI and command line)

Integrate Viper business antivirus EventTracker Enterprise

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Shavlik Protect. Guidelines for Creating Custom ITScripts

Learn Windows PowerShell in a Month of Lunches

Nexus 1000v Quickstart with Hyper V Server Configuration Example

Learn PowerShell Toolmaking in a Month of Lunches

IBM IBM Tivoli Composite Appl Mgr for WebSphere v6.0 Implement. Download Full Version :

Document Number ECX-Exchange2010-Migration-QSG, Version 1, May 2015 Copyright 2015 NEC Corporation.

OpenNebula - Feature #2395 Provide windows guest contextualization scripts

Iron Scripter 2018: Prequel 6

MB Microsoft. Microsoft Dynamics AX 2012 Installation and Configuration

Course Outline: Course Automating Administration with Windows PowerShell v3.

Using SQLCover with SQL Release PowerShell cmdlets

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

DOWNLOAD OR READ : WINDOWS POWERSHELL SCRIPTING GUIDE PDF EBOOK EPUB MOBI

Corporate Training Centre (306)

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Essentials Wizard Help - Configure Office 365

Topic 2: More Shell Skills

Changeable information Lesson 2 Creating a Parameterized Script Best practices Lab A Creating a Parameterized Script...

Windows PowerShell in Action

E-SESS LockDown Browser Installation November Technological Fluency Institute

Transcription:

Powershell: Introduction and Practical Uses Presentation URL: http://bit.ly/2ick4pt

HELLO! I am Chris Wieringa CS Lab Manager for Calvin College cwieri39@calvin.edu 2

1. Goals What we will cover today...

Goals Define and startup PowerShell (PS) Basics of PS Local system management Remote Powershell Software installations Windows Update The real goal is to learn something together today. 4

2. Define and Startup Powershell What is Powershell, and how to run it...

Windows PowerShell is an interactive object -oriented command environment with scripting language features that utilizes small programs called cmdlets to simplify configuration, administration, and management of heterogeneous environments in both standalone and networked typologies by utilizing standards-based remoting protocols. - Ed Wilson, The Scripting Guy 6

Define Powershell Interactive 7

Define Powershell Scripts 8

Startup Today we ll be working with the Powershell ISE : Start -> Windows Powershell ISE -> Rightclick -> Run as Administrator 9

Security through Execution Policy Execution Policy Default security settings to not run scripts. http://bit.ly/2jrsyjn Get-ExecutionPolicy if restricted, run: Set-ExecutionPolicy unrestricted (if non-admin, Set-ExecutionPolicy -Scope CurrentUser unrestricted) 10

3. Basics Start with the basics...

Basic Cmdlets View processes: Get-Process Directory listing: Get-ChildItem -Path C:\ Aliased to ls Services list: Get-Service 12

Basic Cmdlets - More Information Aliases of popular cmdlets are available: http://bit.ly/2h7ibv5 Most cmdlets have arguments you can pass to them -ArgumentNamevalue Get-Help cmdlet Get-Help cmdlet -examples Everything is treated as an objects, which allows objects to be passed to each other through... 13

Pipeline Piping in Powershell is significant. PS will pass objects between commands virtually everywhere. http://bit.ly/2vjh5jx 14

Basic Cmdlets - Pipeline Services list - Pipelining! Get-Service Format -List (or Get-Service FL) Get-Service Select -Object Name,DisplayName Get-Service Select -Object Name,DisplayName Export-CSV -Path $env:temp\servicelist.csv In File Explorer, check your %TEMP% directory for a servicelist.csv file. 15

Basic Cmdlets - Pipeline example continued... Import-CSV -Path $env:temp\servicelist.csv Foreach-Object { Get-Service -Name $_.Name Where-Object { $_.Status -eq Running } Select-Object Name,Status } $_ is a special variable, representing the current object in the pipeline. Fill in the blank variable. http://bit.ly/2kfuiwu 16

4. System Management and Administration How to do something useful on your system...

System Management and Administration - Event Log Event Viewer / Log Get-EventLog -LogName System-Source *GroupPolicy* Useful filters: -EntryType { Error Information FailureAudit SuccessAudit Warning } -LogName: { Application, Security, Setup, System, } -After or -Before Get-Help Get-Event -examples 18

System Management and Administration - Start / Stop Processes Get-Process - shows current processes Start-Process - starts a new process Start-Process -FilePath notepad -WindowStyle Maximized Add -Wait to wait until the process ends. Stop-Process - stops/ends a process Stop-Process -Name notepad Add -Force to force-kill it 19

System Management and Administration - ACLs Get-Acl -Path C:\Windows FL $mygoodacl = Get -Acl -Path C:\Fish.txt Set-Acl -Path C:\Bird.txt -AclObject $mygoodacl Get-Acl -Path C:\Fish.txt Set-Acl -Path C:\Bird.txt 20

System Management and Administration - Registry Registry modification potential - Danger Will Robinson! Get-ItemProperty -Pat h HKLM:\Software\Microsoft\Windows\CurrentVersion Get-ItemProperty -Pat h HKLM:\Software\Microsoft\Windows\CurrentVersion - Name ProgramFilesDir New-Item -Path HKCU:\Software\Labman New-ItemProperty -Pat h HKCU:\Software\Labman -Name NoAttendees -Value 0 Set-ItemProperty -Pat h HKCU:\Software\Labman -Name NoAttendees -Value 40 Get-ItemProperty -Pat h HKCU:\Software\Labman -Name NoAttendees Remove-It em HKCU:\Software\Labman -Force -Recurse Same commands for files! 21

System Management and Administration - Restart! Restart the computer: Restart-Comput er Restart-Comput er -ComputerName labmachine01 -Wait -For PowerShell -Timeout 300 -Delay 2 Stop / Shutdown the computer: Stop-Comput er 22

5. Remote Powershell Now do it all on remote machines...

PS Remoting - Initial Setup Powershell can be used in both interactive and scripted modes. Cmdlets may also work on remote computers. Requires setup https://tek.io/2wh6zr9 Windows Remote Management - On/Allowed IPs Windows Remote Management Service - Started Firewall settings Fairly in depth I ll leave this up to you. 24

PS Remoting - PSSession Interactive Mode: Enter-PSSession -ComputerName syslab01 [syslab0 1] PS C:\ > Get-ChildItem [syslab01] PS C:\ > Exit 25

PS Remoting - PSSession Remote Scripting $s = New-PSSession -ComputerName syslab01 Invoke-Command -Session $s -ScriptBlock { } Get-Process Export -CSV-Path C:\processlist.txt Copy-Item -FromSession $s -Path C:\processlist.txt -Destination C: \reports\ 26

PS Remoting - PSSession Multiple Hosts Scripting # syslab.txt is a file with a list of computer names, one per -line $s = New-PSSession -ComputerName (Get -Content syslab.txt) Invoke-Command -Session $s -ScriptBlock { } Get-ComputerInfo 27

PS Remoting - Cmdlet ComputerName # syslab.txt is a file with a list of computer names, one per -line Invoke-Command -ComputerName (Get -Content syslab.txt) -FilePath C: \Scripts\myScript.ps1-ArgumentList Process, Service https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke -command?view=powershell -6 28

5. Software Installations Get away from the batch scripts...

Software Installations - Get Rid of Batch Powershell is a natural replacement for your batch install scripts Benefits: Full control over install window Easy to check for existing software installs Native ability to remote copy installer and start install Built-In Provider Packages (aka Chocolatey) 30

Software Installations - Run those installers... Basic installation of a file: http://bit.ly/2idfcvi Start-Process -NoNewWindow -Wait -FilePath C:\installers\7zip_x64.exe -ArgumentWindow /S Got a not-so-silent installer? Control your w indow Start-Process -WindowStyle {Normal Hidden Minimized Maximized}... 31

Software Installations - Check Existing Software Installs How to check for existing software installs: http://bit.ly/2rwfxfj 1. (Bad/slow way) Get-WmiObject -Class Win32_Product 2. (Better) Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* Select-Object DisplayName, DisplayVersion, Publisher, InstallDate Format-Table -AutoSize Detect if the install is needed, only continue if it is old/not -existent... 32

Software Installations - Chocolatey integration Use chocolatey? Easy Powershell integration: http://bit.ly/2j0tsol Find-Package -ProviderName Chocolatey -Name 7zip Install- Package 33

6. Windows Update How to run your Windows Update...

Windows Update PSWindowsUpdate module from PowerShell Gallery https://www.powershellgallery.com Install via the nuget system Install once, then load on-use 35

Windows Update - PSWindowsUpdate install Install-PackageProvider NuGet -Force Import-PackageProvider NuGet -Force Set-PSRepository -Name PSGallery -InstallationPolicy Trusted Install-Module PSWindowsUpdate 36

Windows Update - PSWindowsUpdate Operations Get-Command -module PSWindowsUpdate Get updates: Get-WUInstall -AcceptAll-AutoReboot List updates: Get-WUList Results from last run: Get-WULastResults *The cmdlets may take a bit to run. 37

THANKS! ANY QUESTIONS? cw ieri39@calvin.edu 616-526-678 5 https://cs.calvin.edu Presentation URL: http://bit.ly/2ick4pt 38

CREDITS Special thanks to all the people who made and released these awesome resources for free: Presentation template by SlidesCarnival Photographs by Unsplash 39

40