-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comment Spacing, Indentation, and Capitalization (#1084)
* Comment Spacing, Indentation, and Capitalization * Comment Grammar and Spacing Makes grammar in comments better and more consistent Adds space before comment and centers word in `Write-Host` commands * More Grammar and Formatting * Add some comments * Populate PlaceHolder comments in functions Files I found that has issues: Get-WinUtilRegistry.ps1 Install-WinUtilWinget.ps1 Invoke-WinUtilDarkMode.ps1 Remove-WinUtilAPPX.ps1 Test-WinUtilPackageManager.ps1 Update-WinUtilProgramWinget.ps1 Invoke-WPFUpdatessecurity.ps1 * Tweak a few more comments * Tweak another write-host statement * Undo Catch statement adjustment It's outside of the scope of this pull request
- Loading branch information
1 parent
932ec6a
commit acc2b5b
Showing
13 changed files
with
162 additions
and
474 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
function Get-WinUtilVariables { | ||
|
||
<# | ||
.SYNOPSIS | ||
Gets every form object of the provided type | ||
.OUTPUTS | ||
List containing every object that matches the provided type | ||
#> | ||
param ( | ||
[Parameter()] | ||
[string[]]$Type | ||
[ValidateSet("CheckBox", "Button")] | ||
[string]$Type | ||
) | ||
|
||
$keys = $sync.keys | Where-Object { $_ -like "WPF*" } | ||
$keys = $sync.keys | Where-Object {$psitem -like "WPF*"} | ||
|
||
if ($Type) { | ||
if($type){ | ||
$output = $keys | ForEach-Object { | ||
Try { | ||
$objType = $sync["$psitem"].GetType().Name | ||
if ($Type -contains $objType) { | ||
Try{ | ||
if ($sync["$psitem"].GetType() -like "*$type*"){ | ||
Write-Output $psitem | ||
} | ||
} | ||
Catch { | ||
<#I am here so errors don't get outputted for a couple variables that don't have the .GetType() attribute#> | ||
} | ||
Catch{<#I am here so errors don't get outputted for a couple variables that don't have the .GetType() attribute#>} | ||
} | ||
return $output | ||
return $output | ||
} | ||
return $keys | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function Set-WinUtilRestorePoint { | ||
<# | ||
.SYNOPSIS | ||
Creates a Restore Point | ||
#> | ||
|
||
# Check if the user has administrative privileges | ||
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | ||
Write-Host "Please run this script as an administrator." | ||
return | ||
} | ||
|
||
# Check if System Restore is enabled for the main drive | ||
try { | ||
# Try getting restore points to check if System Restore is enabled | ||
Enable-ComputerRestore -Drive "$env:SystemDrive" | ||
} catch { | ||
Write-Host "An error occurred while enabling System Restore: $_" | ||
} | ||
|
||
# Check if the SystemRestorePointCreationFrequency value exists | ||
$exists = Get-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -name "SystemRestorePointCreationFrequency" -ErrorAction SilentlyContinue | ||
if($null -eq $exists){ | ||
write-host 'Changing system to allow multiple restore points per day' | ||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name "SystemRestorePointCreationFrequency" -Value "0" -Type DWord -Force -ErrorAction Stop | Out-Null | ||
} | ||
|
||
# Get all the restore points for the current day | ||
$existingRestorePoints = Get-ComputerRestorePoint | Where-Object { $_.CreationTime.Date -eq (Get-Date).Date } | ||
|
||
# Check if there is already a restore point created today | ||
if ($existingRestorePoints.Count -eq 0) { | ||
$description = "System Restore Point created by WinUtil" | ||
|
||
Checkpoint-Computer -Description $description -RestorePointType "MODIFY_SETTINGS" | ||
Write-Host -ForegroundColor Green "System Restore Point Created Successfully" | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Load Variables needed for testing | ||
|
||
./Compile.ps1 | ||
|
||
$script = Get-Content .\winutil.ps1 | ||
# Remove the part of the script that shows the form, leaving only the variable and function declarations | ||
$script[0..($script.count - 21)] | Out-File .\pester.ps1 | ||
|
||
|
||
BeforeAll { | ||
# Execute the truncated script, bringing the variabes into the current scope | ||
. .\pester.ps1 | ||
} | ||
|
||
Describe "GUI" { | ||
Context "XML" { | ||
It "Imports with no errors" { | ||
$inputXML | should -Not -BeNullOrEmpty | ||
} | ||
} | ||
|
||
Context "Form" { | ||
It "Imports with no errors" { | ||
$sync.Form | should -Not -BeNullOrEmpty | ||
} | ||
} | ||
} |
Oops, something went wrong.