Skip to content

Instantly share code, notes, and snippets.

@codbugs
Last active April 2, 2022 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codbugs/d18b9b2d958c48d94f253535bb3896fe to your computer and use it in GitHub Desktop.
Save codbugs/d18b9b2d958c48d94f253535bb3896fe to your computer and use it in GitHub Desktop.
Los ficheros de este gist han sido creados con el objetivo de incluirlos en el artículo con título "Una forma fácil de pasar parámetros en tus scripts de PowerShell" en la plataforma Dev.To. The files in this gist have been created with the purpose of including them in the article titled "An easy way to provide parameters in your PowerShell scri…

Objetivo

Los ficheros de este gist han sido creados con el objetivo de incluirlos en el artículo con título "Una forma fácil de pasar parámetros en tus scripts de PowerShell" en la plataforma Dev.To.

Si quieres ver el artículo pincha en el siguiente enlace. Si quieres ver el listado de todos los artículos que he publicado pincha en el siguiente enlace.

Purpose

The files in this gist have been created with the purpose of including them in the article titled "An easy way to provide parameters in your PowerShell scripts" on the [Dev.To] (https://dev.to/) platform.

If you want to see the article click on the following link. If you want to see the list of all the articles I have published click on the following link.

param(
[Parameter(Mandatory=$true)]
[String] $Location,
[Parameter(Mandatory=$true)]
[String[]] $Extensions
)
$CmdParams = @{
Path = $Location
Filter = "*.*"
}
Return $Extensions
| Foreach {
$CurrentExtension = $_.ToLower() # Transform extension to lower case
$CmdParams.Filter = "*.$CurrentExtension" # Set the filter to the current extension
Return @{ $_ = $(Get-ChildItem @CmdParams | Measure).Count } # Return an object with the extension as the key and the count obtained as the value
}
param(
[Parameter(Mandatory=$true)]
[String] $Location,
[Parameter(Mandatory=$true)]
[String[]] $Extensions
)
$CmdParams = @{
Path = $Location
Filter = "*.*"
Recurse = $true
Depth = 1
}
Return $Extensions
| Foreach {
$CurrentExtension = $_.ToLower() # Transform extension to lower case
$CmdParams.Filter = "*.$CurrentExtension" # Set the filter to the current extension
Return @{ $_ = $(Get-ChildItem @CmdParams | Measure).Count } # Return an object with the extension as the key and the count obtained as the value
}
param(
[Parameter(Mandatory=$true)]
[String] $Location
)
Return @{
Html = $(Get-ChildItem -Path $Location -Filter *.html | Measure).Count
Css = $(Get-ChildItem -Path $Location -Filter *.css | Measure).Count
Js = $(Get-ChildItem -Path $Location -Filter *.js | Measure).Count
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment