mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-14 03:54:46 +01:00
Update cheat-sheet.md and FAQ.md
This commit is contained in:
parent
abe9bf5ec0
commit
970048b24a
@ -80,7 +80,7 @@ NOTE: the group policy object (GPO) settings of your organization might disallow
|
||||
<details><summary>How to learn PowerShell?</summary>
|
||||
|
||||
* Please find tutorials at: https://www.guru99.com/powershell-tutorial.html
|
||||
* And a PowerShell cheat sheet at: [cheat-sheet.md](cheat-sheet.md)
|
||||
* And a PowerShell cheat sheet at: [PowerShell/Docs/cheat-sheet.md](cheat-sheet.md)
|
||||
* The official PowerShell documentation is at: https://docs.microsoft.com/en-us/powershell/
|
||||
</details>
|
||||
|
||||
|
@ -139,10 +139,10 @@ Regular Expressions
|
||||
'Trevor' -match '^T\w*' # Perform a regular expression match against a string value. # Returns $true and populates $matches variable
|
||||
$matches[0] # Returns 'Trevor', based on the above match
|
||||
|
||||
@('Trevor', 'Billy', 'Bobby') -match '^B' # Perform a regular expression match against an array of string values. Returns Billy, Bobby
|
||||
@('Joe', 'Billy', 'Bobby') -match '^B' # Perform a regular expression match against an array of string values. Returns Billy, Bobby
|
||||
|
||||
$regex = [regex]'(\w{3,8})'
|
||||
$regex.Matches('Trevor Bobby Dillon Joe Jacob').Value # Find multiple matches against a singleton string value.
|
||||
$regex.Matches('Bobby Dillon Joe Jacob').Value # Find multiple matches against a singleton string value.
|
||||
```
|
||||
|
||||
|
||||
@ -209,8 +209,8 @@ Hashtables (Dictionary)
|
||||
-----------------------
|
||||
```
|
||||
$Person = @{
|
||||
FirstName = 'Markus'
|
||||
LastName = 'Fleschutz'
|
||||
FirstName = 'Joe'
|
||||
LastName = 'Doe'
|
||||
Likes = @(
|
||||
'Bacon',
|
||||
'Beer'
|
||||
@ -280,7 +280,7 @@ PowerShell Classes
|
||||
```
|
||||
class Person {
|
||||
[string] $FirstName # Define a class property as a string
|
||||
[string] $LastName = 'Sullivan' # Define a class property with a default value
|
||||
[string] $LastName = 'Doe' # Define a class property with a default value
|
||||
[int] $Age # Define a class property as an integer
|
||||
|
||||
Person() { # Add a default constructor (no input parameters) for a class
|
||||
@ -295,7 +295,7 @@ class Person {
|
||||
}
|
||||
}
|
||||
$Person01 = [Person]::new() # Instantiate a new Person object.
|
||||
$Person01.FirstName = 'Trevor' # Set the FirstName property on the Person object.
|
||||
$Person01.FirstName = 'Joe' # Set the FirstName property on the Person object.
|
||||
$Person01.FullName() # Call the FullName() method on the Person object. Returns 'Trevor Sullivan'
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user