an alias is an alternative name assigned to a cmdlet. aliases allow users to quickly interact with...

18

Upload: gerard-waters

Post on 21-Jan-2016

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is
Page 2: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is
Page 3: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is
Page 4: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is
Page 5: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is
Page 6: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is
Page 7: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is
Page 8: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

An alias is an alternative name assigned to a Cmdlet. 

Aliases allow users to quickly interact with the shell.

The Cmdlet get-alias is used to list all built-in aliases as shown in the diagram on the next slide:

Page 9: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is
Page 10: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

They are .NET programs used to provide easy access to information external to the shell environment in order for the users to view it and manage it.

To obtain a listing of all the providers, the Get-PSProvider cmdlet is used.

To work with specific providers, use the set-location cmdlet then specify the provider drive.

Page 11: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

There are seven types of providers namely:

1.Alias - Provides access to the windows PowerShell aliases and their valuesGet-PSProviderSl Alias:\GCI | where-object {$_.name –like “s*”}

2.Environment - Provides access to the Windows environment variables.

3.FileSystem  - Provides access to files and directories.

4.Function - Provides access to the functions defined in Windows PowerShell.

Page 12: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

5. RegistryProvides access to the system registry keys and values.

6. Variable Provides access to Windows PowerShell variables and their values.

7. CertificateProvides read-only access to certificate stores and certificates.

Page 13: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

1. To address recurring problems

DirectoryListWithArguments.ps1

foreach ($i in $args) {Get-ChildItem $i | Where-Object {$_.length -gt 1000} | Sort-Object -property name}

Page 14: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

2. To run the script as a scheduled task

ListProcessesSortResults.ps1

$args = "localhost","loopback","127.0.0.1"

foreach ($i in $args) {$strFile = "c:\mytest\"+ $i +"Processes.txt" Write-Host "Testing" $i "please wait ..."; Get-WmiObject -computername $i -class win32_process | Select-Object name, processID, Priority, ThreadCount,

PageFaults, PageFileUsage | Where-Object {!$_.processID -eq 0} | Sort-Object -property

name | Format-Table | Out-File $strFile}

Page 15: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

3. To store and share both the “secret commands” and the ideas behind the scripts

AccountsWithNoRequiredPassword.ps1

$args = "localhost"

foreach ($i in $args) {Write-Host "Connecting to" $i "please wait ..."; Get-WmiObject -computername $i -class

win32_UserAccount | Select-Object Name, Disabled, PasswordRequired, SID,

SIDType | Where-Object {$_.PasswordRequired -eq 0} | Sort-Object -property name | Write-Host }

Page 16: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

Scripting support is disabled by default in Windows PowerShell.

Running a script when policy is not set generates an error message that must be fixed to allow script execution.

Page 17: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

There are four levels of execution policy:

1. RestrictedWill not run scripts or configuration files

2. AllSignedAll scripts and configuration files must be signed by a trusted

publisher

3. RemoteSignedAll scripts and configuration files downloaded from the internet

must be signed by a trusted publisher

4. UnrestrictedAll scripts and configuration files will run

Page 18: An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is

Wilson, E. (2007). Microsoft Windows PowerShell step by step. Washington: Microsoft Press.

Tomsho, G. (2010). MCTS guide to Microsoft Windows Server 2008 Active Directory configuration: Exam 70-640. Boston, MA: Course Technology/Cengage Learning.

Schwichtenberg, H. (2008). Essential PowerShell. The Addison-Wesley Microsoft technology series. Upper Saddle River, NJ: Addison-Wesley.