Skip to content

aljazsim/powershell-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Useful PowerShell scripts

This is a collection of useful PowerShell scripts. In order to run the scripts from PowerShell make sure you have the appropriate execution policy set.

Publish a NuGet package

This script publishes a NuGet package to https://www.nuget.org/ for a .NET project.

Make sure you have the following applications installed:

.\publishNuGetPackage.ps1 -projectFilePath ".\Source\Project.csproj" -nugetPackageFilePath ".\Source\bin\Release\Project.1.0.5.nupkg" -nugetKey "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

Parameters:

  • -projectFilePath: the .NET project file path,
  • -nugetPackageFilePath: the file path of the NuGet package generated by msbuild,
  • -nugetKey: the NuGet authentication key.

Generate a unit test project code coverage

This script generates a unit test project code coverage for a .NET solution.

Make sure you have the following applications installed:

.\generateUnitTestCodeCoverage.ps1 -solutionFilePath "PathTo\Solution.sln" -unitTestDllFilePath "PathTo\ProjectUnitTest.dll" -openCoverConsole "PathTo\OpenCover.Console.exe" -reportGenerator "PathTo\ReportGenerator.exe"

Parameters:

  • -solutionFilePath: the path to your solution file,
  • -unitTestDllFilePath: the path to the compiled unit test dll,
  • -openCoverConsole: the path to open cover console can be found in your NuGet packages directory,
  • -reportGenerator: the path to the report generator can be found in your NuGet packages directory.

Resize an image

This script will resize the specified image.

Make sure you have the following applications installed:

.\resizeImage.ps1 -source ".\icon.png" -destination ".\resized\icon.png" -width 300

Parameters:

  • -source: the source file path,
  • -destination: the destination file path,
  • -width: the destination file width in pixels,
  • -height: the destination file height in pixels.

Either destination file width, height or both have to be specified.

If you want to resize an entire directory of image files, you can use this snippet:

Get-ChildItem "." -Filter "*.png" | ForEach-Object { .\resizeImage.ps1 -source $_.FullName -destination ".\resized\$($_.Name)" -width 300 }

Convert SVG image to PNG format

This script generates a PNG format icon from an SVG source file with the specified dimensions.

Make sure you have the following application installed:

.\convertSvgToPng.ps1 -source "icon.svg" -destination "icon.png" -width 300 -height 450

Parameters:

  • -source: the source file path in SVG format,
  • -destination: the destination file path in PNG format,
  • -width: the destination file width in pixels,
  • -height: the destination file height in pixels.

Either destination file width, height or both have to be specified.

If you want to convert an entire directory of SVG files to PNG files, you can use this snippet:

Get-ChildItem ".\svgs" -Filter "*.svg" | ForEach-Object { .\convertSvgToPng.ps1 -source $_.FullName -destination ".\pngs\$([System.IO.Path]::GetFileNameWithoutExtension($_.Name)).png" -width 300 }

Convert SVG image to ICO format

This script generates an ICO format icon from an SVG source file with different icon sizes embedded.

Make sure you have the following applications installed:

.\convertSvgToIco.ps1 -source "icon.svg" -destination "icon.ico"

Parameters:

  • -source: the source file path in SVG format,
  • -destination: the destination file path in ICO format.

If you want to convert an entire directory of SVG files to ICO files, you can use this snippet:

Get-ChildItem ".\svgs" -Filter "*.svg" | ForEach-Object { .\convertSvgToIco.ps1 -source $_.FullName -destination ".\icos\$([System.IO.Path]::GetFileNameWithoutExtension($_.Name)).ico" }

About

Useful PowerShell scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published