.


:




:

































 

 

 

 


- Windows PowerShell .

.

 

1. ********* Windows PowerShell, Server Manager. a. ******** Administrator . b. Server Manager Start. Features. c. / Add Features d. Select Features Windows PowerShell Next. e. Confirm Installation Selections , "/Install". f. . g. . . Installation Results.
2. Windows PowerShell a. Windows PowerShell (Start) -> (All Programms) Windows PowerShell. - ... (Run) (Start), powershell . b. PowerShell. Windows PowerShell help. . c. : PS C:> Help Get-Command Get-Command, , , .. d. : PS C:> Get-Command . e. , , : PS C:> Get-Service Get-Service , . f. , , : PS C:> Get-Process g. Get-Process . : PS C:> Get-Process explorer h. : PS C:> Get-Process w* , w. , . | i. : PS C:> Get-Process i* | format-list . . : PS C:> Help format* : PS C:> Get-Process i* | format-wide PS C:> Get-Process i* | format-custom , , . , Get-Process : PS C:> Get-Process | Get-Member j. , . , : PS C:> Get-Process | where {$_.handlecount -gt 400} k. , : PS C:> Get-Process | where {$_.handlecount -gt 400} | sort-object Handles l. Get-Process|Get-Member Company . : PS C:> Get-Process | Get-Member Company | Format-List PS C:> Get-Process | sort-object Company | format-table -Group Company name, description, handles. m. WS (working set) 5 , PS C:> Get-Process | sort-object -property WS descending| select-object -first 5 stop-process . Notepad . : PS :> Get-process notepad | stop-process . Notepad. , whatif, , , : PS C:> Get-Process notepad | stop-process -whatif , : PS C:> Get-Process notepad | stop-process -confirm , , , . , *.psl, PowerShell, . . Windows PowerShell , . , , , . , , . , . : PS C:> get-executionpolicy Restricted. , : PS C:> set-executionpolicy <_> , : Restricted - . , . AllSigned - , , , . . , , . RemoteSigned- . , ( ). , . . , . Unrestricted- , . , ( Microsoft Outlook, Outlook Express Windows Messenger), , . , . , , . RemoteSigned, , , AllSigned, , . Unrestricted RemoteSigned: PS C:> Set-ExecutionPolicy Unrestricted : PS C:> Set-ExecutionPolicy AllSigned psl PowerShell .
3. , - , , , , , . Windows PowerShell, : new-item, copy-item, move-item, rename-item remove-item. a. TextFiles : PS C:> new-item TextFiles -itemtype directory -itemtype, Windows PowerShell, (file) (directory)., new-item ni. : PS C:> ni TextFiles -itemtype directory b. psdemo.txt, 1.txt, 2.txt: c. *.txt TextFiles, copy-item( cpi, cp, ): , , -path () -destination (): PS C:>copy-item -path '.\*.txt' -destination '.\TextFiles' d. set-location TextFiles. PS C:> set-location TextFiles e. rename-item psdemo.txt psdemo.bak. -path -newName: PS C:> rename-item psdemo.txt psdemo.bak f. , , move-item: PS C:> move-item psdemo.bak..\ g. set-location, sl : PS C:> sl.. 1. h. TextFiles, remove-item. TextFiles , -recurse. , Windows PowerShell remove-item. PS C:> remove-item TextFiles -recurse
4. - , .. Windows PowerShell . PowerShell, , PowerShell, . a. sl set-location, HKEY_CURRENT_USER : PS C:\> sl hkcu: , , , PowerShell . b. HKEY_CURRENT_USER reg: PS HKCU:\> $reg = gci. -rec -ea silentlycontinue get-childitem( gci). . , HKEY_CURRENT_USER. -recurse , . , -easilentlycontinue , , . c. : PS HKCU:\>$s = $reg | % {if ((gp $_.pspath) -match 'PowerShell'){$_.pspath}} , 'PowerShell'. , reg %, for-each. , reg PowerShell '_'. , for-each. for-each if , , pspath, get-itemproperty ( gp), 'PowerShell'. , pspath. s. d. select-object ( select) : PS HKCU:\>$s | select -first 2 e. out-file.
5. , , . Event Viewer (eventvwr.exe). PowerShell , get-eventlog, . 5 System. a. , , , : PS C:\> get-eventlog -list . -list PowerShell . : Application, InternetExplorer, System, Windows Power Shell .. b. , "Error": PS C:\> $bad = get-eventlog "System" | where-object { $_.EntryType -eq "Error" } get-eventlog, "System" , , logName. $bad where-object . where-object , , Entry Type "Error". . , select-object - last: PS C:\> $bad | select-object -last 5
6. , -, , , , . , WindowsPowerShell. a. , , $allprocs: PS C:\> $allprocs= get-process b. for-each, % foreach: PS C:\> $allprocs | foreach-object {if ($_.Virtualmemorysize -gt 20MB) {$_.name}} , , $_. . for-each virtualmemorysize (20 ). , . , PowerShell KB, MB, GB, , , ..
7. WMI , Windows Management Instrumentation (WMI) Microsoft Common Information Model (CMI). WMI - , . , Windows PowerShell , WMI. a. get-wmiobject , $pfu: PS C:\> $pfu = get-wmiobject -class 'win32_pageFileUsage' b. get-member , Win32_pageFileUsage: PS C:\> $pfu | get-member -membertype property | where-object { $_.name -notmatch'_'} get-member , , . WMI win32_pageFileUsage( , WMI , ), : PS C:\> get-wmiobject -list . , : PS C:\> Spfu.caption; $pfu.currentusage . win32_DiskDrive, , . WMI-, . caption , : . . - , , : PS C:\> get-wmiobject win32_LogicalDisk , . type=3: PS C:\> get-wmiobject win32_LogicalDisk -filter "drivetype=3" deviceid, freespace: PS C:\> get-wmiobject win32_LogicaIDisk -filter "drivetype=3" |select deviceid, freespace , , : PS C:\> get-wmiobject win32_LogicaIDisk -filter "drivetype=3" |%{$_.deviceid;$_.freespace/lGB}

 

Windows PowerShell , -.

, VBScript. Windows PowerShell VBScript, a, .



<== | ==>
| . : .
:


: 2017-04-14; !; : 277 |


:

:

, ,
==> ...

745 - | 739 -


© 2015-2024 lektsii.org - -

: 0.016 .