Содержание
- 2. Немного истории
- 3. Command.com with a batch-files Windows Script Host (cscript.exe) JScript and VBScript, Monad, aka Microsoft Shell or
- 4. Язык высокого уровня Базируется на .NET Командлеты является специализированными классами .NET Возможность пользоваться конвейером Расширенная система
- 5. Единственное мощное средство в Windows 2008 (2012) Server Core Выполнение рутинных задач (автоматизация, множественные операции) Доступ
- 6. http://msdn.microsoft.com/ru-ru/library/cc281945(v=sql.105).aspx http://ru.wikipedia.org/wiki/Windows_PowerShell http://stackoverflow.com (Ответы на многие вопросы) http://blogs.msdn.com/b/powershell/ http://www.computerperformance.co.uk/powershell/ http://thepowershellguy.com/blogs/posh/default.aspx Ресурсы по PowerShell в Сети
- 7. PowerShell в книгах
- 8. PowerShell в книгах
- 9. PowerShell в книгах
- 10. PowerShell в книгах
- 11. PowerShell в книгах
- 12. Verb-Noun Get-Command Set-ADUser Add-Computer Remove-EventLog … Правила именования Commandlets
- 13. powershell[.exe] [-PSConsoleFile FileName | -Version VersionNumber ] [-NoLogo] [-NoExit] [-NoProfile] [-NonInteractive] [-Sta] [-InputFormat {Text | XML}]
- 14. Рабочая среда PowerShell PowerShell_ISE
- 15. Варианты её настройки
- 16. Варианты её настройки
- 17. if ($host.name -eq "ConsoleHost") { $size=New-Object System.Management.Automation.Host.Size(120,80); $host.ui.rawui.WindowSize=$size } $myHostWin = $host.ui.rawui $myHostWin.ForegroundColor = "Blue" $myHostWin.BackgroundColor
- 18. Запускаем Powershell, затем PowerShell_ISE Знакомство
- 19. ExecutionPolicy
- 20. PS> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned PS> Get-ExecutionPolicy RemoteSigned PS> Изменение ExecutionPolicy
- 21. 1. Aliases PowerShell looks for alternate built-in or profile-defined aliases for the associated command name. If
- 22. PS> 1kb 1024 PS> 1mb 1048576 PS> 1gb 1073741824 PS> (1024*1024)/1MB 1 Использование GB, MB, и
- 23. Общие параметры для всех CmdLet
- 24. A pipeline is a method of passing data from one command to another. Get-Process | Where-Object
- 25. Пару слов про Aliases Aliases
- 26. Get-Module Modules
- 27. dir dir | sort Length -Descending dir | sort Length -Descending | select -first 1 dir
- 28. Основные команды Read-Host – read data from host Import-Csv – import data from CSV format Import-CliXml
- 29. Out-* —cmdlets that send the objects or formatting records to a specific destination Write-*—cmdlets that write
- 30. For –foregroundcolor and –backgroudcolor the next colors can be used: Black DarkBlue DarkGreen DarkCyan DarkRed DarkMagenta
- 31. Вывод Output (Часть команд)
- 32. Нужно спросить имя пользователя и вывести его на экран жёлтым цветом Нужно считать их текстового файла
- 33. $a = 1 $a | Get-Member TypeName: System.Int32 … $b = "1" $b | Get-Member TypeName:
- 34. $a = 1; $b = “1”; $c = “abc”; $d = $a / $b; $e =
- 35. Get-ChildItem variable: (Yes. It’s a drive) Get-Help … About_Automatic_variables —variables created and maintained by PowerShell About_Environment_variables
- 36. It represents the current object coming down the pipeline Get-ChildItem "c:\temp" | Where {$_.Length -gt 1MB}
- 37. $a = 1,2,3,4,5 $b = 1..5 $c = "a","b","c","d","e" $a = @(1,2,3,4,5) $a = @() for($i=1;$i-le5;$i++){$a
- 38. Операторы сравнения
- 39. 8 –eq 4 $a = “3”; $b =3; $a –eq $b; $a –gt $b; $a –ne
- 40. Get-ChildItem "C:\Temp" | Where{!$_.PsIsContainer} | ForEach-Object { if ($_.Length -gt 1MB) { Remove-Item $_.Fullname -WhatIf }
- 41. $files = Get-ChildItem "C:\Temp" | Where {!$_.PsIsContainer} foreach ($file in $files){ switch ($file.Length){ {$_ -gt 1MB}{Write-Host
- 42. Foreach-Object cmdlet Foreach loop For loop Do loop While loop Циклы
- 43. for ($i = 0; $i -lt somevalue; $i++) { } Циклы For
- 44. Циклы Foreach-Object $Out1 = @" $count files are smaller than 1MB and occupy $total_size bytes "@
- 45. Use the following syntax for a foreach loop: foreach ($item in $collection_of_items) { } dir "c:\test"
- 46. $date = (Get-Date).Adddays(-10) $files = Get-ChildItem "c:\Temp" | Where{!$_.PSIsContainer} foreach($file in $files){ if ($file.LastAccessTime -lt $date){
- 47. while ( ) { } Циклы While
- 48. $data = 1..57 $j = 1 while ($j -le 10){ $qqq = "C:\TEMP\PS\111\" $foldername = "Testfolder_$j"
- 49. do { } until ( ) do { } while ( ) Циклы Do
- 50. $i = 1 do { $name = "Testfolder_$i" New-Item -ItemType directory -Name $name $i++ } while
- 51. Get-Help Get-Command Get-Member Get-PSDrive 4 ваших лучших друга
- 52. Get-Help get-service | get-member -membertype *property Получение помощи (Get-Help)
- 53. Get-Command Get-Command ipconfig.exe | Format-List Get-Command *process Get-Command -Module ActiveDirectory | Sort verb, noun Get-Command Get-Process
- 54. Get-Help Get-Member Get-Process c* | Get-Member Get-Process c* | Get-Member -MemberType Property | Format-Wide -Column 2
- 55. Get-Help about Get-Help -detailed Get-Help -full Get-Help -examples Get-Help -online Get-Help about_topic_name Расширенное получение помощи
- 56. Single line comments: # Multiline comments: Основы
- 57. function Name { param( [type]$ParameterA = default_value, [type]$ParameterB = default_value ) begin { } process {
- 58. $data = 1..57 $i = 1 while ($i -le 10) { $name = "Testfolder_$i" New-Item -ItemType
- 59. Scope defines how scripts and functions work with variables. When PowerShell starts, it defines a top-level
- 60. PS> $env:psmodulepath -split ";" C:\Users\Alex\Documents\WindowsPowerShell\Modules C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ PS> Get-Module -ListAvailable ModuleType Name ExportedCommands ---------- ---- ---------------- Manifest
- 61. Рабочие примеры
- 62. Based on 02.ps1 Show process list as a Table Show by Grouping processes in Table Advanced
- 63. function get-ms { $ie = New-Object -ComObject InternetExplorer.Application $ie.Navigate("http://www.microsoft.com/") while ($ie.busy) { Start-Sleep -seconds 1 }
- 64. Рабочие примеры
- 65. Based on 04.ps1 Add new menu point, that route us to the site http://blogs.msdn.com/b/powershell/ Making a
- 66. Get-WmiObject -Class Win32_ComputerSystem | Format-List Name, SystemType, NumberOfProcessors Get-WmiObject -Class Win32_Processor | Format-List Manufacturer, Name, Description,
- 67. Get-WMIObject –list Returning a long list Get-WmiObject -List *OperatingSystem* Either option will return a list of
- 68. PS> $t = Get-WMIObject -Class Win32_OperatingSystem | Select LastBootUpTime >> PS> $t LastBootUpTime -------------- 20070406072653.500000+060 PS>
- 69. Two different ways, doing the same. Using [WMIClass] is a shortcut for using New-Object : $x
- 70. Рабочие примеры
- 71. Obtaining a Process list (07.ps1) Make it friendly Make it more friendly Changing sort order for
- 72. .NET VERSIONS PowerShell v1 needs . NET 2.0. PowerShell v2 needs . NET 2.0 apart from
- 73. PS> [System.Math]::Sqrt(16) 4 PS> [System.Math]::Pi 3.14159265358979 Интеграция с .NET Примеры.
- 74. [System.math] | get-member –Static Name MemberType Definition ---- ---------- ---------- Acos Method static double Acos(double d)
- 75. Рабочие примеры
- 76. Converting everything to string (09.ps1) Converting numbers Converting dates Converting times Complex converting Практика
- 77. Write-Host, Write-Warning, Write-Error Read-Host, Measure-Command Понятие отладки, базовые рекомендации
- 78. $sb = { Get-ChildItem c:\*.* } Measure-Command -Expression $sb Output should be like that: Days :
- 79. At last: Write-Progress (-Activity, -Status, -PercentComplete, -CurrentOperation) Find top 100 biggest files (10.ps1) More informative output
- 80. Find all *.tmp or anything else extension files from the root of the disk, count it
- 81. Obtaining OS version for a group of computers. (12.ps1) Make all above and export to Excel-compatible
- 82. Read the help files—there’s a mass of good information, especially in the examples. In PowerShell v3,
- 83. Avoid enumerating collections—using ForEach-Object or the ForEach scripting construct—unless there’s no other way to accomplish your
- 84. Ping computer via PowerShell (13.ps1) Pinging group of computers Restart service Another way to restart service
- 86. Скачать презентацию