From 3504b98dafcc70586614a015ff161aaf5c7df99c Mon Sep 17 00:00:00 2001 From: "stepsecurity-app[bot]" <188008098+stepsecurity-app[bot]@users.noreply.github.com> Date: Wed, 5 Nov 2025 20:21:47 +0000 Subject: [PATCH 1/3] [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot --- .github/workflows/Build Module.yml | 18 ++++++++++++++---- .github/workflows/Deploy MkDocs.yml | 12 ++++++++++-- .github/workflows/Publish.yml | 10 +++++++++- .pre-commit-config.yaml | 6 ++++++ 4 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/Build Module.yml b/.github/workflows/Build Module.yml index f502168..7c9d0f2 100644 --- a/.github/workflows/Build Module.yml +++ b/.github/workflows/Build Module.yml @@ -19,8 +19,13 @@ on: workflow_dispatch: +permissions: + contents: read + jobs: test: + permissions: + contents: write # for stefanzweifel/git-auto-commit-action to push code in repo name: 🧪 Run Tests runs-on: ubuntu-latest strategy: @@ -28,8 +33,13 @@ jobs: steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2 + with: + egress-policy: audit + - name: ✅ Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 # Uncomment below to explore what modules/variables/env variables are available in the build image - name: 📦 Modules and Variables Display @@ -45,14 +55,14 @@ jobs: run: Invoke-Build -File .\src\TheCleaners.build.ps1 - name: 🧪 Upload Pester Results - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: pester-results path: .\src\Artifacts\testOutput if-no-files-found: warn - name: 📦 Upload Build - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: zip-archive path: .\src\Archive @@ -60,6 +70,6 @@ jobs: # git-auto-commit-action only runs on Linux-based platforms. - name: 💾 Commit Changes - uses: stefanzweifel/git-auto-commit-action@v5 + uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0 with: commit_message: 'Commit Build' diff --git a/.github/workflows/Deploy MkDocs.yml b/.github/workflows/Deploy MkDocs.yml index d0acedd..439df7c 100644 --- a/.github/workflows/Deploy MkDocs.yml +++ b/.github/workflows/Deploy MkDocs.yml @@ -14,6 +14,9 @@ on: # Allow manual triggering of the workflow. workflow_dispatch: +permissions: + contents: read + jobs: build: @@ -27,11 +30,16 @@ jobs: cancel-in-progress: true steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2 + with: + egress-policy: audit + - name: ✅ Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 - name: 🐍 Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: '3.x' # specify the Python version diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml index 4e59b76..14dc059 100644 --- a/.github/workflows/Publish.yml +++ b/.github/workflows/Publish.yml @@ -1,12 +1,20 @@ name: Publish to PowerShell Gallery on: workflow_dispatch: +permissions: + contents: read + jobs: publish: runs-on: ubuntu-latest steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2 + with: + egress-policy: audit + - name: Clone Project Files - uses: actions/checkout@v4 + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 - name: Publish PowerShell Module shell: pwsh run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..479defe --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace From 9ef2328f7afd21a1730079d49c11e673b4434223 Mon Sep 17 00:00:00 2001 From: "stepsecurity-app[bot]" <188008098+stepsecurity-app[bot]@users.noreply.github.com> Date: Wed, 5 Nov 2025 20:22:35 +0000 Subject: [PATCH 2/3] Commit Build --- .../TheCleaners_0.0.15_20250311.031804.zip | Bin 10145 -> 0 bytes src/Artifacts/Invoke-TheCleaners.ps1 | 45 +- src/Artifacts/TheCleaners.psm1 | 385 ++++++++++-------- 3 files changed, 248 insertions(+), 182 deletions(-) delete mode 100644 src/Archive/TheCleaners_0.0.15_20250311.031804.zip diff --git a/src/Archive/TheCleaners_0.0.15_20250311.031804.zip b/src/Archive/TheCleaners_0.0.15_20250311.031804.zip deleted file mode 100644 index 782922eefc6cf8ac47a051f18303b8e184be987e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10145 zcmaKS18`;0w(W_XbZpx;I<{@wHaa-5*>O(Hj@_}1j&0lMbbjAo@72Bczx&_ZRco(Z zHOHR2c8#hv)|x|E4gwMb@Q)Dfu+{y)lm8mv{@%^ZR4tsHT-}+K|0@j^K>0T<-5Yqv z1P%ZMLjV9+f74_fJ)P_<7}c#U#Oy6h94%bkn4H~M(~{>Lf3aYMUz5KQPPfE(&hMq# z;^T`-8(?*iSXWV$h{D<^`X_69T#R~Z(hW8`kFk?5c~f{prZ#{;a1=}*?_alhpI&={ zKAs+olS+Z8H8C0$QBurB9P)b-STk0Mi?AT^(pl{tJpH&{po`v$bt5#$xQZVFYf9mo zruh^Ko*r^!2^NYSwgWOk0ih((I)Nl!EwQ6P>Pr{1Z7E%tyH-#Y+Yo3D`Z-d{NJ?gH zhP9CV?Ig_Gy(5;HbYw3zPIBbWEu7V#+Y|ST#^1M@`T3*+_xG;;dE~bz=9val=+Zh6 zNxNNW)7VbQ-o9ylbv$9W*8X?z>HXreEQOW1P@$dJF0uky3Z=9Rdea2`qE55LoU(BA zptddTy}1k*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-BoXUEMZjGgl{FAounE!sBwy|Hk=P^ z^Ow74ZNBYe7jevvMk=%O(7bLFzZes~#mjgH%lEH*v3R>eCzWsVqwe#tdG7n&v4XS$ zVP#E#p93pn>X-ogEaQ7T(iW_InZo`OIebNCk=UP;34jfwF|~u?ti-)n&QN!Qm)qXH zr@pN^_uC=)l&N3xD`sdf?5I+X(WLa;U6?>9%iFmW3NI+*?Mwibxmg?4h`o0Z&Q>NB zWc#ECvC1QQOnvG2{VU*`oEZ)+uUXS+s3C95(-oT`O8RH!>CvaM92htT;Qwz5`zt~I zCH}=C_TRAoY!dq?hWhXHKU>EBx6=Qx0sS+g{@Ty}%@p*{;{VAO^iN>JU*NxJr@uxu zbJl;B{m)(Df1+>y>ac%DJNysy|Et&jiB2Q@-_)D39MoSU6954H_woh<0MM!a@$`QH D$gCMv diff --git a/src/Artifacts/Invoke-TheCleaners.ps1 b/src/Artifacts/Invoke-TheCleaners.ps1 index feedc72..c1a0af1 100644 --- a/src/Artifacts/Invoke-TheCleaners.ps1 +++ b/src/Artifacts/Invoke-TheCleaners.ps1 @@ -4,17 +4,50 @@ .GUID bec6a004-45da-4062-ab78-b8eae99f29be .AUTHOR Sam Erde .COPYRIGHT (c) 2025 Sam Erde. All rights reserved. -.TAGS Update PowerShell Windows +.TAGS PowerShell Windows Utility .LICENSEURI https://github.com/SamErde/TheCleaners/blob/main/LICENSE .PROJECTURI https://github.com/SamErde/TheCleaners/ #> + function Invoke-TheCleaners { + <# + .SYNOPSIS + Show a welcome message when the module is imported explicitly by the user. + + .DESCRIPTION + This function shows a welcome message to help the user get started when they explicitly import the module. If the + module is automatically imported by invoking one of its exported functions, we assume the user already knows the + command that they want to run and do not show the welcome message. + + .PARAMETER InvokingCommand + A parameter to receive the command line that called this function. This is used to determine if the module was + imported explicitly by the user or automatically by invoking one of its exported functions. This information must + come from outside the function in order to be able to determine what command invoked the script itself. + + .EXAMPLE + Invoke-TheCleaners -InvokingCommand "$( ((Get-PSCallStack)[1]).InvocationInfo.MyCommand )" + + .NOTES + Author: Sam Erde + Company: Sentinel Technologies, Inc + Date: 2025-03-11 + Version: 1.0.0 + #> [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')] - param() - Write-Host "Thank you for calling The Cleaners! 🧹`nRun " -ForegroundColor Green -NoNewline - Write-Host 'Start-Cleaning' -BackgroundColor Black -ForegroundColor White -NoNewline - Write-Host " to see the services we offer today.`n" -ForegroundColor Green + param ( + # The command that called this function. + [Parameter(Mandatory)] + [string] + $InvokingCommand + ) + + if ($InvokingCommand -match 'ipmo|Import-Module') { + Write-Host "Thank you for calling The Cleaners! 🧹`nRun " -ForegroundColor Green -NoNewline + Write-Host 'Start-Cleaning' -BackgroundColor Black -ForegroundColor White -NoNewline + Write-Host " to see the services we offer today.`n" -ForegroundColor Green + } + } -Invoke-TheCleaners +Invoke-TheCleaners -InvokingCommand "$( ((Get-PSCallStack)[1]).InvocationInfo.MyCommand )" diff --git a/src/Artifacts/TheCleaners.psm1 b/src/Artifacts/TheCleaners.psm1 index e705170..70ef3cd 100644 --- a/src/Artifacts/TheCleaners.psm1 +++ b/src/Artifacts/TheCleaners.psm1 @@ -12,205 +12,53 @@ .GUID bec6a004-45da-4062-ab78-b8eae99f29be .AUTHOR Sam Erde .COPYRIGHT (c) 2025 Sam Erde. All rights reserved. -.TAGS Update PowerShell Windows +.TAGS PowerShell Windows Utility .LICENSEURI https://github.com/SamErde/TheCleaners/blob/main/LICENSE .PROJECTURI https://github.com/SamErde/TheCleaners/ #> -function Invoke-TheCleaners { - [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')] - param() - Write-Host "Thank you for calling The Cleaners! 🧹`nRun " -ForegroundColor Green -NoNewline - Write-Host 'Start-Cleaning' -BackgroundColor Black -ForegroundColor White -NoNewline - Write-Host " to see the services we offer today.`n" -ForegroundColor Green -} - -Invoke-TheCleaners - - -function Convert-SamAccountNameToSID { - <# - .SYNOPSIS - Translates a SamAccountName to a SID. - - .DESCRIPTION - Translates a SamAccountName to a SID. - - .PARAMETER domain - The domain to search for the SamAccountName. - - .PARAMETER SamAccountName - The SamAccountName to translate to a SID. - - .EXAMPLE - Convert-SamAccountNameToSID -Domain "contoso" -SamAccountName "jdoe" - - Translates the SamAccountName "jdoe" to a SID. - - .COMPONENT - TheCleaners - #> - [CmdletBinding()] - param ( - # The Domain - [Parameter(Mandatory)] - [string]$Domain, - - # The SamAccountName - [Parameter(Mandatory)] - [string]$SamAccountName - ) - - $User = New-Object System.Security.Principal.NTAccount($Domain,$SamAccountName) - $SID = $User.Translate([System.Security.Principal.SecurityIdentifier]) - $SID.Value -} # End function Convert-SamAccountNameToSID - -function Convert-SIDtoSamAccountName { +function Invoke-TheCleaners { <# .SYNOPSIS - Translates a SID to a SamAccountName. + Show a welcome message when the module is imported explicitly by the user. .DESCRIPTION - Translates a SID to a SamAccountName. + This function shows a welcome message to help the user get started when they explicitly import the module. If the + module is automatically imported by invoking one of its exported functions, we assume the user already knows the + command that they want to run and do not show the welcome message. - .PARAMETER SID - The SID to translate to a SamAccountName. + .PARAMETER InvokingCommand + A parameter to receive the command line that called this function. This is used to determine if the module was + imported explicitly by the user or automatically by invoking one of its exported functions. This information must + come from outside the function in order to be able to determine what command invoked the script itself. .EXAMPLE - Convert-SIDtoSamAccountName -SID "S-1-5-21-3623811015-3361044348-30300820" - - Translates the SID to a SamAccountName. + Invoke-TheCleaners -InvokingCommand "$( ((Get-PSCallStack)[1]).InvocationInfo.MyCommand )" - .COMPONENT - TheCleaners + .NOTES + Author: Sam Erde + Company: Sentinel Technologies, Inc + Date: 2025-03-11 + Version: 1.0.0 #> [CmdletBinding()] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')] param ( - # The SID as a string or a SID object. + # The command that called this function. [Parameter(Mandatory)] - $SID - ) - - $SID = New-Object System.Security.Principal.SecurityIdentifier($SID) - $User = $SID.Translate([System.Security.Principal.NTAccount]) - $User.Value -} # End function Convert-SIDtoSamAccountName - - -<# -.SYNOPSIS - Remove files in a path that are older than the specified number of days. - -.DESCRIPTION - Remove files in a path that are older than the specified number of days. This function is used by other functions within the module when removing old files. - -.EXAMPLE - Remove-OldFiles -Path "C:\Windows\Temp" -Days 60 -Recurse - - Removes all files older than 60 does in C:\Windows\Temp with recursion to clean subfolders. -#> -function Remove-OldFiles { - [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns')] - param ( - # The path containing files to remove [string] - $Path, - - # How many days worth of logs to retain (how far back to filter) - [int16] - $Days = 60 + $InvokingCommand ) - begin { - - } - - process { - Write-Verbose -Message "Finding and removing files older than $Days." - Get-ChildItem -Path $Path -Recurse | Where-Object { - $_.CreationTime -le ([datetime]::Now.AddDays( -$Days )) - } | Remove-Item + if ($InvokingCommand -match 'ipmo|Import-Module') { + Write-Host "Thank you for calling The Cleaners! 🧹`nRun " -ForegroundColor Green -NoNewline + Write-Host 'Start-Cleaning' -BackgroundColor Black -ForegroundColor White -NoNewline + Write-Host " to see the services we offer today.`n" -ForegroundColor Green } - end { - - } } - -function Show-TCLogo { - <# - .SYNOPSIS - Show an ASCII art logo for The Cleaners. - - .DESCRIPTION - Show a color or plain ASCII art logo for The Cleaners whenever you need it in another function. - - .PARAMETER Plain - Return a plan-text version of the logo instead of multi-colored Write-Host output. - - .EXAMPLE - Show-Logo - - .EXAMPLE - Show-Logo -Plain - - #> - [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost','')] - param ( - [Parameter()] - [switch] - $Plain - ) - - $Version = (Import-PowerShellDataFile -Path $PSScriptRoot\..\TheCleaners.psd1).ModuleVersion - - if ($Plain.IsPresent) { - $Logo = @" - - ╭━━━━┳╮╱╱╱╱╱╭━━━┳╮ - ┃╭╮╭╮┃┃╱╱╱╱╱┃╭━╮┃┃ v$Version - ╰╯┃┃╰┫╰━┳━━╮┃┃╱╰┫┃╭━━┳━━┳━╮ ╭━━┳━┳━━╮ - ╱╱┃┃╱┃╭╮┃┃━┫┃┃╱╭┫┃|┃━┫╭╮┃╭╮╮┃|━┫╭┫━━┫ - ╱╱┃┃╱┃┃┃┃┃━┫┃╰━╯┃╰┫┃━┫╭╮┃||┃┃|━┫|┣━━┃ - ╱╱╰╯╱╰╯╰┻━━╯╰━━━┻━┻━━┻╯╰┻╯╰┻┻━━┻╯╰━━╯ - -"@ - return $Logo - } else { - Write-Host '' - Write-Host ' ╭━━━━┳╮' -ForegroundColor DarkCyan -NoNewline - Write-Host '╱╱╱╱╱' -ForegroundColor Yellow -NoNewline - Write-Host '╭━━━┳╮' -ForegroundColor DarkCyan #NewLine - Write-Host ' ┃╭╮╭╮┃┃' -ForegroundColor DarkCyan -NoNewline - Write-Host '╱╱╱╱╱' -ForegroundColor Yellow -NoNewline - Write-Host '┃╭━╮┃┃' -ForegroundColor DarkCyan -NoNewline #NewLine - Write-Host " v$Version" -ForegroundColor Yellow - Write-Host ' ╰╯┃┃╰┫╰━┳━━╮┃┃' -ForegroundColor DarkCyan -NoNewline - Write-Host '/' -ForegroundColor Yellow -NoNewline - Write-Host '╰┫┃╭━━┳━━┳━╮' -ForegroundColor DarkCyan -NoNewline - Write-Host '*' -ForegroundColor Yellow -NoNewline - Write-Host '╭━━┳━┳━━╮' -ForegroundColor DarkCyan #NewLine - Write-Host ' ╱╱' -ForegroundColor Yellow -NoNewline - Write-Host '┃┃' -ForegroundColor DarkCyan -NoNewline - Write-Host '/' -ForegroundColor Yellow -NoNewline - Write-Host '┃╭╮┃┃━┫┃┃' -ForegroundColor DarkCyan -NoNewline - Write-Host '/' -ForegroundColor Yellow -NoNewline - Write-Host '╭┫┃|┃━┫╭╮┃╭╮╮┃|━┫╭┫━━┫' -ForegroundColor DarkCyan #NewLine - Write-Host ' ╱╱' -ForegroundColor Yellow -NoNewline - Write-Host '┃┃' -ForegroundColor DarkCyan -NoNewline - Write-Host '/' -ForegroundColor Yellow -NoNewline - Write-Host '┃┃┃┃┃━┫┃╰━╯┃╰┫┃━┫╭╮┃||┃┃|━┫|┣━━┃' -ForegroundColor DarkCyan #NewLine - Write-Host ' ╱╱' -ForegroundColor Yellow -NoNewline - Write-Host '┃┃' -ForegroundColor DarkCyan -NoNewline - Write-Host '/' -ForegroundColor Yellow -NoNewline - Write-Host '╰╯╰┻━━╯╰━━━┻━┻━━┻╯╰┻╯╰┻┻━━┻╯╰━━╯' -ForegroundColor DarkCyan #NewLine - Write-Host '' - } -} +Invoke-TheCleaners -InvokingCommand "$( ((Get-PSCallStack)[1]).InvocationInfo.MyCommand )" function Clear-CurrentUserTemp { @@ -528,4 +376,189 @@ function Start-Cleaning { +function Convert-SamAccountNameToSID { + <# + .SYNOPSIS + Translates a SamAccountName to a SID. + + .DESCRIPTION + Translates a SamAccountName to a SID. + + .PARAMETER domain + The domain to search for the SamAccountName. + + .PARAMETER SamAccountName + The SamAccountName to translate to a SID. + + .EXAMPLE + Convert-SamAccountNameToSID -Domain "contoso" -SamAccountName "jdoe" + + Translates the SamAccountName "jdoe" to a SID. + + .COMPONENT + TheCleaners + #> + [CmdletBinding()] + param ( + # The Domain + [Parameter(Mandatory)] + [string]$Domain, + + # The SamAccountName + [Parameter(Mandatory)] + [string]$SamAccountName + ) + + $User = New-Object System.Security.Principal.NTAccount($Domain,$SamAccountName) + $SID = $User.Translate([System.Security.Principal.SecurityIdentifier]) + $SID.Value +} # End function Convert-SamAccountNameToSID + + +function Convert-SIDtoSamAccountName { + <# + .SYNOPSIS + Translates a SID to a SamAccountName. + + .DESCRIPTION + Translates a SID to a SamAccountName. + + .PARAMETER SID + The SID to translate to a SamAccountName. + + .EXAMPLE + Convert-SIDtoSamAccountName -SID "S-1-5-21-3623811015-3361044348-30300820" + + Translates the SID to a SamAccountName. + + .COMPONENT + TheCleaners + #> + [CmdletBinding()] + param ( + # The SID as a string or a SID object. + [Parameter(Mandatory)] + $SID + ) + + $SID = New-Object System.Security.Principal.SecurityIdentifier($SID) + $User = $SID.Translate([System.Security.Principal.NTAccount]) + $User.Value +} # End function Convert-SIDtoSamAccountName + + +<# +.SYNOPSIS + Remove files in a path that are older than the specified number of days. + +.DESCRIPTION + Remove files in a path that are older than the specified number of days. This function is used by other functions within the module when removing old files. + +.EXAMPLE + Remove-OldFiles -Path "C:\Windows\Temp" -Days 60 -Recurse + + Removes all files older than 60 does in C:\Windows\Temp with recursion to clean subfolders. +#> +function Remove-OldFiles { + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns')] + param ( + # The path containing files to remove + [string] + $Path, + + # How many days worth of logs to retain (how far back to filter) + [int16] + $Days = 60 + ) + + begin { + + } + + process { + Write-Verbose -Message "Finding and removing files older than $Days." + Get-ChildItem -Path $Path -Recurse | Where-Object { + $_.CreationTime -le ([datetime]::Now.AddDays( -$Days )) + } | Remove-Item + } + + end { + + } +} + + +function Show-TCLogo { + <# + .SYNOPSIS + Show an ASCII art logo for The Cleaners. + + .DESCRIPTION + Show a color or plain ASCII art logo for The Cleaners whenever you need it in another function. + + .PARAMETER Plain + Return a plan-text version of the logo instead of multi-colored Write-Host output. + + .EXAMPLE + Show-Logo + + .EXAMPLE + Show-Logo -Plain + + #> + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost','')] + param ( + [Parameter()] + [switch] + $Plain + ) + + $Version = (Import-PowerShellDataFile -Path $PSScriptRoot\..\TheCleaners.psd1).ModuleVersion + + if ($Plain.IsPresent) { + $Logo = @" + + ╭━━━━┳╮╱╱╱╱╱╭━━━┳╮ + ┃╭╮╭╮┃┃╱╱╱╱╱┃╭━╮┃┃ v$Version + ╰╯┃┃╰┫╰━┳━━╮┃┃╱╰┫┃╭━━┳━━┳━╮ ╭━━┳━┳━━╮ + ╱╱┃┃╱┃╭╮┃┃━┫┃┃╱╭┫┃|┃━┫╭╮┃╭╮╮┃|━┫╭┫━━┫ + ╱╱┃┃╱┃┃┃┃┃━┫┃╰━╯┃╰┫┃━┫╭╮┃||┃┃|━┫|┣━━┃ + ╱╱╰╯╱╰╯╰┻━━╯╰━━━┻━┻━━┻╯╰┻╯╰┻┻━━┻╯╰━━╯ + +"@ + return $Logo + } else { + Write-Host '' + Write-Host ' ╭━━━━┳╮' -ForegroundColor DarkCyan -NoNewline + Write-Host '╱╱╱╱╱' -ForegroundColor Yellow -NoNewline + Write-Host '╭━━━┳╮' -ForegroundColor DarkCyan #NewLine + Write-Host ' ┃╭╮╭╮┃┃' -ForegroundColor DarkCyan -NoNewline + Write-Host '╱╱╱╱╱' -ForegroundColor Yellow -NoNewline + Write-Host '┃╭━╮┃┃' -ForegroundColor DarkCyan -NoNewline #NewLine + Write-Host " v$Version" -ForegroundColor Yellow + Write-Host ' ╰╯┃┃╰┫╰━┳━━╮┃┃' -ForegroundColor DarkCyan -NoNewline + Write-Host '/' -ForegroundColor Yellow -NoNewline + Write-Host '╰┫┃╭━━┳━━┳━╮' -ForegroundColor DarkCyan -NoNewline + Write-Host '*' -ForegroundColor Yellow -NoNewline + Write-Host '╭━━┳━┳━━╮' -ForegroundColor DarkCyan #NewLine + Write-Host ' ╱╱' -ForegroundColor Yellow -NoNewline + Write-Host '┃┃' -ForegroundColor DarkCyan -NoNewline + Write-Host '/' -ForegroundColor Yellow -NoNewline + Write-Host '┃╭╮┃┃━┫┃┃' -ForegroundColor DarkCyan -NoNewline + Write-Host '/' -ForegroundColor Yellow -NoNewline + Write-Host '╭┫┃|┃━┫╭╮┃╭╮╮┃|━┫╭┫━━┫' -ForegroundColor DarkCyan #NewLine + Write-Host ' ╱╱' -ForegroundColor Yellow -NoNewline + Write-Host '┃┃' -ForegroundColor DarkCyan -NoNewline + Write-Host '/' -ForegroundColor Yellow -NoNewline + Write-Host '┃┃┃┃┃━┫┃╰━╯┃╰┫┃━┫╭╮┃||┃┃|━┫|┣━━┃' -ForegroundColor DarkCyan #NewLine + Write-Host ' ╱╱' -ForegroundColor Yellow -NoNewline + Write-Host '┃┃' -ForegroundColor DarkCyan -NoNewline + Write-Host '/' -ForegroundColor Yellow -NoNewline + Write-Host '╰╯╰┻━━╯╰━━━┻━┻━━┻╯╰┻╯╰┻┻━━┻╯╰━━╯' -ForegroundColor DarkCyan #NewLine + Write-Host '' + } +} + + From c4104ed5f17810660ccac9710e3f4059a70b7959 Mon Sep 17 00:00:00 2001 From: Sam Erde <20478745+SamErde@users.noreply.github.com> Date: Wed, 5 Nov 2025 15:31:50 -0500 Subject: [PATCH 3/3] Delete src/Artifacts/Invoke-TheCleaners.ps1 --- src/Artifacts/Invoke-TheCleaners.ps1 | 53 ---------------------------- 1 file changed, 53 deletions(-) delete mode 100644 src/Artifacts/Invoke-TheCleaners.ps1 diff --git a/src/Artifacts/Invoke-TheCleaners.ps1 b/src/Artifacts/Invoke-TheCleaners.ps1 deleted file mode 100644 index c1a0af1..0000000 --- a/src/Artifacts/Invoke-TheCleaners.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -<#PSScriptInfo -.DESCRIPTION The Cleaners do the dirty work in your servers for you. We take care of temp files, IIS logs, Exchange Server logs, and more! -.VERSION 0.0.15 -.GUID bec6a004-45da-4062-ab78-b8eae99f29be -.AUTHOR Sam Erde -.COPYRIGHT (c) 2025 Sam Erde. All rights reserved. -.TAGS PowerShell Windows Utility -.LICENSEURI https://github.com/SamErde/TheCleaners/blob/main/LICENSE -.PROJECTURI https://github.com/SamErde/TheCleaners/ -#> - -function Invoke-TheCleaners { - <# - .SYNOPSIS - Show a welcome message when the module is imported explicitly by the user. - - .DESCRIPTION - This function shows a welcome message to help the user get started when they explicitly import the module. If the - module is automatically imported by invoking one of its exported functions, we assume the user already knows the - command that they want to run and do not show the welcome message. - - .PARAMETER InvokingCommand - A parameter to receive the command line that called this function. This is used to determine if the module was - imported explicitly by the user or automatically by invoking one of its exported functions. This information must - come from outside the function in order to be able to determine what command invoked the script itself. - - .EXAMPLE - Invoke-TheCleaners -InvokingCommand "$( ((Get-PSCallStack)[1]).InvocationInfo.MyCommand )" - - .NOTES - Author: Sam Erde - Company: Sentinel Technologies, Inc - Date: 2025-03-11 - Version: 1.0.0 - #> - [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')] - param ( - # The command that called this function. - [Parameter(Mandatory)] - [string] - $InvokingCommand - ) - - if ($InvokingCommand -match 'ipmo|Import-Module') { - Write-Host "Thank you for calling The Cleaners! 🧹`nRun " -ForegroundColor Green -NoNewline - Write-Host 'Start-Cleaning' -BackgroundColor Black -ForegroundColor White -NoNewline - Write-Host " to see the services we offer today.`n" -ForegroundColor Green - } - -} - -Invoke-TheCleaners -InvokingCommand "$( ((Get-PSCallStack)[1]).InvocationInfo.MyCommand )"