GithubHelp home page GithubHelp logo

jimbrig / psscripts Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 348 KB

PowerShell Scripts Published to the Gallery.

Home Page: https://www.powershellgallery.com/profiles/jimbrig

License: The Unlicense

PowerShell 100.00%
helpers-library personal powershell powershell-library powershell-script published scripts-collection system utility-library windows

psscripts's Introduction

Custom PowerShell Scripts


Note
Collection of PowerShell Scripts published to my Powershell Gallery Profile.

Contents

Overview

Note View the Repository's CHANGELOG for the latest updates and changes made over time

This repository contains a collection of PowerShell scripts that I have written for various purposes and published to my Powershell Gallery Profile.

Installation

Bulk Installation

To install all scripts at once use the Install-PSCustomScripts.ps1 script:

Install-Script -Name Install-PSCustomScripts.ps1

Install-PSCustomScripts

Individual Script Installation

To install any individual script listed in this repository, you can use the Install-Script cmdlet from the PowerShellGet module.

Install-Script -Name <script-name>

Clone Locally

Lastly, one can simply clone or download the scripts for use locally:

# SSH
git clone [email protected]:jimbrig/PSScripts.git

# HTTPS
https://github.com/jimbrig/PSScripts.git

# Github-CLI
gh repo clone jimbrig/PSScripts

Roadmap

  • Get-FileHash - Calculates the hash of a file using the specified algorithm.

Scripts

This script converts a string to Markdown.

This script reads an encrypted secret from the user.

Sets the icon for a folder:

Update all modules at once:

Appendices

License

This project is licensed under the Unlicense. See the LICENSE file for details.

Versioning

I use Semantic Versioning for versioning all the scripts.

Acknowledgments

Hat tip to anyone whose code was used:

Contact

psscripts's People

Contributors

github-actions[bot] avatar jimbrig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

psscripts's Issues

Feature: Add `Remove-OldDrivers` Script

<#PSScriptInfo

.VERSION 1.0

.GUID 373d0e75-bee5-4ebe-8dbf-c476e96d5fe1

.AUTHOR jimmy

.COMPANYNAME

.COPYRIGHT

.TAGS

.LICENSEURI

.PROJECTURI

.ICONURI

.EXTERNALMODULEDEPENDENCIES 

.REQUIREDSCRIPTS

.EXTERNALSCRIPTDEPENDENCIES

.RELEASENOTES


.PRIVATEDATA

#>

<# 

.DESCRIPTION 
 Delete unused drivers 

#> 
Param(
    [Parameter()]
    [switch]$WhatIf
)

$ErrorActionPreference = "Stop"

$Drivers = Get-WindowsDriver -Online -All | Where-Object -FilterScript {$_.Driver -like 'oem*inf'} | Select-Object -Property Driver, ClassDescription, ProviderName, Date, Version

$OriginalFileName = @{
	Name = "OriginalFileName"
	Expression = {$_.OriginalFileName | Split-Path -Leaf}
}
$Date = @{
	Name = "Date"
	Expression = {$_.Date.Tostring().Split("")[0]}
}
$AllDrivers = Get-WindowsDriver -Online -All | Where-Object -FilterScript {$_.Driver -like 'oem*inf'} | Select-Object -Property $OriginalFileName, Driver, ClassDescription, ProviderName, $Date, Version

Write-Verbose "`nAll installed third-party drivers" -Verbose
($AllDrivers | Sort-Object -Property ClassDescription | Format-Table -AutoSize -Wrap | Out-String).Trim()
$DriverGroups = $AllDrivers | Group-Object -Property OriginalFileName | Where-Object -FilterScript {$_.Count -gt 1}

Write-Verbose "`nDuplicate drivers" -Verbose
($DriverGroups | ForEach-Object -Process {$_.Group | Sort-Object -Property Date -Descending | Select-Object -Skip 1} | Format-Table | Out-String).Trim()
$DriversToRemove = $DriverGroups | ForEach-Object -Process {$_.Group | Sort-Object -Property Date -Descending | Select-Object -Skip 1}

Write-Verbose "`nDrivers to remove" -Verbose
($DriversToRemove | Sort-Object -Property ClassDescription | Format-Table | Out-String).Trim()

If ($WhatIf)
{
    Write-Verbose "`nWhatIf switch is set. No drivers will be removed" -Verbose
    Exit
} else {
    Write-Verbose "`nWhatIf switch is not set. Drivers will be removed" -Verbose
    ForEach ($item in $DriversToRemove) {
	$Name = $($item.Driver).Trim()
	& pnputil.exe /delete-driver "$Name" /force
    }
}

Refactor: Refactor Project Structure

Would like to structure the project like so:

  • <root>\
    • README.md
    • CHANGELOG.md
    • PSScripts.build.ps1
    • tools\
      • README.md
      • PSScripts.Tools.psm1 (Module for housing automation and build functions)
      • ScriptCertificates\
        • Certificate.pfx
        • Certificate.pem
    • Scripts\
      • README.md
      • scripts.json
      • <ScriptName>\
        • README.md
        • <ScriptName>.ps1
        • .script-version
        • build\
          • <ScriptName>.<ScriptVersion>.nupkg
        • utils\
          • <Utility Helpers for the Script to Dot Source>
          • <MyUtils>.ps1

Unimplemented `Recurse` option in Set-FolderIcon.ps1

Looks like the Recurse parameter to set an icon on all sub-folders wasn't implemented in the Set-FolderIcon script.
I would really appreciate if you added this feature, it's exactly what I'm trying to accomplish!

Feature: New Script for `Add-GitAttributes`

Adds .gitattributes to working directory/project:

# PSGitIgnore Module

# This module is used to create a .gitignore file for a project.

Function Add-GitAttributes {
  <#
  .SYNOPSIS
    Adds a .gitignore file to the current directory.
  .DESCRIPTION
    Adds a .gitattributes file to the current directory by invoking the GitHub API 
    from the repo: alexkaratarakis/gitattributes. If no list is provided, the 
    default is `Common`.
  .PARAMETER List
    (Optional) The list of items or languages to add to the .gitignore file 
    (comma-separated). By default, this is just `Common`.

    The list of items can be found at <https://github.com/alexkaratarakis/gitattributes>.
  .PARAMETER Path
    (Optional) The path to the `.gitignore` file. By default, this is just 
    `.gitattributes` in the current directory.
  .EXAMPLE
    Add-GitAttributes -List "Common,PowerShell"

    Adds the `Common` and `PowerShell` items to the `.gitattributes` file.
  .EXAMPLE
    Add-GitAttributes -List @("R", "Markdown", "Python") -Path "C:\Temp\.gitattributes"

    Adds attributes for R, Markdown, and Python to the `.gitattributes`
    file located at `C:\Temp\.gitattributes`.
  #>
  [CmdletBinding()]
  [Alias("gitattributes")]
  Param (
    [Parameter(
      Mandatory = $false,
      ValueFromPipeline = $true,
      HelpMessage = "The list of items or languages to add to the .gitattributes file."
    )][string[]]$List = @("Common"),
    
    [Parameter(
      Mandatory = $false,
      HelpMessage = "The path to the .gitattributes file."
    )][string]$Path = $(Join-Path -path $PWD -ChildPath ".gitattributes") 
  )


  If(-not (Test-Path -Path $Path)) {
    New-Item -Path $Path -ItemType File -Force
    Set-Content -Path $Path -Value ""
  }

  $BaseURI = "https://raw.githubusercontent.com/alexkaratarakis/gitattributes/master/"
  $URIs = $List | ForEach-Object { "$BaseURI$_.gitattributes" }

  ForEach ($URI in $URIs) {
    $Content = ""
    Write-Verbose "Retrieving .gitattributes from $URI..."
    try {
      $Content = (Invoke-WebRequest -Uri $URI).Content + "`n" + "`n"
    } catch {
      Write-Error "Unable to retrieve .gitattributes file from $URI."
    }

    If ($Content -ne "") {
      Add-Content -Path $Path -Value $Content
    }
    Write-Verbose "Added/Appended Items for $URI to $Path"
  }  
  
  $listSep = ($List -join ', ')
  Write-Verbose "Added/Appended Items for $listSep to $Path"
  
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.