SlideShare a Scribd company logo
1 of 18
PowerShell
Osnove
WMF? PowerShell?
 PowerShell je dio WMF (Windows Management Framework)
 5 iteracija, posljednji je PowerShell 5 (Google: WMF 5)
Ali postoji PowerShell i PowerShell ISE
 PowerShell je okruženje
 PowerShell ISE je alat za razvoj cmdleta
Script, function, cmdlet, module
 Objektno orijentiran
 Funkcija je osnova
 CmdLet sadrži funkcije
 Skripta je skup funkcija i CmdLeta
 Module je skup skripti, funkcija i CmdLeta
Verb-Noun
 CmdLeti koriste Verb-Noun standard
 Razmaka u CmdLetu nema
 Verb – što (Get, Set, Update, …)
 Noun – na čemu (Help, ADUser, Item, …)
 40 tak striktno definiranih glagola
 I naravno parametri… (-Nešto)
 Tab, IntelliSense, AutoComplete, …
A kako da to pokrenem?
 PowerShell skriptu ili modul nije moguće pokrenuti na dvostruki klik (by-design, al za ozbiljno)
 Cmdlet se pokreće pozivanjem, npr „Get-Help”
 Skripta se pokreće malo čudnije „.Ubij-Sve.ps1”
 Ili se otvori u ISE i pokrene zelenim „play” gumbom
 Ponekad skripta = modul i ništa se ne dogodi?
 „Run as Administrator” je gotovo obavezno
Help, man, bog-ti-pomogo
 Update-Help
 Get-Help process
 Get-Help *process
 Get-Help *process*
 Get-Help Get-Process -Detailed
 Get-Help Get-Process -Full
 Get-Help Get-Process -Examples
 Get-Help Get-Process -ShowWindow
Moduli
 Module je potrebno instalirati
 Npr. Active Directory modul se instalira kada se instalira RSAT
 Moduli se mogu i dodavati ručno (nikada ne dodavat u
C:WindowsSystem32WindowsPowerShellv1.0Modules)
 Get-Module -ListAvailable
 Import-Module
Operatori
 Aritmetički
 + - * /
 Get-Help about_arithmetic_operators
 Dodjela
 = += -=
 Get-Help about_comparison_opeartors
Operatori
 Logički
 -and
 -or
 Get-Help about_Logical_Operators
 Komparativni
 -eq (equal, jednako)
 -ne (not equal, nije jednako)
 Get-Help about_Comparison_Operators
Varijable
 Označavaju se sa znakom $
 npr $mojaVarijabla
 $procesi = Get-Process
 Ispis varijable - $procesi
Zagrade, navodnici, komentari…
 Zgrade ()
 Vitičaste zagrade {}
 Dvostruki navodnici – „”
 Jednostruki navodnici - ‘’
 Dolar - $ - varijabla
 Hash # - komentar
Pipeline
 Prosljeđivanje rezultata CmdLeta u daljnje obrađivanje
 Pipeline se označava sa |
 Korištenje objekta u pipeu - $_
 Get-Process | Where-Object {$_.Name –eq „svchost”} | Out-GridView
Uvjeti
If(uvjet)
{
# uvjet zadovoljen
}
Else
{
# uvijet nije zadovoljen
}
Petlje
do
{
# napravi nešto
}
while (uvjet)
do
{
# napravi nešto
}
until (uvjet)
while (uvjet)
{
# napravi nešto
}
Petlje
for ($i=1; $i –le 10; $i++)
{
$i
}
Foreach ($varijabla in $skup)
{
$varijabla
}
Export
 Export
 Export-CSV
 Out
 Out-File
 Out-Printer
 Out-GridView
Udaljeno izvršavanje
 WinRM mora raditi
 Enable-PSRemoting -Force
 Dio CmdLeta ima parametar –ComputerName
 Enter-PSSession
 Invoke-Command

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

PowerShell osnove

  • 2. WMF? PowerShell?  PowerShell je dio WMF (Windows Management Framework)  5 iteracija, posljednji je PowerShell 5 (Google: WMF 5)
  • 3. Ali postoji PowerShell i PowerShell ISE  PowerShell je okruženje  PowerShell ISE je alat za razvoj cmdleta
  • 4. Script, function, cmdlet, module  Objektno orijentiran  Funkcija je osnova  CmdLet sadrži funkcije  Skripta je skup funkcija i CmdLeta  Module je skup skripti, funkcija i CmdLeta
  • 5. Verb-Noun  CmdLeti koriste Verb-Noun standard  Razmaka u CmdLetu nema  Verb – što (Get, Set, Update, …)  Noun – na čemu (Help, ADUser, Item, …)  40 tak striktno definiranih glagola  I naravno parametri… (-Nešto)  Tab, IntelliSense, AutoComplete, …
  • 6. A kako da to pokrenem?  PowerShell skriptu ili modul nije moguće pokrenuti na dvostruki klik (by-design, al za ozbiljno)  Cmdlet se pokreće pozivanjem, npr „Get-Help”  Skripta se pokreće malo čudnije „.Ubij-Sve.ps1”  Ili se otvori u ISE i pokrene zelenim „play” gumbom  Ponekad skripta = modul i ništa se ne dogodi?  „Run as Administrator” je gotovo obavezno
  • 7. Help, man, bog-ti-pomogo  Update-Help  Get-Help process  Get-Help *process  Get-Help *process*  Get-Help Get-Process -Detailed  Get-Help Get-Process -Full  Get-Help Get-Process -Examples  Get-Help Get-Process -ShowWindow
  • 8. Moduli  Module je potrebno instalirati  Npr. Active Directory modul se instalira kada se instalira RSAT  Moduli se mogu i dodavati ručno (nikada ne dodavat u C:WindowsSystem32WindowsPowerShellv1.0Modules)  Get-Module -ListAvailable  Import-Module
  • 9. Operatori  Aritmetički  + - * /  Get-Help about_arithmetic_operators  Dodjela  = += -=  Get-Help about_comparison_opeartors
  • 10. Operatori  Logički  -and  -or  Get-Help about_Logical_Operators  Komparativni  -eq (equal, jednako)  -ne (not equal, nije jednako)  Get-Help about_Comparison_Operators
  • 11. Varijable  Označavaju se sa znakom $  npr $mojaVarijabla  $procesi = Get-Process  Ispis varijable - $procesi
  • 12. Zagrade, navodnici, komentari…  Zgrade ()  Vitičaste zagrade {}  Dvostruki navodnici – „”  Jednostruki navodnici - ‘’  Dolar - $ - varijabla  Hash # - komentar
  • 13. Pipeline  Prosljeđivanje rezultata CmdLeta u daljnje obrađivanje  Pipeline se označava sa |  Korištenje objekta u pipeu - $_  Get-Process | Where-Object {$_.Name –eq „svchost”} | Out-GridView
  • 15. Petlje do { # napravi nešto } while (uvjet) do { # napravi nešto } until (uvjet) while (uvjet) { # napravi nešto }
  • 16. Petlje for ($i=1; $i –le 10; $i++) { $i } Foreach ($varijabla in $skup) { $varijabla }
  • 17. Export  Export  Export-CSV  Out  Out-File  Out-Printer  Out-GridView
  • 18. Udaljeno izvršavanje  WinRM mora raditi  Enable-PSRemoting -Force  Dio CmdLeta ima parametar –ComputerName  Enter-PSSession  Invoke-Command