Skip to content

Commit e26d135

Browse files
🩹 [Patch]: Support 5.1 (#41)
## Description This pull request includes several changes to the PowerShell modules and scripts, focusing on adding a new module for admin role functionalities and updating existing scripts for better compatibility and functionality. - Fixes #40 ### Compatibility and Configuration: * [`src/manifest.psd1`](diffhunk://#diff-89820c99acb3b881e314c7e358eea621a8687cb4e0c687f541b9dcc9f30cc5dcR1-R3): Added a manifest file specifying the required PowerShell version (`5.1`). ### Script Updates: * [`src/variables/private/common.ps1`](diffhunk://#diff-43f49f109813a50f70fe2c6aef4729f89799983af5274aac8824887f527ec693L21-R21): Updated the `$script:OS` variable assignment to include a check for `PSEdition` being 'Desktop' to enhance compatibility across different PowerShell editions. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas
1 parent 6f339f1 commit e26d135

6 files changed

Lines changed: 17 additions & 19 deletions

File tree

src/classes/private/Scope.ps1

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/functions/public/Get-Font.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.3' }
1+
#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.5' }
22

33
function Get-Font {
44
<#
@@ -85,7 +85,8 @@ function Get-Font {
8585

8686
# Specifies the scope of the font(s) to get.
8787
[Parameter(ValueFromPipelineByPropertyName)]
88-
[Scope[]] $Scope = 'CurrentUser'
88+
[ValidateSet('CurrentUser', 'AllUsers')]
89+
[string[]] $Scope = 'CurrentUser'
8990
)
9091

9192
begin {
@@ -96,8 +97,7 @@ function Get-Font {
9697
process {
9798
$scopeCount = $Scope.Count
9899
Write-Verbose "[$functionName] - Processing [$scopeCount] scope(s)"
99-
foreach ($ScopeItem in $Scope) {
100-
$scopeName = $ScopeItem.ToString()
100+
foreach ($scopeName in $Scope) {
101101

102102
Write-Verbose "[$functionName] - [$scopeName] - Getting font(s)"
103103
$fontFolderPath = $script:FontFolderPathMap[$script:OS][$scopeName]

src/functions/public/Install-Font.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.3' }
1+
#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.5' }
22

33
function Install-Font {
44
<#
@@ -119,7 +119,8 @@ function Install-Font {
119119
# CurrentUser will install the font for the current user only.
120120
# AllUsers will install the font so it is available for all users on the system.
121121
[Parameter(ValueFromPipelineByPropertyName)]
122-
[string] $Scope = 'CurrentUser',
122+
[ValidateSet('CurrentUser', 'AllUsers')]
123+
[string[]] $Scope = 'CurrentUser',
123124

124125
# Recurse will install all fonts in the specified folder and subfolders.
125126
[Parameter()]
@@ -148,8 +149,7 @@ Please run the command again with elevated rights (Run as Administrator) or prov
148149
process {
149150
$scopeCount = $Scope.Count
150151
Write-Verbose "[$functionName] - Processing [$scopeCount] scopes(s)"
151-
foreach ($scopeItem in $Scope) {
152-
$scopeName = $scopeItem.ToString()
152+
foreach ($scopeName in $Scope) {
153153
$fontDestinationFolderPath = $script:FontFolderPathMap[$script:OS][$scopeName]
154154
$pathCount = $Path.Count
155155
Write-Verbose "[$functionName] - [$scopeName] - Processing [$pathCount] path(s)"
@@ -226,7 +226,7 @@ Please run the command again with elevated rights (Run as Administrator) or prov
226226
if (-not $fileCopied) {
227227
continue
228228
}
229-
if ($IsWindows) {
229+
if ($script:OS -eq 'Windows') {
230230
$fontType = $script:SupportedFonts | Where-Object { $_.Extension -eq $fontExtension } | Select-Object -ExpandProperty Type
231231
$registeredFontName = "$fontName ($fontType)"
232232
Write-Verbose "[$functionName] - [$scopeName] - [$fontFilePath] - Registering font as [$registeredFontName]"

src/functions/public/Uninstall-Font.ps1

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
# CurrentUser will uninstall the font for the current user.
6060
# AllUsers will uninstall the font so it is removed for all users.
6161
[Parameter(ValueFromPipelineByPropertyName)]
62-
[Scope[]] $Scope = 'CurrentUser'
62+
[ValidateSet('CurrentUser', 'AllUsers')]
63+
[string[]] $Scope = 'CurrentUser'
6364
)
6465

6566
begin {
@@ -80,9 +81,7 @@ Please run the command again with elevated rights (Run as Administrator) or prov
8081
process {
8182
$scopeCount = $Scope.Count
8283
Write-Verbose "[$functionName] - Processing [$scopeCount] scopes(s)"
83-
foreach ($scopeItem in $Scope) {
84-
$scopeName = $scopeItem.ToString()
85-
84+
foreach ($scopeName in $Scope) {
8685
$nameCount = $Name.Count
8786
Write-Verbose "[$functionName] - [$scopeName] - Processing [$nameCount] font(s)"
8887
foreach ($fontName in $Name) {
@@ -124,7 +123,7 @@ Please run the command again with elevated rights (Run as Administrator) or prov
124123
}
125124
}
126125

127-
if ($IsWindows) {
126+
if ($script:OS -eq 'Windows') {
128127
Write-Verbose "[$functionName] - [$scopeName] - [$fontName] - Searching for font in registry"
129128
$keys = Get-ItemProperty -Path $script:FontRegPathMap[$scopeName]
130129
$key = $keys.PSObject.Properties | Where-Object { $_.Value -eq $filePath }

src/manifest.psd1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
PowerShellVersion = '5.1'
3+
}

src/variables/private/common.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $script:FontFolderPathMap = @{
1818
}
1919
}
2020

21-
$script:OS = if ($IsWindows) {
21+
$script:OS = if ($IsWindows -or $PSEdition -eq 'Desktop') {
2222
'Windows'
2323
} elseif ($IsLinux) {
2424
'Linux'

0 commit comments

Comments
 (0)