Skip to content

Commit 70a6c7c

Browse files
Remove Platform Not Supported Exception
1 parent 90f842c commit 70a6c7c

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/code/GroupPolicyRepositoryEnforcement.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public static bool IsGroupPolicyEnabled()
3333
{
3434
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
3535
{
36-
throw new PlatformNotSupportedException("Group policy is only supported on Windows.");
36+
// Always return false for non-Windows platforms and Group Policy is not available.
37+
return false;
3738
}
3839

3940
if (InternalHooks.EnableGPRegistryHook)

test/GroupPolicyEnforcement.Tests.ps1

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,11 @@ Describe 'GroupPolicyEnforcement API Tests' -Tags 'CI' {
88

99
It 'Should return the correct policy enforcement status' -Skip:(-not $IsWindows) {
1010
$actualStatus = [Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement]::IsGroupPolicyEnabled()
11-
$actualStatus | Should -Be $false
11+
$actualStatus | Should -BeFalse
1212
}
1313

1414
It 'Should return platform not supported exception on non-windows platform' -Skip:$IsWindows {
15-
try {
16-
[Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement]::IsGroupPolicyEnabled()
17-
}
18-
catch {
19-
$_.Exception.Message | Should -Be 'Group Policy is not supported on this platform.'
20-
$_.Exception.InnerException.GetType().FullName | Should -Be 'System.InvalidOperationException'
21-
}
15+
[Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement]::IsGroupPolicyEnabled() | Should -BeTrue
2216
}
2317

2418
It 'Group Policy must be enabled before getting allowed repositories' -Skip:(-not $IsWindows) {
@@ -54,7 +48,7 @@ Describe 'GroupPolicyEnforcement Cmdlet Tests' -Tags 'CI' {
5448
Register-PSResourceRepository -Name 'Example' -Uri 'https://www.example.com/'
5549
$psrep = Get-PSResourceRepository -Name 'Example'
5650
$psrep | Should -Not -BeNullOrEmpty
57-
$psrep.IsAllowedByPolicy | Should -Be $true
51+
$psrep.IsAllowedByPolicy | Should -BeTrue
5852
}
5953
finally {
6054
Unregister-PSResourceRepository -Name 'Example'

0 commit comments

Comments
 (0)