Last active
May 19, 2022 11:20
-
-
Save lzlrd/4b27b92f0b4ed40bbf404e7051f8f448 to your computer and use it in GitHub Desktop.
A PowerShell script to easily manage a PATH exportable folder with multiple programs in dedicated sub-folders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$invocPath = $(split-path $MyInvocation.MyCommand.Path) | |
ForEach ($i in (Get-ChildItem -Force -Path $invocPath | Where-Object { ($_.Attributes -Match "ReparsePoint") -And ($_.LinkType -Eq "SymbolicLink") -And (-Not $_.PSIsContainer) })) { If ($i.Name -ne "binexport.ps1") { Remove-Item $i.FullName } } | |
ForEach ($i in (Get-ChildItem -Force -Path $invocPath -Recurse -Include "*.bat", "*.dll", "*.exe", "*.ps1" | Where-Object { $_.Attributes -NotMatch "ReparsePoint" })) { If (( -Join ($invocPath, "\", $i.Name)) -Ne $MyInvocation.MyCommand.Path) { New-Item -ItemType SymbolicLink -Path ( -Join ($invocPath, "\", $i.Name)) -Target $i.FullName | Out-Null } } | |
# Exceptions | |
If (Test-Path -Path ( -Join ($invocPath, "\open_a_terminal_here.bat")) -PathType Leaf) { Remove-Item ( -Join ($invocPath, "\open_a_terminal_here.bat")) } | |
ForEach ($i in (Get-ChildItem -Force -Path $invocPath "restic_*_windows_amd64.exe")) { Move-Item $i.FullName ( -Join ($invocPath, "\restic.exe")) } | |
If (Test-Path -Path ( -Join ($invocPath, "\scrcpy-server")) -PathType Leaf) { Remove-Item ( -Join ($invocPath, "\scrcpy-server")) } | |
ForEach ($i in (Get-ChildItem -Force -Path $invocPath -Recurse "scrcpy-server")) { New-Item -ItemType SymbolicLink -Path ( -Join ($invocPath, "\", $i)) -Target $i.FullName | Out-Null } | |
ForEach ($i in (Get-ChildItem -Force -Path $invocPath "winfetch.ps1")) { Move-Item $i.FullName ( -Join ($invocPath, "\neofetch.ps1")) } | |
# Output | |
ForEach ($i in (Get-ChildItem -Force -Path $invocPath | Where-Object { ($_.Attributes -Match "ReparsePoint") -And ($_.LinkType -Eq "SymbolicLink") -And (-Not $_.PSIsContainer) })) { Write-Output ( -Join ("Created a symbolic link for ", $i.Name, ".")) } | |
# Update Script | |
if (Get-NetAdapter | Where-Object {$_.Status -Eq 'Up'}) { | |
$url = "https://gist.githubusercontent.com/lazerl0rd/4b27b92f0b4ed40bbf404e7051f8f448/raw/binexport.ps1" | |
Invoke-WebRequest -Uri ( -Join ($url, "?", (Get-Random -Minimum 1000 -Maximum 9999))) -OutFile $MyInvocation.MyCommand.Path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment