76

20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Embed Size (px)

Citation preview

Page 1: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339
Page 2: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

20 Better Ways to Perform Server Administration Using PowerShellOrin Thomas M339

Page 3: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Many Server Administrators haven’t had the time to learn PowerShell

Page 4: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

This session is about taking day to day tasks that Server Administrators have to perform

Page 5: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

And showing how to perform them with a line or so of PowerShell

Page 6: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

In this session we will look at the following:

Page 7: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

-Basic configuration-Core role tools

AD DSFile ServersDHCPDNS

-Snippits

Page 8: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Basic Configuration Tasks

Page 9: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Rename-Computer Ignite-NZDemo

Rename a computer

Page 10: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Restart-Computer

Restart a computer

Page 11: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Stop-Computer

Shut down a computer

Page 12: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Get-NetIPConfiguration

Determine IP Address

Page 13: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

New-NetIPAddress -InterfaceAlias Ethernet -IPAddress 172.16.0.20 -PrefixLength 24 -DefaultGateway 172.16.0.1

Set IP Address

Page 14: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Set-DNSClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 172.16.0.10

Configure DNS Server

Page 15: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Add-Computer -DomainName igniteNZ.internal

Join a domain

Page 16: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Basic Diagnostics

Page 17: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

DEMO: BASIC COMPUTER CONFIGURATION

Page 18: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Get-NetAdapterStatistics

Verify Network Adapter Functionality

Page 19: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Test-NetConnection

Verify Network Adapter Connectivity

Page 20: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Test-NetConnection 8.8.8.8

Verify Network Adapter Connectivity

Page 21: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Test-NetConnection bing.com -traceroute

Verify Network Adapter Connectivity

Page 22: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Test-NetConnection smtp.com –Port 25

Verify Network Adapter Connectivity

Page 23: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Test-ComputerSecurechannel -credential domain\admin -Repair

Repair Trust Relationship

Page 24: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Get-Eventlog -logname System -EntryType Error

Error Event Logs

Page 25: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Stop-ServiceStart-ServiceRestart-ServiceSet-ServiceGet-Service

Manage Services

Page 26: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Get-Service | Where-Object {$_.Status –eq “Stopped”}

View Stopped Services

Page 27: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Install-WindowsFeature -IncludeAllSubfeature -IncludeManagementTools File-Services

Add Roles and Features

Page 28: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Install-WindowsFeature Net-Framework-Core -source d:\sources\sxs

Add Roles .NET Framework

Page 29: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Get-Hotfix

View Installed Updates

Page 30: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Firewall Basics

Page 31: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

New-NetFirewallRule -DisplayName “Allow Inbound Port 80" -Direction Inbound –LocalPort 80 -Protocol TCP -Action Allow

Add Firewall Rules Allow

Page 32: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

New-NetFirewallRule -DisplayName "Block Outbound Port 80" -Direction Outbound –LocalPort 80 -Protocol TCP -Action Block

Add Firewall Rules Block

Page 33: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Virtual Machine Basics

Page 34: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

New-VM -MemoryStartupBytes 2048MB -Name NZ-VM -Path "d:\NZ-VM" -VHDPath  "d:\NZ-VM\disk.vhdx"

Create a new VM from a sysprepped VHD

Page 35: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

GET-VM –name NZ* | GET-VMNetworkAdapter | Connect-VMNetworkAdapter –Switchname ‘Private Network’

Assign VM Network Adapter to Virtual Switch

Page 36: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

PowerShell Direct

Page 37: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Allows you to run PowerShell commands from the Hyper-V Host inside a VM without remoting

Page 38: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Don’t have to sign in to VM or remote to VM

to run commands or scripts on a local VM

Page 39: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

RequiresWindows 10

Windows Server 2016Host & VM

Page 40: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Enter-PSSession –VMName VMNameInvoke-Command –VMName VMName –ScriptBlock

{Commands}

Using PowerShell Direct

Page 41: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Active Directory Management

Page 42: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

$newpwd = ConvertTo-SecureString -String "P@ssw0rd"

-AsPlainText –Force

Ready a secure password

Page 43: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

New-ADUser –Name Don.Funk –AccountPassword $newpwd

New User

Page 44: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Enable-ADAccount –Identity Don.Funk

Enable New User

Page 45: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Set-ADAccountPassword Don.Funk -NewPassword $newpwd -Reset -PassThru | Set-ADuser -ChangePasswordAtLogon $True

Reset Password & Force Change

Page 46: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

New-ADGroup -Name “Aucklanders" -SamAccountName Aucklanders -GroupCategory Security -GroupScope Global -Path "CN=Users,DC=IgniteNZ,DC=Internal"

New Group

Page 47: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Search-ADAccount –PasswordNeverExpires

Search for accounts with non-expiring passwords

Page 48: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Search-AdAccount –accountinactive –timespan 90.00:00:00

Search for accounts that haven’t signed-on for 90 days

Page 49: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Search-AdAccount –Lockedout

Search for locked out accounts

Page 50: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Search-AdAccount –AccountDisabled

Search for disabled accounts

Page 51: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

DEMO: BASIC AD ADMINISTRATION

Page 52: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

ISE Snippets

Page 53: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Allow you to add frequently used PowerShell code to a special menu in PowerShell ISE

Page 54: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Requires execution policy be set to unrestricted

Page 55: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

New-IseSnippet -Force -Title "Password_String" -Description "Secure Password String" -Text "`$newpwd = ConvertTo-SecureString -String

P@ssw0rd -AsPlainText –Force"

Secure Password Snippet

Page 56: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339
Page 57: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

DEMO: SNIPPETS

Page 58: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

DNS Management

Page 59: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Add-DnsServerPrimaryZone -Name "westisland.ignitenz.internal" -ReplicationScope "Forest" -PassThru

New DNS Primary Zone

Page 60: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Add-DnsServerResourceRecordA -Name “wellington" -ZoneName "igniteNZ.internal" -AllowUpdateAny -IPv4Address "172.18.99.23" -TimeToLive 01:00:00

New Record

Page 61: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

DEMO: BASIC DNS

Page 62: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

DHCP Management

Page 63: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Add-DhcpServerv4Scope -Name "Alpha-Scope" -StartRange 172.16.0.0 -EndRange 172.16.0.254 -SubnetMask 255.255.255.0

New Scope

Page 64: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Add-DhcpServerv4Reservation -ComputerName domaincontrol.igniteNZ.internal -ScopeId 172.16.0.0 -IPAddress 172.16.0.200 -ClientId F0-DE-F1-7A-00-5E -Description "Reservation for Printer"

New Reservation

Page 65: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Set-DhcpServerv4OptionValue -ComputerName domaincontrol.igniteNZ.internal -ScopeId 172.16.0.0 -OptionId 006 -Value "172.16.0.10"

New Scope Setting - DNS

Page 66: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Set-DhcpServerv4OptionValue -ComputerName domaincontrol.igniteNZ.internal -ScopeId 172.16.0.0 -OptionId 003 -Value "172.16.0.1"

New Scope Setting - Gateway

Page 67: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

DEMO: BASIC DHCP

Page 68: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

File Server Management

Page 69: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

New-SmbShare –Name SharedFolder –Path C:\SharedFolder -FullAccess IgniteNZ\Administrator -ReadAccess IgniteNZ\Don.Funk

New File Share

Page 70: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

DEMO: BASIC FILE SHARES

Page 71: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Summary

-Basic configuration-Core role tools

AD DSFile ServersDHCPDNS

-Snippits

Page 72: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Q&A

Page 73: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Related Ignite NZ Sessions

Virtualization Vision & Strategy

What’s new in Windows Server Hyper-V

Microsoft’s New Windows Server Containers

1

2

3

Required Slide*delete this box once you have listed content that is related to your session.

Speakers, please list the other Breakout Sessions that relate to your session.

Also indicate where and when they can find you, to continue the discussion. If you’re going to be at Hub Happy Hour (5.30-6.30pm Wed and Thu, let them know)

Page 74: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Resources

TechNet & MSDN FlashSubscribe to our fortnightly newsletter

http://aka.ms/technetnz http://aka.ms/msdnnz

http://aka.ms/ch9nz

Microsoft Virtual AcademyFree Online Learning

http://aka.ms/mva

Sessions on Demand

Page 75: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

Complete your session evaluation now and be in to win!

Page 76: 20 Better Ways to Perform Server Administration Using PowerShell Orin Thomas M339

© 2015 Microsoft Corporation. All rights reserved.Microsoft, Windows and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or

other countries.MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.