Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PowerShell Port to repository #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Ronin-Droid
Copy link

Spent a little while re-writing this script to be PowerShell compatible. Still has some Batch code in the PS1 script, but it was avoided wherever possible (within reason). This is more future-proofing than it is any appreciable upgrade. Added code so the script can correctly identify Windows 11. Dropped support for older windows, as this is a PowerShell script and won't run on a windows without PowerShell. The Batch file is still present for compatibility.
Most notable change is the addition of a self-elevation function, which checks if the script is running with administrator privileges and triggers the windows UAC if necessary.
Also cleaned up some of the grammar. It wasn't bad, but it did bother me.

#:getValues
function GetValues {
# for /f "tokens=4 delims=[] " %%a in ('ver') do set version=%%a
$Version = systeminfo | findstr /B /C:"OS Version"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output of systeminfo is localized. The output of ver is not localized. Or have a look at some alternatives: https://ss64.com/ps/syntax-ver.html.

$choices = '&Yes', '&No'

if(-not (Test-Path "$env:USERPROFILE\Desktop\Backup\Regedit\$currentDate\" -PathType Container)) {
mkdir "$env:USERPROFILE\Desktop\Backup\Regedit\$currentDate\"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my system this invocation of mkdir failed, because it does not create parent directories. This also applies to the batch script wureset.bat. PowerShell has New-Item -Type Directory -Force ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants