SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
CIS 216
Highline Community College
Dan Morrill
 Get-help - The first PowerShell cmdlet every administrator should learn is Get-
Help. You can use this command to get help with any other command. For
example, if you want to know how the Get-Process command works, you can
type:
 Get-Help -Name Get-Process and Windows will display the full command
syntax.
 Set-ExecutionPolicy
 Restricted — Restricted is the default execution policy and locks PowerShell
down so that commands can be entered only interactively. PowerShell scripts
are not allowed to run.
 All Signed — If the execution policy is set to All Signed then scripts will be
allowed to run, but only if they are signed by a trusted publisher.
 Remote Signed — If the execution policy is set to Remote Signed, any
PowerShell scripts that have been locally created will be allowed to run. Scripts
created remotely are allowed to run only if they are signed by a trusted
publisher.
 Unrestricted — As the name implies, Unrestricted removes all restrictions
from the execution policy.
 Get-ExcutionPolicy
 If you’re working on an unfamiliar server, you’ll need to
know what execution policy is in use before you attempt
to run a script. You can find out by using the Get-
ExecutionPolicy command.
 Get-service
 The Get-Service command provides a list of all of the
services that are installed on the system. If you are
interested in a specific service you can append the -
Name switch and the name of the service (wildcards are
permitted) When you do, Windows will show you the
service’s state.
 ConvertTo-HTML
 PowerShell can provide a wealth of information about the system, but
sometimes you need to do more than just view the information onscreen.
Sometimes, it’s helpful to create a report you can send to someone. One way of
accomplishing this is by using the ConvertTo-HTML command.
 To use this command, simply pipe the output from another command into the
ConvertTo-HTML command. You will have to use the -Property switch to
control which output properties are included in the HTML file and you will
have to provide a filename.
 Get-Service | ConvertTo-HTML -Property Name, Status > C:services.htm
 Export-CSV
 Just as you can create an HTML report based on PowerShell data, you can also
export data from PowerShell into a CSV file that you can open using Microsoft
Excel. The syntax is similar to that of converting a command’s output to HTML.
At a minimum, you must provide an output filename. For example, to export
the list of system services to a CSV file, you could use the following command:
 Get-Service | Export-CSV c:service.csv
 Select-Object
 If you tried using the command above, you know that there were
numerous properties included in the CSV file. It’s often helpful to
narrow things down by including only the properties you are really
interested in. This is where the Select-Object command comes into
play. The Select-Object command allows you to specify specific
properties for inclusion. For example, to create a CSV file containing
the name of each system service and its status, you could use the
following command:
 Get-Service | Select-Object Name, Status | Export-CSV c:service.csv
 Get-EventLog
 You can actually use PowerShell to parse your computer’s event logs.
There are several parameters available, but you can try out the
command by simply providing the -Log switch followed by the name of
the log file. For example, to see the Application log, you could use the
following command:
 Get-EventLog -Log "Application"
 Get-Process
 Just as you can use the Get-Service command to display a list
of all of the system services, you can use the Get-Process
command to display a list of all of the processes that are
currently running on the system.
 Stop-Process
 Sometimes, a process will freeze up. When this happens, you
can use the Get-Process command to get the name or the
process ID for the process that has stopped responding. You
can then terminate the process by using the Stop-Process
command. You can terminate a process based on its name or
on its process ID. For example, you could terminate Notepad
by using one of the following commands:
 Stop-Process -Name notepad
 Stop-Process -ID 2668
 Search-ADAccount -PasswordNeverExpires | FT
Name, ObjectClass, UserPrincipalName
 Show user accounts with a non-expiring password
 Get-AdUser -Filter * -Properties OfficePhone | FT
OfficePhone,UserPrincipalName
 Display the phone number values for all user accounts
 Psdrive
 Shows all connected drives, local and network
 Remember that to run scripts you need to be
authorized to do so:
 Get-ExcutionPolicy
 Set-ExecutionPolicy unrestricted
 Allows you to run anything once you know the current
execution policy, and how to set it to run your script
 Running your script is all about syntax
 & "C:My ScriptsTest.ps1“
 If there is a space in the directory name, must be in quotes
 & tells the script to run
 PS1 is for Power Shell 1 – a good naming convention to know
what version of powershell you were running when it was
made
Pipes
Pipes are used to
string commands
together
Get-Service | Sort-
Object Status |
Format-Table
Will give you a handy
table of all the
services running, by
status, and in a nicely
formatted table
 Nice list of services, but now I want them as a CSV, so
what do I type?
 Get-Service | Sort-Object Status | Format-Table |
export-CSV c:service.csv
 Try it
 Did you get this?
 Did I have permission to write to the C:?
 Did I make an error in syntax?
 What happens if I try to write it to my own home
directory?
 get-service | sort-object Status | format-table | export-
CSV "c:usersdmorrillMy documentsservices.csv"
Windows power shell basics
 Permissions on where you can write files
 Permissions on what can run when writing a
PowerShell Script
 Permissions on Directories
 Your permissions when accessing remote services like
Active Directory (who you are running the script as)
 All of these can keep a script from executing at all, or
erring out when we try to execute the file
 Using powershell
 Get a list of running services (screen cap)
 Get a list of running services formatted as a table (screen
cap)
 Get a list of running services formatted as a table and
output as a CSV file
 Get a list of running services formatted as a table and
output as a HTML file
 Zip all the files (2 images, 1 CSV, and 1 HTML file) and
upload to Angel

Mais conteúdo relacionado

Mais procurados

Monitoring with Syslog and EventMachine (RailswayConf 2012)
Monitoring  with  Syslog and EventMachine (RailswayConf 2012)Monitoring  with  Syslog and EventMachine (RailswayConf 2012)
Monitoring with Syslog and EventMachine (RailswayConf 2012)Wooga
 
More than syntax
More than syntaxMore than syntax
More than syntaxWooga
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVMaxym Kharchenko
 
Logrotate sh
Logrotate shLogrotate sh
Logrotate shBen Pope
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scriptingTony Fabeen
 
What's new in PHP 5.5
What's new in PHP 5.5What's new in PHP 5.5
What's new in PHP 5.5Tom Corrigan
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest UpdatesIftekhar Eather
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101hendrikvb
 
Getting out of Callback Hell in PHP
Getting out of Callback Hell in PHPGetting out of Callback Hell in PHP
Getting out of Callback Hell in PHPArul Kumaran
 
Shell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address InformationShell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address InformationVCP Muthukrishna
 
The Ring programming language version 1.5.4 book - Part 18 of 185
The Ring programming language version 1.5.4 book - Part 18 of 185The Ring programming language version 1.5.4 book - Part 18 of 185
The Ring programming language version 1.5.4 book - Part 18 of 185Mahmoud Samir Fayed
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Zyxware Technologies
 

Mais procurados (20)

Monitoring with Syslog and EventMachine (RailswayConf 2012)
Monitoring  with  Syslog and EventMachine (RailswayConf 2012)Monitoring  with  Syslog and EventMachine (RailswayConf 2012)
Monitoring with Syslog and EventMachine (RailswayConf 2012)
 
More than syntax
More than syntaxMore than syntax
More than syntax
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
 
Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
 
Php hacku
Php hackuPhp hacku
Php hacku
 
Unix cheatsheet
Unix cheatsheetUnix cheatsheet
Unix cheatsheet
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
What's new in PHP 5.5
What's new in PHP 5.5What's new in PHP 5.5
What's new in PHP 5.5
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
Php
PhpPhp
Php
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
Getting out of Callback Hell in PHP
Getting out of Callback Hell in PHPGetting out of Callback Hell in PHP
Getting out of Callback Hell in PHP
 
Shell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address InformationShell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address Information
 
The Ring programming language version 1.5.4 book - Part 18 of 185
The Ring programming language version 1.5.4 book - Part 18 of 185The Ring programming language version 1.5.4 book - Part 18 of 185
The Ring programming language version 1.5.4 book - Part 18 of 185
 
LogMiner
LogMinerLogMiner
LogMiner
 
Tres Gemas De Ruby
Tres Gemas De RubyTres Gemas De Ruby
Tres Gemas De Ruby
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
 

Semelhante a Windows power shell basics

Basic commands for powershell : Configuring Windows PowerShell and working wi...
Basic commands for powershell : Configuring Windows PowerShell and working wi...Basic commands for powershell : Configuring Windows PowerShell and working wi...
Basic commands for powershell : Configuring Windows PowerShell and working wi...Hitesh Mohapatra
 
Power Shell for System Admins - By Kaustubh
Power Shell for System Admins - By KaustubhPower Shell for System Admins - By Kaustubh
Power Shell for System Admins - By KaustubhKaustubh Kumar
 
8 power shell commands every windows administrator should know
8 power shell commands every windows administrator should know8 power shell commands every windows administrator should know
8 power shell commands every windows administrator should knowDana Pardaz Co.
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubEssam Salah
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellPhan Hien
 
Intro to PowerShell
Intro to PowerShellIntro to PowerShell
Intro to PowerShellAdam Preston
 
Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0venkatakrishnan k
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14Syed Asrarali
 
Sql Server & PowerShell
Sql Server & PowerShellSql Server & PowerShell
Sql Server & PowerShellAaron Shilo
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Wamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationWamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationChetan Soni
 
Power shell basics day 2
Power shell basics day 2Power shell basics day 2
Power shell basics day 2Ashish Raj
 
PHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpPHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpaimaq9a
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltStack
 

Semelhante a Windows power shell basics (20)

Basic commands for powershell : Configuring Windows PowerShell and working wi...
Basic commands for powershell : Configuring Windows PowerShell and working wi...Basic commands for powershell : Configuring Windows PowerShell and working wi...
Basic commands for powershell : Configuring Windows PowerShell and working wi...
 
PowerShell-1
PowerShell-1PowerShell-1
PowerShell-1
 
Power Shell for System Admins - By Kaustubh
Power Shell for System Admins - By KaustubhPower Shell for System Admins - By Kaustubh
Power Shell for System Admins - By Kaustubh
 
8 power shell commands every windows administrator should know
8 power shell commands every windows administrator should know8 power shell commands every windows administrator should know
8 power shell commands every windows administrator should know
 
Windows PowerShell.pptx
Windows PowerShell.pptxWindows PowerShell.pptx
Windows PowerShell.pptx
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShell
 
Intro to PowerShell
Intro to PowerShellIntro to PowerShell
Intro to PowerShell
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0
 
No-script PowerShell v2
No-script PowerShell v2No-script PowerShell v2
No-script PowerShell v2
 
AtoM's Command Line Tasks - An Introduction
AtoM's Command Line Tasks - An IntroductionAtoM's Command Line Tasks - An Introduction
AtoM's Command Line Tasks - An Introduction
 
Intro to tsql
Intro to tsqlIntro to tsql
Intro to tsql
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14
 
Sql Server & PowerShell
Sql Server & PowerShellSql Server & PowerShell
Sql Server & PowerShell
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Wamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationWamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and Configuration
 
Power shell basics day 2
Power shell basics day 2Power shell basics day 2
Power shell basics day 2
 
PHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpPHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for php
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
 

Mais de Dan Morrill

Understanding web site analytics
Understanding web site analyticsUnderstanding web site analytics
Understanding web site analyticsDan Morrill
 
Understanding UNIX CASE and TPUT
Understanding UNIX CASE and TPUTUnderstanding UNIX CASE and TPUT
Understanding UNIX CASE and TPUTDan Morrill
 
Information security principles
Information security principlesInformation security principles
Information security principlesDan Morrill
 
Using Regular Expressions in Grep
Using Regular Expressions in GrepUsing Regular Expressions in Grep
Using Regular Expressions in GrepDan Morrill
 
Understanding the security_organization
Understanding the security_organizationUnderstanding the security_organization
Understanding the security_organizationDan Morrill
 
You should ask before copying that media
You should ask before copying that mediaYou should ask before copying that media
You should ask before copying that mediaDan Morrill
 
Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Dan Morrill
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewDan Morrill
 
What is cloud computing
What is cloud computingWhat is cloud computing
What is cloud computingDan Morrill
 
Social Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleSocial Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleDan Morrill
 
Case Studies In Social Media Chinese
Case Studies In Social Media ChineseCase Studies In Social Media Chinese
Case Studies In Social Media ChineseDan Morrill
 
Case Studies In Social Media
Case Studies In Social MediaCase Studies In Social Media
Case Studies In Social MediaDan Morrill
 
Turn On Tune In Step Out
Turn On Tune In Step OutTurn On Tune In Step Out
Turn On Tune In Step OutDan Morrill
 
Technology And The Future Of Management
Technology And The Future Of ManagementTechnology And The Future Of Management
Technology And The Future Of ManagementDan Morrill
 

Mais de Dan Morrill (15)

Understanding web site analytics
Understanding web site analyticsUnderstanding web site analytics
Understanding web site analytics
 
Understanding UNIX CASE and TPUT
Understanding UNIX CASE and TPUTUnderstanding UNIX CASE and TPUT
Understanding UNIX CASE and TPUT
 
Information security principles
Information security principlesInformation security principles
Information security principles
 
Using Regular Expressions in Grep
Using Regular Expressions in GrepUsing Regular Expressions in Grep
Using Regular Expressions in Grep
 
Understanding the security_organization
Understanding the security_organizationUnderstanding the security_organization
Understanding the security_organization
 
You should ask before copying that media
You should ask before copying that mediaYou should ask before copying that media
You should ask before copying that media
 
Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
 
What is cloud computing
What is cloud computingWhat is cloud computing
What is cloud computing
 
Social Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleSocial Media Plan for CityU of Seattle
Social Media Plan for CityU of Seattle
 
BSIS Overview
BSIS OverviewBSIS Overview
BSIS Overview
 
Case Studies In Social Media Chinese
Case Studies In Social Media ChineseCase Studies In Social Media Chinese
Case Studies In Social Media Chinese
 
Case Studies In Social Media
Case Studies In Social MediaCase Studies In Social Media
Case Studies In Social Media
 
Turn On Tune In Step Out
Turn On Tune In Step OutTurn On Tune In Step Out
Turn On Tune In Step Out
 
Technology And The Future Of Management
Technology And The Future Of ManagementTechnology And The Future Of Management
Technology And The Future Of Management
 

Último

General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17Celine George
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxMYDA ANGELICA SUAN
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17Celine George
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesMohammad Hassany
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice documentXsasf Sfdfasd
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 

Último (20)

General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptx
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming Classes
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice document
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 

Windows power shell basics

  • 1. CIS 216 Highline Community College Dan Morrill
  • 2.  Get-help - The first PowerShell cmdlet every administrator should learn is Get- Help. You can use this command to get help with any other command. For example, if you want to know how the Get-Process command works, you can type:  Get-Help -Name Get-Process and Windows will display the full command syntax.  Set-ExecutionPolicy  Restricted — Restricted is the default execution policy and locks PowerShell down so that commands can be entered only interactively. PowerShell scripts are not allowed to run.  All Signed — If the execution policy is set to All Signed then scripts will be allowed to run, but only if they are signed by a trusted publisher.  Remote Signed — If the execution policy is set to Remote Signed, any PowerShell scripts that have been locally created will be allowed to run. Scripts created remotely are allowed to run only if they are signed by a trusted publisher.  Unrestricted — As the name implies, Unrestricted removes all restrictions from the execution policy.
  • 3.  Get-ExcutionPolicy  If you’re working on an unfamiliar server, you’ll need to know what execution policy is in use before you attempt to run a script. You can find out by using the Get- ExecutionPolicy command.  Get-service  The Get-Service command provides a list of all of the services that are installed on the system. If you are interested in a specific service you can append the - Name switch and the name of the service (wildcards are permitted) When you do, Windows will show you the service’s state.
  • 4.  ConvertTo-HTML  PowerShell can provide a wealth of information about the system, but sometimes you need to do more than just view the information onscreen. Sometimes, it’s helpful to create a report you can send to someone. One way of accomplishing this is by using the ConvertTo-HTML command.  To use this command, simply pipe the output from another command into the ConvertTo-HTML command. You will have to use the -Property switch to control which output properties are included in the HTML file and you will have to provide a filename.  Get-Service | ConvertTo-HTML -Property Name, Status > C:services.htm  Export-CSV  Just as you can create an HTML report based on PowerShell data, you can also export data from PowerShell into a CSV file that you can open using Microsoft Excel. The syntax is similar to that of converting a command’s output to HTML. At a minimum, you must provide an output filename. For example, to export the list of system services to a CSV file, you could use the following command:  Get-Service | Export-CSV c:service.csv
  • 5.  Select-Object  If you tried using the command above, you know that there were numerous properties included in the CSV file. It’s often helpful to narrow things down by including only the properties you are really interested in. This is where the Select-Object command comes into play. The Select-Object command allows you to specify specific properties for inclusion. For example, to create a CSV file containing the name of each system service and its status, you could use the following command:  Get-Service | Select-Object Name, Status | Export-CSV c:service.csv  Get-EventLog  You can actually use PowerShell to parse your computer’s event logs. There are several parameters available, but you can try out the command by simply providing the -Log switch followed by the name of the log file. For example, to see the Application log, you could use the following command:  Get-EventLog -Log "Application"
  • 6.  Get-Process  Just as you can use the Get-Service command to display a list of all of the system services, you can use the Get-Process command to display a list of all of the processes that are currently running on the system.  Stop-Process  Sometimes, a process will freeze up. When this happens, you can use the Get-Process command to get the name or the process ID for the process that has stopped responding. You can then terminate the process by using the Stop-Process command. You can terminate a process based on its name or on its process ID. For example, you could terminate Notepad by using one of the following commands:  Stop-Process -Name notepad  Stop-Process -ID 2668
  • 7.  Search-ADAccount -PasswordNeverExpires | FT Name, ObjectClass, UserPrincipalName  Show user accounts with a non-expiring password  Get-AdUser -Filter * -Properties OfficePhone | FT OfficePhone,UserPrincipalName  Display the phone number values for all user accounts  Psdrive  Shows all connected drives, local and network
  • 8.  Remember that to run scripts you need to be authorized to do so:  Get-ExcutionPolicy  Set-ExecutionPolicy unrestricted  Allows you to run anything once you know the current execution policy, and how to set it to run your script  Running your script is all about syntax  & "C:My ScriptsTest.ps1“  If there is a space in the directory name, must be in quotes  & tells the script to run  PS1 is for Power Shell 1 – a good naming convention to know what version of powershell you were running when it was made
  • 9. Pipes Pipes are used to string commands together Get-Service | Sort- Object Status | Format-Table Will give you a handy table of all the services running, by status, and in a nicely formatted table
  • 10.  Nice list of services, but now I want them as a CSV, so what do I type?  Get-Service | Sort-Object Status | Format-Table | export-CSV c:service.csv  Try it  Did you get this?
  • 11.  Did I have permission to write to the C:?  Did I make an error in syntax?  What happens if I try to write it to my own home directory?  get-service | sort-object Status | format-table | export- CSV "c:usersdmorrillMy documentsservices.csv"
  • 13.  Permissions on where you can write files  Permissions on what can run when writing a PowerShell Script  Permissions on Directories  Your permissions when accessing remote services like Active Directory (who you are running the script as)  All of these can keep a script from executing at all, or erring out when we try to execute the file
  • 14.  Using powershell  Get a list of running services (screen cap)  Get a list of running services formatted as a table (screen cap)  Get a list of running services formatted as a table and output as a CSV file  Get a list of running services formatted as a table and output as a HTML file  Zip all the files (2 images, 1 CSV, and 1 HTML file) and upload to Angel

Notas do Editor

  1. Source: http://www.techrepublic.com/blog/10things/10-powershell-commands-every-windows-admin-should-know/2052
  2. http://technet.microsoft.com/en-us/library/ee176949.aspx