Powershell Super basics
satya - 6/15/2024, 10:31:48 AM
Comments
<#
This script calculates the sum of numbers from 1 to 10.
It uses a for loop to iterate through the numbers and
accumulates the total in a counter variable.
#>
# Initialize variable
$counter = 0
# Loop through numbers 1 to 10
for ($i = 1; $i -le 10; $i++) {
$counter += $i
}
# Output the result
Write-Output $counter
satya - 6/15/2024, 10:33:12 AM
Use this github for some sample code
satya - 6/15/2024, 10:34:04 AM
I tend to use these some more comments
#*******************************************************
# Config Functions
#*******************************************************
satya - 6/15/2024, 10:38:04 AM
Line comments
# Initialize variable
$counter = 0
# Loop through numbers 1 to 10
for ($i = 1; $i -le 10; $i++) {
$counter += $i # Add current number to counter
}
# Output the result
Write-Output $counter
satya - 6/15/2024, 12:50:35 PM
update-help command
update-help
# make sure to run powershell in admin mode
satya - 6/15/2024, 12:52:45 PM
update-help
- without this get-help shows only basic help
- This will include:
- examples
- broader description
- online help
- technical info etc.
- Note: It seem to fail for some modules, even when I run it as an admin