From f15d6623e857fc8e4f88c799a50b3e4d612f4cef Mon Sep 17 00:00:00 2001 From: USER Date: Sat, 6 Jan 2024 21:12:18 +0000 Subject: [PATCH] . --- PS/pUnlockUSB.ps1 | 8 +++ bin/l_UnlockUSB.bat | 118 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 PS/pUnlockUSB.ps1 create mode 100644 bin/l_UnlockUSB.bat diff --git a/PS/pUnlockUSB.ps1 b/PS/pUnlockUSB.ps1 new file mode 100644 index 0000000..7d2050d --- /dev/null +++ b/PS/pUnlockUSB.ps1 @@ -0,0 +1,8 @@ +Get-Content C:\Scripts\Secrets\unlockusb.txt | Where-Object {$_.length -gt 0} | Where-Object {!$_.StartsWith("#")} | ForEach-Object { + $var = $_.Split('=',2).Trim() + New-Variable -Scope Script -Name $var[0] -Value $var[1] +} + +$SecureString = ConvertTo-SecureString $mystring -AsPlainText -Force +Unlock-BitLocker -MountPoint "E:" -Password $SecureString + diff --git a/bin/l_UnlockUSB.bat b/bin/l_UnlockUSB.bat new file mode 100644 index 0000000..05c88fd --- /dev/null +++ b/bin/l_UnlockUSB.bat @@ -0,0 +1,118 @@ +@echo on +call C:\Scripts\wLocal\localENV.bat +@REM xxxxxxx +echo "START: %~n0" + +set UNLOCKPS="%LOCAL%\PS\pUnlock.ps1" +set EXE="Powershell.exe" + +@REM set variables to ensure they are set, +@REM printer 0 - no install +@REM printer 1 - install brother +@REM printer 2 - install zebra +@REM printer 3 - install both + +set ZUPER=0 +set PRINTER=0 + +if "%USERNAME%" == "zuper" ( + echo "Found user %USERNAME%" + @REM echo "Not setting up printer for %USERNAME%" + set ZUPER=1 + ) + +if "%check_computername%" EQU "SERVER2" ( + set ZUPER=1 +) + +if "%check_computername%" EQU "SURGERY1" ( + set PRINTER=3 +) + +if "%check_computername%" EQU "SURGERY2" ( + set PRINTER=3 +) + +if "%check_computername%" EQU "SURGERY3" ( + set PRINTER=3 +) + +if "%check_computername%" EQU "SURGERY4" ( + set PRINTER=3 +) + +if "%check_computername%" EQU "RECEPTION1" ( + set PRINTER=1 +) + +if "%check_computername%" EQU "RECEPTION2" ( + set PRINTER=2 +) + +if "%check_computername%" EQU "RECEPTION3" ( + set PRINTER=1 +) + +if "%check_computername%" EQU "RECEPTION4" ( + set PRINTER=1 +) + +if [%ZUPER%] == [1] ( + echo "Attempting unlock of drive" + call %TMESSAGE% '"Attempting unlock of drive on %check_computername%"' + %EXE% -ExecutionPolicy Bypass -File %UNLOCKPS% +) else ( + if [%PRINTER%] == [1] ( + echo "Installing Brother" + @REM %EXE% -ExecutionPolicy Bypass -File %BROTHERPS% + @REM rundll32 printui.dll,PrintUIEntry /in /n \\reception2\brother + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\192.168.1.22\BROTHER" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\reception2\BROTHER" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -ac -p "\\reception2\BROTHER" + @REM rundll32 printui.dll,PrintUIEntry /y /n \\server_name\printer_name + shutdown /r /t 1 + ) + if [%PRINTER%] == [2] ( + echo "Installing Zebra" + @REM %EXE% -ExecutionPolicy Bypass -File %ZEBRAPS% + CD C:\WINDOWS\SYSTEM + @REM rundll32 printui.dll,PrintUIEntry /in /n \\reception1\zebra + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\192.168.1.21\ZEBRA" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\reception1\ZDesigner GK420d" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -ac -p "\\reception1\ZEBRA" + @REM rundll32 printui.dll,PrintUIEntry /y /n \\server_name\printer_name + shutdown /r /t 1 + ) + if [%PRINTER%] == [3] ( + echo "Installing Brother and Zebra" + @REM %EXE% -ExecutionPolicy Bypass -File %BROTHERPS% + @REM %EXE% -ExecutionPolicy Bypass -File %ZEBRAPS% + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\192.168.1.22\BROTHER" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\reception2\BROTHER" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -ac -p "\\reception2\BROTHER" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\192.168.1.21\ZEBRA" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\reception1\ZDesigner GK420d" + cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -ac -p "\\reception1\ZEBRA" + shutdown /r /t 1 + ) + ) + +echo "FINISHED: %~n0" + +@REM https://woshub.com/manage-printers-and-drivers-from-the-command-line-in-windows-8/ +@REM https://ss64.com/nt/net-use.html +@REM https://www.windowscentral.com/how-properly-remove-printer-windows-10#uninstall_printer_printmanagement + + + + +@REM Printer name \\reception1\ZDesigner GK420d +@REM Share name ZEBRA +@REM Driver name ZDesigner GK420d + +@REM C:\Windows\System>cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -p "\\reception1\ZDesigner GK420d" + + +@REM Printer name \\reception2\BROTHER +@REM Share name BROTHER +@REM Driver name Brother DCP-L2510D series