180 lines
9.5 KiB
Markdown
180 lines
9.5 KiB
Markdown
|
||
|
||
|
||
|
||
```powershell
|
||
❯ 'Hello World' | Get-Member
|
||
|
||
|
||
|
||
TypeName: System.String
|
||
|
||
Name MemberType Definition
|
||
|
||
---- ---------- ----------
|
||
|
||
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
|
||
CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB), int IComparable.CompareTo(System.Object obj), int IComparable[string].CompareTo(strin…
|
||
Contains Method bool Contains(string value), bool Contains(string value, System.StringComparison comparisonType), bool Contains(char value), bool Contains(char value…
|
||
CopyTo Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
|
||
EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.StringComparison comparisonType), bool EndsWith(string value, bool ignoreCase, cultur…
|
||
EnumerateRunes Method System.Text.StringRuneEnumerator EnumerateRunes()
|
||
Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals(string value, System.StringComparison comparisonType), bool IEquatable[string]…
|
||
GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumerable.GetEnumerator(), System.Collections.Generic.IEnumerator[char] IEnum…
|
||
GetHashCode Method int GetHashCode(), int GetHashCode(System.StringComparison comparisonType)
|
||
GetPinnableReference Method System.Char&, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e GetPinnableReference()
|
||
GetType Method type GetType()
|
||
.../...
|
||
```
|
||
|
||
|
||
|
||
```powershell
|
||
❯ 'Hello World'.ToLower()
|
||
hello world
|
||
```
|
||
|
||
|
||
|
||
|
||
|
||
```powershell
|
||
❯ ping google.com
|
||
PING google.com (216.58.215.46): 56 data bytes
|
||
64 bytes from 216.58.215.46: icmp_seq=0 ttl=112 time=60.009 ms
|
||
64 bytes from 216.58.215.46: icmp_seq=1 ttl=112 time=156.384 ms
|
||
Request timeout for icmp_seq 2
|
||
64 bytes from 216.58.215.46: icmp_seq=3 ttl=112 time=131.664 ms
|
||
64 bytes from 216.58.215.46: icmp_seq=4 ttl=112 time=143.645 ms
|
||
64 bytes from 216.58.215.46: icmp_seq=5 ttl=112 time=77.214 ms
|
||
64 bytes from 216.58.215.46: icmp_seq=6 ttl=112 time=64.536 ms
|
||
64 bytes from 216.58.215.46: icmp_seq=7 ttl=112 time=64.478 ms
|
||
64 bytes from 216.58.215.46: icmp_seq=8 ttl=112 time=67.211 ms
|
||
64 bytes from 216.58.215.46: icmp_seq=9 ttl=112 time=62.654 ms
|
||
64 bytes from 216.58.215.46: icmp_seq=10 ttl=112 time=73.045 ms
|
||
^C
|
||
--- google.com ping statistics ---
|
||
11 packets transmitted, 10 packets received, 9.1% packet loss
|
||
round-trip min/avg/max/stddev = 60.009/90.084/156.384/35.969 ms
|
||
```
|
||
|
||
|
||
|
||
```powershell
|
||
❯ Test-Connection google.com
|
||
|
||
|
||
Destination: google.com
|
||
|
||
Ping Source Address Latency BufferSize Status
|
||
(ms) (B)
|
||
|
||
---- ------ ------- ------- ---------- ------
|
||
|
||
1 SilverBook.local 216.58.215.46 77 32 Success
|
||
2 SilverBook.local 216.58.215.46 56 32 Success
|
||
3 SilverBook.local 216.58.215.46 75 32 Success
|
||
4 SilverBook.local 216.58.215.46 67 32 Success
|
||
```
|
||
|
||
|
||
|
||
|
||
|
||
```powershell
|
||
❯ Get-Help Test-Connection
|
||
|
||
NAME
|
||
Test-Connection
|
||
|
||
SYNTAX
|
||
Test-Connection [-TargetName] <string[]> [-Ping] [-IPv4] [-IPv6] [-ResolveDestination] [-Source <string>] [-MaxHops <int>] [-Count <int>] [-Delay <int>] [-BufferSize <int>] [-DontFragment] [-TimeoutSeconds <int>] [-Quiet] [<CommonParameters>]
|
||
|
||
Test-Connection [-TargetName] <string[]> -Traceroute [-IPv4] [-IPv6] [-ResolveDestination] [-Source <string>] [-MaxHops <int>] [-TimeoutSeconds <int>] [-Quiet] [<CommonParameters>]
|
||
|
||
Test-Connection [-TargetName] <string[]> -MtuSize [-IPv4] [-IPv6] [-ResolveDestination] [-TimeoutSeconds <int>] [-Quiet] [<CommonParameters>]
|
||
|
||
Test-Connection [-TargetName] <string[]> -TcpPort <int> [-IPv4] [-IPv6] [-ResolveDestination] [-Source <string>] [-TimeoutSeconds <int>] [-Quiet] [<CommonParameters>]
|
||
```
|
||
|
||
|
||
```powershell
|
||
❯ [System.Collections.ArrayList]$testArray = @()
|
||
|
||
❯ $testArray.Add('yahoo.com') | Out-Null
|
||
❯ $testArray.Add('google.com') | Out-Null
|
||
|
||
❯ $testArray
|
||
google.com
|
||
yahoo.com
|
||
|
||
❯ Test-Connection -ComputerName $testArray
|
||
|
||
|
||
Destination: google.com
|
||
|
||
Ping Source Address Latency BufferSize Status
|
||
(ms) (B)
|
||
---- ------ ------- ------- ---------- ------
|
||
1 SilverBook.local 172.217.18.206 3969 32 Success
|
||
2 SilverBook.local 172.217.18.206 60 32 Success
|
||
3 SilverBook.local 172.217.18.206 82 32 Success
|
||
4 SilverBook.local 172.217.18.206 62 32 Success
|
||
|
||
Destination: yahoo.com
|
||
|
||
Ping Source Address Latency BufferSize Status
|
||
(ms) (B)
|
||
---- ------ ------- ------- ---------- ------
|
||
1 SilverBook.local 98.138.219.231 2068 32 Success
|
||
2 SilverBook.local 98.138.219.231 208 32 Success
|
||
3 SilverBook.local 98.138.219.231 312 32 Success
|
||
4 SilverBook.local 98.138.219.231 204 32 Success
|
||
|
||
```
|
||
|
||
|
||
|
||
Comparer 2 fichiers texte:
|
||
|
||
```powershell
|
||
❯ compare-object (get-content one.txt) (get-content two.txt)
|
||
```
|
||
|
||
|
||
|
||
Bash <-> PowerShell:
|
||
|
||
| Bash | PowerShell | Alias |
|
||
| ----------------------------- | ------------------------------------------------------------ | ---------------------- |
|
||
| pwd | Get-Location | pwd, gl |
|
||
| cd | Set-Location | cd, sl, chdir |
|
||
| ls | Get-ChildItem | ls, dir |
|
||
| ls -ltr | Get-ChildItem $env:USERPROFILE\Desktop \| Sort-Object -Property LastWriteTime | |
|
||
| find | Get-ChildItem | |
|
||
| find . -type f -iname "azure" | Get-ChildItem -Filter "\*azure\*" -Recurse -File | |
|
||
| cp | Copy-Item | cp, copy, cpi |
|
||
| cp -R Tools ~/ | Copy-Item -Path '.\Tools\' -Destination $env:USERPROFILE -Recurse | |
|
||
| | Copy-Item '.\Tools\' $env:USERPROFILE -Recurse | |
|
||
| rm | Remove-Item | rm, ri, rmdir, rd, del |
|
||
| rm -rf | Remove-Item -Recurse -Force | |
|
||
| mkdir | New-Item -ItemType Directory -Name 'MyNewFolder' | |
|
||
| touch | New-Item | |
|
||
| touch newFile{1..3} | 1..3 \| ForEach-Object { New-Item -ItemType File -Name "newFile$_" } | |
|
||
| cat | Get-Content | cat, gc, type |
|
||
| tail -n7 ./MyFile1 | Get-Content -Tail 7 .\MyFile1 | |
|
||
| tail -f ./log1 | Get-Content -Wait .\log1 | |
|
||
| uname -a | \$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture'<br /> Get-CimInstance Win32_OperatingSystem \| Select-Object $Properties \| Format-Table -AutoSize | |
|
||
| ping | Test-Connection | |
|
||
| | Test-Connection google.com \| Format-Table -AutoSize | |
|
||
| man | Get-Help | |
|
||
| | Get-Help Stop-Service -Full | |
|
||
| cut | Get-ChildItem $env:USERPROFILE\Desktop -Filter "*.ps1" \| >> Select-Object -Property 'Name', 'Length' | |
|
||
| | | |
|
||
| | | |
|
||
| | | |
|
||
| | | |
|
||
| | | |
|
||
| | | |
|
||
|