Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a27dd09

Browse files
initial commit
1 parent b064e3d commit a27dd09

12 files changed

+644
-2
lines changed

‎.github/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 03 Sep 2019
4+
5+
- Initial release.

‎.github/CODE_OF_CONDUCT.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at tech@techthoughts.info. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html)
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq)

‎.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"powershell.codeFormatting.preset":"Stroustrup"
3+
}

‎LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Jake Morrison
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#____________________________________________________________
2+
# https://techthoughts.info/learn-and-use-powershell-with-just-three-commands/
3+
#____________________________________________________________
4+
# your first cmdlet - getting timezone information
5+
6+
Get-TimeZone
7+
#____________________________________________________________
8+
# Get-Command
9+
10+
Get-Command *
11+
# An asterisk (*) in many languages acts as a wildcard. This syntax is saying: get me ALL of the commands
12+
13+
Get-Command *process*
14+
# the wild cards around process will find ANY command that contains the word process
15+
16+
# Get-Command can't always find everything, you may have to Google
17+
Get-Command *file*
18+
#____________________________________________________________
19+
# Get-Help
20+
21+
# Windows Users:
22+
Get-Help Stop-Process
23+
#Linux/MacOs Users
24+
Get-Help Stop-Process -Online
25+
26+
Get-Help Stop-Process -Examples
27+
#____________________________________________________________
28+
# Get-Member
29+
30+
Get-Date | Get-Member
31+
32+
Get-Random | Get-Member
33+
#____________________________________________________________
34+
# Expand the available viewable properties of a cmdlet with Format-List
35+
36+
Get-Date | Format-List
37+
#____________________________________________________________
38+
# Find-Module
39+
40+
Find-Module -Tag Telegram
41+
#____________________________________________________________
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#____________________________________________________________
2+
# https://techthoughts.info/working-with-the-powershell-pipeline/
3+
#____________________________________________________________
4+
# the pipeline operator
5+
6+
Get-Process | Sort-Object Id
7+
#____________________________________________________________
8+
# In this example, every command found will be "piped" to Get-Help
9+
# This will run Get-Help against EVERY command found
10+
11+
Get-Command | Get-Help
12+
#____________________________________________________________
13+
# This example would restart the BITS service!
14+
15+
Get-Service -Name BITS | Restart-Service
16+
#____________________________________________________________
17+
# try running this command on your machine to see the results.
18+
# the WhatIf parameter will make Stop-Process take no actual action
19+
20+
Get-Process | Stop-Process -WhatIf
21+
#____________________________________________________________
22+
# PSItem
23+
# Get all processes. For each process (object) found,
24+
# display that object
25+
26+
Get-Process | ForEach-Object {$PSItem}
27+
28+
# In this simple example, we will display the current object
29+
# to the console
30+
1,2,3 | ForEach-Object {$PSItem}
31+
32+
# Spelling out $PSItem (not common)
33+
1,2,3 | ForEach-Object {$PSItem}
34+
# using $PSItem shorthand (common)
35+
1,2,3 | ForEach-Object {$_}
36+
#____________________________________________________________
37+
# Format-List & Format-Table
38+
39+
# Note the way things look using Format-Table
40+
Get-Process | Format-Table
41+
# Now see how that differs if you pipe instead to Format-List
42+
Get-Process | Format-List
43+
44+
# Note the return from just Get-Date
45+
Get-Date
46+
# Now see how the whole object is returned if you pipe to Format-List
47+
Get-Date | Format-List
48+
49+
# basic information about the notepad process
50+
Get-Process notepad
51+
# more information about the notepad process
52+
Get-Process notepad | Format-List
53+
# all available information about the notepad process
54+
Get-Process notepad | Format-List
55+
#____________________________________________________________
56+
# Select-Object
57+
58+
# Using Select-Object you can retrieve only the properties you are after
59+
Get-Process | Select-Object Name,Id,CPU,Responding
60+
#____________________________________________________________
61+
# Sort-Object
62+
63+
# This example pipes all processes to Sort-Object which sorts by CPU use
64+
# Use to quickly identify your busiest processes. Very handy!
65+
Get-Process | Sort-Object CPU
66+
67+
# You can combine multiple pipelines together as well
68+
Get-Process | Select-Object Name,Id,CPU,Responding | Sort-Object CPU
69+
#____________________________________________________________
70+
# Where-Object
71+
72+
# Get Processes, return only those where current object $_ is greater than 15
73+
Get-Process | Where-Object {$_.CPU -gt 15}
74+
75+
# Get file information for all files found in the $HOME directory
76+
# Return information for only files that are greater than 5MB in size
77+
Get-ChildItem $HOME -Recurse | Where-Object {$_.Length -gt 5MB}
78+
79+
# Count the number of large file in your $HOME directory
80+
Get-ChildItem $HOME -Recurse | Where-Object {$_.Length -gt 50MB} | Measure-Object
81+
#____________________________________________________________
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#____________________________________________________________
2+
# https://techthoughts.info/powershell-history-and-current-state/
3+
#____________________________________________________________
4+
# determine what version of PowerShell you are running with the following:
5+
$PSVersionTable
6+
# The PSVersion number is the version. you can get it specifically like this:
7+
$PSVersionTable.PSVersion
8+
#____________________________________________________________
9+
# in a 5.1 window count the number of cmdlets:
10+
Get-Command | Measure-Object
11+
# now try the same thing in a 6+ console window
12+
Get-Command | Measure-Object
13+
#____________________________________________________________
14+
# in a 6+ console window run the following:
15+
Install-Module WindowsCompatibility -Scope CurrentUser
16+
#____________________________________________________________
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#____________________________________________________________
2+
# https://techthoughts.info/getting-setup-powershell-development/
3+
#____________________________________________________________
4+
code --list-extensions
5+
code --install-extension ms-vscode.PowerShell
6+
7+
# PowerShell base VSCode settings:
8+
<#
9+
{
10+
// editor
11+
"editor.quickSuggestionsDelay": 1,
12+
"editor.tabCompletion": "on",
13+
"files.defaultLanguage": "powershell",
14+
15+
// default shell
16+
// Windows
17+
// PowerShell 6
18+
"terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\6円\\pwsh.exe",
19+
"powershell.powerShellExePath": "C:\\Program Files\\PowerShell\6円\\pwsh.exe",
20+
//PowerShell 5.1 and below
21+
// "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
22+
// "powershell.powerShellExePath": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
23+
// Linux
24+
// Ubuntu
25+
// "terminal.integrated.shell.linux": "/snap/powershell/36/opt/powershell/pwsh",
26+
// "powershell.powerShellExePath": "/snap/powershell/36/opt/powershell/pwsh",
27+
28+
// powershell settings changes
29+
"powershell.codeFormatting.preset":"Stroustrup",
30+
"powershell.startAutomatically": true,
31+
"powershell.scriptAnalysis.enable": true,
32+
"powershell.integratedConsole.showOnStartup": false,
33+
"powershell.integratedConsole.focusConsoleOnExecute": true,
34+
}
35+
#>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#____________________________________________________________
2+
# https://techthoughts.info/working-with-powershell-variables/
3+
#____________________________________________________________
4+
#https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_variables?view=powershell-6
5+
#https://docs.microsoft.com/en-us/powershell/scripting/learn/using-variables-to-store-objects?view=powershell-6
6+
#____________________________________________________________
7+
Get-Process
8+
$processes = Get-Process
9+
$processes
10+
#----------------------------------------
11+
# not using variable
12+
Get-Process | Where-Object {$_.CPU -gt 5000} #find processes keeping the CPU busy
13+
Get-Process | Sort-Object WorkingSet64 -Descending #sort processes by memory usage
14+
#----------------------------------------
15+
# using variable
16+
$processes = Get-Process
17+
$processes | Where-Object {$_.CPU -gt 5000} #find processes keeping the CPU busy
18+
$processes | Sort-Object WorkingSet64 -Descending #sort processes by memory usage
19+
#----------------------------------------
20+
# not strong typed
21+
$myNewVariable
22+
23+
# data types
24+
#----------------------------------------
25+
$total = 2 + 2
26+
$total
27+
$total | Get-Member
28+
#----------------------------------------
29+
$total = '2 + 2'
30+
$total
31+
$total | Get-Member
32+
#____________________________________________________________
33+
# understanding data types
34+
35+
$num1 = 2
36+
$num2 = 2
37+
$total = $num1 + $num2
38+
$total
39+
#----------------------------------------
40+
$num1 = '2'
41+
$num2 = '2'
42+
$total = $num1 + $num2
43+
$total
44+
#----------------------------------------
45+
46+
#strong type
47+
#----------------------------------------
48+
[int]$num1 = '2'
49+
[int]$num2 = '2'
50+
$total = $num1 + $num2
51+
#----------------------------------------
52+
53+
#convert
54+
#----------------------------------------
55+
$stringReturn = $total.ToString()
56+
$total | Get-Member
57+
#----------------------------------------
58+
59+
#quotes
60+
$literal = 'Two plus one equals: $(1 + 2)'
61+
$literal
62+
$escaped = "Two plus one equals: $(1 + 2)"
63+
$escaped
64+
Write-Host '$escaped'
65+
Write-Host "$escaped"
66+
67+
#constant variables are reserved
68+
Get-Variable
69+
# you can't use these
70+
$HOME = 'c:\test'
71+
72+
#environment variables
73+
Get-ChildItem env:
74+
$env:COMPUTERNAME
75+
$env:USERNAME
76+
77+
#putting it all together with an example
78+
$path = Read-Host -Prompt 'Please enter the file path you wish to scan for large files...'
79+
$rawFileData = Get-ChildItem -Path $path -Recurse
80+
$largeFiles = $rawFileData | Where-Object {$_.Length -gt 100MB}
81+
$largeFilesCount = $largeFiles | Measure-Object | Select-Object -ExpandProperty Count
82+
Write-Host "You have $largeFilesCount large file(s) in $path"
83+
#____________________________________________________________

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /