Batch Script

From BC$ MobileTV Wiki
(Redirected from PowerShell)
Jump to: navigation, search

A Batch Script is a piece of system-level program logic which can control specific system functions via a command prompt (most commonly Batch is supported in Windows server environments but may be ported to others).


PowerShell

[1] [2] [3]

[4]

[5]

[6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

[16] [17] [18] [19] [20]

[21]

[22]

[25] [26] [27]

[28] [29] [30] [31] [32] [33] [34] [35] [36]


[44]

[45] [46] [47]

[48]


Windows Terminal

Supports PowerShell, standard DOS-style "command prompt", and others; all with multi-tab support for managing several terminal windows at once.

[49] [50] [51]


Commands

To pass a specific command-line input parameter from a Batch script to a called program within it, use:

%1 %2 %3 ... %15

For the first, second, third and fifteenth parameter (etc).

To pass through all command-line input parameters from a Batch script to a called program within it, use:

%*

[52]




Resources


Tutorials


External Links

References

  1. Microsoft dev docs -- PowerShell - Start-Process: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7.1
  2. Programmatically Opening Windows Terminal in a Specific Folder: https://weblog.west-wind.com/posts/2019/Sep/03/Programmatically-Opening-Windows-Terminal-in-a-Specific-Folder
  3. What is the best way for communication between Powershell script and Windows service?: https://stackoverflow.com/questions/41017341/what-is-the-best-way-for-communication-between-powershell-script-and-windows-ser
  4. PowerTip - Open Windows Explorer to a Location: https://devblogs.microsoft.com/scripting/powertip-open-windows-explorer-to-a-location/
  5. PowerTip - Use PowerShell to Create New File: https://devblogs.microsoft.com/scripting/powertip-use-powershell-to-create-new-file/
  6. Everything you wanted to know about the if statement: https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-if?view=powershell-7.1
  7. Powershell - If Else Statement: https://www.tutorialspoint.com/powershell/if_else_statement_in_powershell.htm
  8. Check if a string is NULL or EMPTY using PowerShell: https://techibee.com/powershell/check-if-a-string-is-null-or-empty-using-powershell/1889
  9. How to use If-ElseIf-Else in PowerShell: https://teckangaroo.com/how-to-use-else-if-in-powershell/
  10. PowerShell - What is the best way to check whether the current user has permission to overwrite a file in PowerShell?: https://stackoverflow.com/questions/22943289/powershell-what-is-the-best-way-to-check-whether-the-current-user-has-permissio
  11. How to declare a variable and its type is Boolean in PowerShell?: https://stackoverflow.com/questions/54721256/how-to-declare-a-variable-and-its-type-is-boolean-in-powershell
  12. Understanding Booleans in PowerShell: https://social.technet.microsoft.com/wiki/contents/articles/2286.understanding-booleans-in-powershell.aspx
  13. Boolean Values and Operators: https://devblogs.microsoft.com/powershell/boolean-values-and-operators/
  14. Powershell – If -And' & If -Or Statements: https://www.heelpbook.net/2019/powershell-if-and-if-or-statements/
  15. Introduction to PowerShell If-Not: https://www.educba.com/powershell-if-not/
  16. PowerShell if-then Latest examples 2020: https://teckangaroo.com/how-to-use-if-then-in-powershell/
  17. Back to Basics -- The PowerShell For Loop: https://adamtheautomator.com/powershell-for-loop/
  18. Powershell For Loop Explained -- syntax & examples: https://www.itechguides.com/powershell-for-loop-explained-syntax-and-examples/
  19. PowerShell Basics -Contains, -CContains & -NotContains Conditional Operators: https://www.computerperformance.co.uk/powershell/contains/
  20. More Powerful Batch Files Part I - Branching and Looping: http://commandwindows.com/batchfiles-branching.htm
  21. Working with Values and Variables in PowerShell: https://mcpmag.com/articles/2012/10/02/pshell-values-variables.aspx
  22. Create a File If Not Exists via PowerShell: https://morgantechspace.com/2015/06/powershell-create-file-if-not-exists.html
  23. Return line number from string match: https://stackoverflow.com/questions/34664231/return-line-number-from-string-match
  24. PowerShell: Searching Through Files for Matching Strings: https://www.pdq.com/blog/powershell-searching-through-files-for-matching-strings/
  25. Find files which does not contains selected string: https://stackoverflow.com/questions/17945514/find-files-which-does-not-contains-selected-string
  26. Powershell (how to check whether) "string does not contain" some value: https://stackoverflow.com/questions/27970441/powershell-string-does-not-contain
  27. Microsoft dev docs -- PowerShell - About Try Catch Finally: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_try_catch_finally
  28. PowerTip: Use PowerShell to Find Folders that Match Pattern: https://devblogs.microsoft.com/scripting/powertip-use-powershell-to-find-folders-that-match-pattern/
  29. Get-ChildItem - List files with the matched string pattern ?: https://social.technet.microsoft.com/Forums/en-US/617c4f1c-786e-45a8-85e0-d9680bd470af/getchilditem-list-files-with-the-matched-string-pattern-
  30. Find Files That Match a Pattern: http://powershellcookbook.com/recipe/lvCW/find-files-that-match-a-pattern
  31. Grep for Windows – findstr example: https://mkyong.com/linux/grep-for-windows-findstr-example/
  32. "find" command: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find
  33. How to execute find command with Powershell: https://stackoverflow.com/questions/37639919/how-to-execute-find-command-with-powershell
  34. Why can “find” not be used in PowerShell?: https://superuser.com/questions/1208964/why-can-find-not-be-used-in-powershell
  35. EXAMPLE command to find a specific pattern recursively in all sub-folders under a specific path (Get-ChildItem -Path 'C:\APPS\AEM\author\crx-quickstart\launchpad\felix' -Force -Recurse -ErrorAction 'SilentlyContinue' -Filter "classes").FullName
  36. Find PowerShell Commands by Using the Get-Command Cmdlet: https://devblogs.microsoft.com/scripting/find-powershell-commands-by-using-the-get-command-cmdlet/
  37. How to insert a newline before adding content with add-content: https://social.technet.microsoft.com/Forums/sharepoint/en-US/caa9c4ef-40cd-444e-ab4b-c1ca674361c0/how-to-insert-a-newline-before-adding-content-with-addcontent?forum=winserverpowershell
  38. Writing new lines to a text file in PowerShell: https://stackoverflow.com/questions/17434151/writing-new-lines-to-a-text-file-in-powershell
  39. PowerTip - New Lines with PowerShell: https://blogs.technet.microsoft.com/heyscriptingguy/2014/09/07/powertip-new-lines-with-powershell/
  40. How to - Out file to New Line in Text File: https://community.spiceworks.com/topic/2002837-how-to-out-file-to-new-line-in-text-file
  41. Convert String to 24 Hour time format in powershell: https://stackoverflow.com/questions/12162702/convert-string-to-24-hour-time-format-in-powershell
  42. Standard DateTime Format patterns:: https://ss64.com/ps/syntax-dateformats.html
  43. PowerShell: Parsing Date and Time: http://dusan.kuzmanovic.net/2012/05/07/powershell-parsing-date-and-time/
  44. PowerShell parsing JSON: https://stackoverflow.com/questions/45945944/powershell-parsing-json (more readable/reusable script example)
  45. PowerShell Basics -- Environment Variables -$Env: (examples & scripts): https://www.computerperformance.co.uk/powershell/environmental-variables/
  46. Speed Up Array Comparisons in Powershell with a Runtime Regex: https://devblogs.microsoft.com/scripting/speed-up-array-comparisons-in-powershell-with-a-runtime-regex/
  47. Microsoft dev docs -- Powershell - Everything you wanted to know about array: https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-arrays?view=powershell-7.1
  48. PowerTip - Prompt for Input for PowerShell Script: https://devblogs.microsoft.com/scripting/powertip-prompt-for-input-for-powershell-script/
  49. Windows Terminal Tips and Tricks: https://devblogs.microsoft.com/commandline/windows-terminal-tips-and-tricks/
  50. Set up Powerline in Windows Terminal: https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup
  51. Cascadia Code 2009.22: https://github.com/microsoft/cascadia-code/releases (better look & feel font to be used with Consoles)
  52. Is there a way to indicate the last n parameters in a batch file?: http://stackoverflow.com/questions/761615/is-there-a-way-to-indicate-the-last-n-parameters-in-a-batch-file
  53. http://stackoverflow.com/questions/12606609/autorun-inf-doesnt-work
  54. Tips for using DIR: http://www.robvanderwoude.com/dir.php
  55. Run batch scripts on a remote server (windows) from jenkins: https://stackoverflow.com/questions/22553588/run-batch-scripts-on-a-remote-server-windows-from-jenkins
  56. How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?: https://stackoverflow.com/questions/203090/how-do-i-get-current-date-time-on-the-windows-command-line-in-a-suitable-format
  57. How to get a UNIVERSAL Windows batch file timestamp: https://stackoverflow.com/questions/1747468/how-to-get-a-universal-windows-batch-file-timestamp

See Also

Shell Script | Windows | DOS