Upload
gerard-waters
View
229
Download
0
Embed Size (px)
Citation preview
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:
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.
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.
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.
1. To address recurring problems
DirectoryListWithArguments.ps1
foreach ($i in $args) {Get-ChildItem $i | Where-Object {$_.length -gt 1000} | Sort-Object -property name}
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}
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 }
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.
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
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.