Giter Site home page Giter Site logo

brandonmcclure / friendly-chainsaw Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 3.0 695 KB

friendly-chainsaw is a collection of PowerShell functions that I use as part of my daily life

PowerShell 99.10% Dockerfile 0.19% Makefile 0.71%
powershell sql-server ssas tfs-api

friendly-chainsaw's Introduction

friendly-chainsaw

Docker Stars Docker Pulls

A collection of my PowerShell functions and scripts that I have developed over time. There are functions to help with logging and Text to Speech (FC_Log); my git workflow (FC_Git module); setting up/administering windows PCs (FC_SysAdmin); querying/administering SQL server and generally working with data (Excel/Flat files, ssas, ssis, crystal reports etc. inside of FC_Data); as well as other more fun stuff (render a Blender file, wrappers for GBA emulator, etc. in FC_Misc).

As I primarily use pwsh core nowadays, these modules are designed to be pwsh core compatible.

Using

Powershell Gallery

Use PSGallery to install and update your local modules. I am working towards CI/CD setup for publishing and it still needs some more automation, so there may be some delay in getting the latest versions published, but this is a much better way to install and manage your modules than hacking your $env:PSModulePath

The 2 main modules that you need are:

The other modules are independent of each other.

Directly access via source code

Clone the repository locally and add the /Modules/ directory into your $env:PSModulePath via your $PROFILE. My profile on development machines includes a section like below to use the modules directly from source. If running on Windows, you will need to replace the : with ;

if (!($env:PSModulePath -Like "*:/home/brandon/git/friendly-chainsaw/Modules/*")){
        $env:PSModulePath = $env:PSModulePath + ":/home/brandon/git/friendly-chainsaw/Modules/:"
}

Docker

To open an interactive shell:

docker run -it bmcclure89/fc_powershell:main

To mount a directory and run a script in an interactive way:

docker run -v ${PWD}:/work -it bmcclure89/fc_powershell:main pwsh /work/Scripts/Invoke-DockerScriptExample.ps1 "Brandon"

Building/Running the tests

Use make build and make test to build the module files and run the tests. This will run some helper docker images (src) to keep the environment consistent.

You can run the tests manually with pester as well!

Contributing

This is a collection of scripts that I use daily. As such, I don't really have a goal for this code (other than to make my daily life more automated!). If you have an improvement or an idea, open a pull request with your contribution!

License

This project is licensed under the MIT License unless specified otherwise. I see the LICENSE file for details

friendly-chainsaw's People

Contributors

brandonmcclure avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

friendly-chainsaw's Issues

Newly built modules do not have any Exported Commands

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
docker run mcr.microsoft.com/powershell pwsh -c 'Install-Module FC_Core -force -RequiredVersion 5.2.3; Import-Module FC_Core -force; Get-Command -Module FC_Core; Write-Host "Get Module"; Get-Module FC_Core'

Returns nothing for Get-Command, and for Get-Module


Script 5.2.3 FC_Core

Expected behavior
To see the Functions To Export like in: https://www.powershellgallery.com/packages/FC_Core/5.2.3/Content/FC_Core.psd1

Desktop (please complete the following information):
pwsh core/multiple os

Write-Log to file does not specify the loglevel in the formatted message

Describe the bug
When using the File log target, the loglevel of the message is not included in the file, but it is on the console.

To Reproduce

Set-logTargets -Console 1 -File "my.log"
Write-Log "Info message"
Write-Log "This is a warning" Warning
Write-Log "This is a error/big problem" Error

Expected behavior
Contents of my.log should contain:

Info message
[Warning] This is a warning
[Error] This is a error/big problem

Get-TFSPullRequests is failing

When it builds the $action to use for the REST call, the global variable for the apiVersion is not getting set in the url, causing the REST call to fail.

If Invoke-IncrementalBackup is run from a non admin shell it will create the base folders and increment the incremental backup count

To Reproduce
Create a incremental backup job. and run as a non admin:

New-BackupJob -Name Test -SourcePath C:\temp\gitRepo -DestinationPath C:\temp\backup -BackupProvider $(Get-AllowedBackupProviders -Name 'pwsh')

Get-BackupJob Test | Invoke-BackupJob

Expected behavior
Backup job should fail with an exception that it canot run as an admin. The incremental backup should not be incremented.

Write-Log fails when Set-LogTarget = win event log in PowerShell Core

Describe the bug
Write-log throws the following message when you send the output to the event log in PowerShell core:

Error Message = The term 'Write-EventLog' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

To Reproduce

  1. Set-logTargets -WindowsEventLog 1
  2. Write-log "my thingy"

Expected behavior
It goes into event viewer

Screenshots
Incidentally, I found this in Windows Server 2019 Event Viewer:

image

Additional context
I'm going to switch to Write-host and see what sort of output goes to the event viewer

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.