Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
powershell_examples [2022/06/25 17:17] – [Basic script with parameters] mguptonpowershell_examples [2023/01/30 13:48] (current) mgupton
Line 1: Line 1:
 ====== Powershell Examples ====== ====== Powershell Examples ======
 +  * code snippets
 +
 +
   * [[https://gist.github.com/9to5IT/dbc91fea726c113fad6c|Basic Template (w/ logging)]]   * [[https://gist.github.com/9to5IT/dbc91fea726c113fad6c|Basic Template (w/ logging)]]
 +  * [[https://learn.microsoft.com/en-us/powershell/scripting/developer/help/examples-of-comment-based-help?view=powershell-7.2|Comment-based Help]]
  
  
Line 45: Line 49:
 main main
 </code> </code>
 +
 +====== Loop Over Files ======
 +=== Example of looping over files and doing something with them ===
 +<code powershell>
 +param(
 +    [Parameter(Mandatory=$true)] [String]$dir
 +)
 +
 +foreach ($file in Get-ChildItem -File $dir) {
 +    jq -s -f .\filter.jq $dir\$file
 +}
 +</code>
 +
  
  • powershell_examples.1656177421.txt.gz
  • Last modified: 2022/06/25 17:17
  • by mgupton