Microsoft ® shell scripting environment Gives administrators more power and command in the shell...

19
PowerShell
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    218
  • download

    4

Transcript of Microsoft ® shell scripting environment Gives administrators more power and command in the shell...

Page 1: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Page 2: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• Microsoft ® shell scripting environment• Gives administrators more power and

command in the shell environment– Hence…PowerShell?

• Active Directory Module for Windows® Powershell allows for command-line and scripted operations

Page 3: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Getting Help• Get-help

Page 4: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Getting Help• Get-help get-acl -examples

Page 5: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Local Command• Get-ACL c:\windows

Page 6: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Local commands• Get-Service—returns

all services running on host

Page 7: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Local commands• Get-Service >

services.txt—output of Get-Service redirected to file services.txt

Page 8: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Local commands• Get-Service | ConvertTo-HTML | Out-File

services.html—output of Get-Service piped to ConvertTo-HTML whose output is piped to Out-File services.html

Page 9: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Local commands• Get-Service | ConvertTo-HTML | Out-File

services.html

Page 10: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

Local commands• Get-Service | Select Name,Status | ConvertTo-

HTML | Out-File services.html

Page 11: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• Check the state/status of a service– Get-WmiObject –class Win32_Service –filter

‘name=”adws”

Page 12: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• View Event log errors– Get-EventLog -LogName 'Application' -EntryType Error -Newest 5 |

Select-Object -property eventid, message | Format-table -AutoSize -Wrap

Page 13: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• Determine SID of local user accounts• Returns the security identifier of the diplayed

name.– $objUser = New-Object System.Security.Principal.NTAccount("administrator")– $strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])– $strSID.Value

Page 14: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• Determine SID of domain user accounts• Returns the security identifier of the displayed

name.– $objUser = New-Object System.Security.Principal.NTAccount(“domain name”,

"administrator")– $strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])– $strSID.Value

Page 15: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• Saving PowerShell scripts• Save commands at *.ps1

Page 16: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• Must change script execution policy to run scripts.

• Options are:– Restricted—no scripts can be run (default).– AllSigned—only scripts signed by trusted publisher

can be run– RemoteSigned—downloaded scripts must be

signed by a trusted publisher– Unrestricted—no restrictionsThunderdome!

Page 17: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• Get-ExecutionPolicy—displays current policy• Set-ExecutionPolicy—change policy

Page 18: Microsoft ® shell scripting environment Gives administrators more power and command in the shell environment – Hence…PowerShell? Active Directory Module.

PowerShell

• Growing resources daily