Move everything to PowerShell on Windows

Port existing batch script behavior over to PowerShell, and switch over to a
command-based pattern like DBRepair.sh - that is, allow the user to pass in a
list of commands to be run automatically, or, if no commands are provided,
interactively allow the user to choose what to do.
This commit is contained in:
danrahn
2024-05-11 14:49:53 -07:00
parent ec9edaf304
commit c9a9a1eb81
3 changed files with 817 additions and 0 deletions

View File

@@ -984,3 +984,39 @@ cd /var/packages/PlexMediaServer/shares/PlexMediaServer
# Run classic Stop PMS, Automatic optimization/repair, Start PMS, and exit sequence
sudo ./DBRepair.sh stop auto start exit
```
# Special Considerations - Windows
Windows development is currently not on-par with DBRepair.sh, with only a limited number
of commands available. Additionally, the script (DBRepair-Windows.ps1) might fail to run
if your machine's ExecutionPolicy blocks execution of PowerShell scripts, which is the
default. There are several ways to potentially get around this:
1. From an administrator PowerShell prompt, run `Set-ExecutionPolicy RemoteSigned`, then
run the script from a normal PowerShell prompt.
2. Explicitly set the `ExecutionPolicy` when running the script, e.g.:
```powershell
powershell -ExecutionPolicy Bypass ".\DBRepair-Windows.ps1 stop auto start"
```
Note that this method may not work if your machine is managed with Group Policy, which
can block manual `ExecutionPolicy` overrides.
3. Similar to 2, but make it a batch script (e.g. `DBRepair.bat`) that lives alongside
the powershell script:
```batch
@echo off
powershell -ExecutionPolicy Bypass -Command ".\DBRepair-Windows.ps1 %*"
```
Then run that script directly:
```batch
.\DBRepair.bat stop auto start
```
Also note that the PowerShell script cannot be run directly from a Command Prompt window.
If you are running this from Command Prompt, you must launch it via PowerShell:
```cmd
powershell .\DBRepair-Windows.ps1 [args]
```