Skip to content

Latest commit

 

History

History
106 lines (77 loc) · 3.76 KB

README.md

File metadata and controls

106 lines (77 loc) · 3.76 KB

Powershell Utilities

Unit tests Linting

Adding it to the PowerShell profile

You can add these scripts to your PowerShell profile to make them easier for use.

Note

Note that for PowerShell Core and PowerShell Windows, there are different profile files

Example:

# open the configuration file for your PowerShell

> code $profile
# inside Microsoft.Powershell_profile.ps1 file

function RunWhere($command) {
    (Get-Command $command).Path
}

Set-Alias -Name "whereis" -Value RunWhere

Note

To learn more about how you can configure your powershell profiles, take a look at about_Profiles

🐍 Scripts

  • Time.ps1 - Short function that works like time on Unix
# Example: 
> ./Time.ps1 # execute the script
> time dotnet run # use the function to measure the time of a certain command
# Example: 
> ./WhereIs.ps1 # Execute the script
> whereis php
C:\tools\php74\php.exe
# Example: 
> ./GetStringBetweenByIndex.ps1 -Value "Hello World" -Start "He" -End "ld"
ello Wor
# Example: 
> ./ConvertGitLogToJson.ps1 -NumberOfCommits 1
[
  {
    "commit": "f9f320eeea4c4329896a785f083c04279526064f",
    "tree": "4841da995b423e1d748ccfd908976070e435f254",  
    "parent": "f78937b304446b504a0ad9ea101d995193431528",
    "refs": "HEAD -> main, origin/main, origin/HEAD",    
    "subject": "Update README.md",
    "body": "",
    "author": "Fabrício Pinto Ferreira",
    "commiter": "GitHub"
  }
]
# Example: 
> ./GetIfStringIsInArray.ps1 -ArraySet @('work', 'paper') -StringToVerify "I work in a paper company"
True

🎹 Commands