microsoft ® shell scripting environment gives administrators more power and command in the shell...

Post on 22-Dec-2015

218 Views

Category:

Documents

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

PowerShell

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

PowerShell

Getting Help• Get-help

PowerShell

Getting Help• Get-help get-acl -examples

PowerShell

Local Command• Get-ACL c:\windows

PowerShell

Local commands• Get-Service—returns

all services running on host

PowerShell

Local commands• Get-Service >

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

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

PowerShell

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

services.html

PowerShell

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

HTML | Out-File services.html

PowerShell

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

‘name=”adws”

PowerShell

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

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

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

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

PowerShell

• Saving PowerShell scripts• Save commands at *.ps1

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!

PowerShell

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

PowerShell

• Growing resources daily

top related