From fd47e152d3f3d036531980c8bf908b6b25055ed2 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Wed, 13 Mar 2019 11:09:56 -0700 Subject: [PATCH 1/5] **DISABLE_SECRET_SCANNING** From c00f461828e77087f0141499abe116d2dda57fb3 Mon Sep 17 00:00:00 2001 From: alerickson <25858831+alerickson@users.noreply.github.com> Date: Wed, 13 Mar 2019 17:37:26 -0700 Subject: [PATCH 2/5] Merge development to master (#440) --- CHANGELOG.md | 4 + SignCat.xml | 9 ++ SignConfig.xml | 23 ++++++ src/PowerShellGet/PowerShellGet.psd1 | 118 ++++++++++++++------------- 4 files changed, 97 insertions(+), 57 deletions(-) create mode 100644 SignCat.xml create mode 100644 SignConfig.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cc86553..7063ff90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 2.1.1 +- Fix DSC resource folder structure + ## 2.1.0 Breaking Change @@ -18,6 +21,7 @@ Bug Fixes New Features - New DSC resource, PSRepository (#426) (Thanks @johlju!) +- Added tests and integration of DSC resource PSModule (Thanks @johlju!) - Piping of PS respositories (#420) - utf8 support for .nuspec (#419) diff --git a/SignCat.xml b/SignCat.xml new file mode 100644 index 00000000..9b16b2d4 --- /dev/null +++ b/SignCat.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/SignConfig.xml b/SignConfig.xml new file mode 100644 index 00000000..d3d51d60 --- /dev/null +++ b/SignConfig.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/PowerShellGet/PowerShellGet.psd1 b/src/PowerShellGet/PowerShellGet.psd1 index 4c82b748..9df2d0eb 100644 --- a/src/PowerShellGet/PowerShellGet.psd1 +++ b/src/PowerShellGet/PowerShellGet.psd1 @@ -1,59 +1,63 @@ @{ -RootModule = 'PSModule.psm1' -ModuleVersion = '2.1.0' -GUID = '1d73a601-4a6c-43c5-ba3f-619b18bbb404' -Author = 'Microsoft Corporation' -CompanyName = 'Microsoft Corporation' -Copyright = '(c) Microsoft Corporation. All rights reserved.' -Description = 'PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, DSC Resources, Role Capabilities and Scripts.' -PowerShellVersion = '3.0' -FormatsToProcess = 'PSGet.Format.ps1xml' -FunctionsToExport = @( - 'Find-Command', - 'Find-DSCResource', - 'Find-Module', - 'Find-RoleCapability', - 'Find-Script', - 'Get-InstalledModule', - 'Get-InstalledScript', - 'Get-PSRepository', - 'Install-Module', - 'Install-Script', - 'New-ScriptFileInfo', - 'Publish-Module', - 'Publish-Script', - 'Register-PSRepository', - 'Save-Module', - 'Save-Script', - 'Set-PSRepository', - 'Test-ScriptFileInfo', - 'Uninstall-Module', - 'Uninstall-Script', - 'Unregister-PSRepository', - 'Update-Module', - 'Update-ModuleManifest', - 'Update-Script', - 'Update-ScriptFileInfo') - -VariablesToExport = "*" -AliasesToExport = @('inmo','fimo','upmo','pumo') -FileList = @('PSModule.psm1', - 'PSGet.Format.ps1xml', - 'PSGet.Resource.psd1') -RequiredModules = @(@{ModuleName='PackageManagement';ModuleVersion='1.1.7.0'}) -PrivateData = @{ - "PackageManagementProviders" = 'PSModule.psm1' - "SupportedPowerShellGetFormatVersions" = @('1.x','2.x') - PSData = @{ - Tags = @('Packagemanagement', - 'Provider', - 'PSEdition_Desktop', - 'PSEdition_Core', - 'Linux', - 'Mac') - ProjectUri = 'https://go.microsoft.com/fwlink/?LinkId=828955' - LicenseUri = 'https://go.microsoft.com/fwlink/?LinkId=829061' - ReleaseNotes = @' + RootModule = 'PSModule.psm1' + ModuleVersion = '2.1.1' + GUID = '1d73a601-4a6c-43c5-ba3f-619b18bbb404' + Author = 'Microsoft Corporation' + CompanyName = 'Microsoft Corporation' + Copyright = '(c) Microsoft Corporation. All rights reserved.' + Description = 'PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, DSC Resources, Role Capabilities and Scripts.' + PowerShellVersion = '3.0' + FormatsToProcess = 'PSGet.Format.ps1xml' + FunctionsToExport = @( + 'Find-Command', + 'Find-DSCResource', + 'Find-Module', + 'Find-RoleCapability', + 'Find-Script', + 'Get-InstalledModule', + 'Get-InstalledScript', + 'Get-PSRepository', + 'Install-Module', + 'Install-Script', + 'New-ScriptFileInfo', + 'Publish-Module', + 'Publish-Script', + 'Register-PSRepository', + 'Save-Module', + 'Save-Script', + 'Set-PSRepository', + 'Test-ScriptFileInfo', + 'Uninstall-Module', + 'Uninstall-Script', + 'Unregister-PSRepository', + 'Update-Module', + 'Update-ModuleManifest', + 'Update-Script', + 'Update-ScriptFileInfo') + + VariablesToExport = "*" + AliasesToExport = @('inmo', 'fimo', 'upmo', 'pumo') + FileList = @('PSModule.psm1', + 'PSGet.Format.ps1xml', + 'PSGet.Resource.psd1') + RequiredModules = @(@{ModuleName = 'PackageManagement'; ModuleVersion = '1.1.7.0'}) + PrivateData = @{ + "PackageManagementProviders" = 'PSModule.psm1' + "SupportedPowerShellGetFormatVersions" = @('1.x', '2.x') + PSData = @{ + Tags = @('Packagemanagement', + 'Provider', + 'PSEdition_Desktop', + 'PSEdition_Core', + 'Linux', + 'Mac') + ProjectUri = 'https://go.microsoft.com/fwlink/?LinkId=828955' + LicenseUri = 'https://go.microsoft.com/fwlink/?LinkId=829061' + ReleaseNotes = @' +## 2.1.1 + +- Fix DSC resource folder structure + ## 2.1.0 Breaking Change @@ -243,8 +247,8 @@ Bug fixes * Proxy Authentication support. * Responses to a number of user requests and issues. '@ + } } -} -HelpInfoURI = 'http://go.microsoft.com/fwlink/?linkid=855963' + HelpInfoURI = 'http://go.microsoft.com/fwlink/?linkid=855963' } From b8c0bfbfff13a5969264dc2eb14c41fac9e6318e Mon Sep 17 00:00:00 2001 From: Thomas Nieto <38873752+tnieto88@users.noreply.github.com> Date: Wed, 29 May 2019 19:49:13 -0500 Subject: [PATCH 3/5] Add PSGetPath public variable --- src/PowerShellGet/PowerShellGet.psd1 | 2 +- .../private/modulefile/PartOne.ps1 | 22 ++++++---- .../private/modulefile/PartTwo.ps1 | 42 ++++++++----------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/PowerShellGet/PowerShellGet.psd1 b/src/PowerShellGet/PowerShellGet.psd1 index f2babb35..7e3fc989 100644 --- a/src/PowerShellGet/PowerShellGet.psd1 +++ b/src/PowerShellGet/PowerShellGet.psd1 @@ -35,7 +35,7 @@ 'Update-Script', 'Update-ScriptFileInfo') - VariablesToExport = "*" + VariablesToExport = 'PSGetPath' AliasesToExport = @('inmo', 'fimo', 'upmo', 'pumo') FileList = @('PSModule.psm1', 'PSGet.Format.ps1xml', diff --git a/src/PowerShellGet/private/modulefile/PartOne.ps1 b/src/PowerShellGet/private/modulefile/PartOne.ps1 index 8f4ac695..1f287a3e 100644 --- a/src/PowerShellGet/private/modulefile/PartOne.ps1 +++ b/src/PowerShellGet/private/modulefile/PartOne.ps1 @@ -78,6 +78,14 @@ $script:MyDocumentsModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:ProgramFilesScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path $script:ProgramFilesPSPath -ChildPath 'Scripts' $script:MyDocumentsScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath 'Scripts' +$script:PSGetPath = [pscustomobject]@{ + AllUsersModules = $script:ProgramFilesModulesPath + AllUsersScripts = $script:ProgramFilesScriptsPath + CurrentUserModules = $script:MyDocumentsModulesPath + CurrentUserScripts = $script:MyDocumentsScriptsPath + PSTypeName = 'Microsoft.PowerShell.Commands.PSGetPath' +} + $script:TempPath = [System.IO.Path]::GetTempPath() $script:PSGetItemInfoFileName = "PSGetModuleInfo.xml" @@ -133,9 +141,9 @@ $script:NuGetProviderName = "NuGet" $script:NuGetProviderVersion = [Version]'2.8.5.201' $script:SupportsPSModulesFeatureName = "supports-powershell-modules" -$script:FastPackRefHashtable = @{} -$script:NuGetBinaryProgramDataPath = if ($script:IsWindows) {"$env:ProgramFiles\PackageManagement\ProviderAssemblies"} -$script:NuGetBinaryLocalAppDataPath = if ($script:IsWindows) {"$env:LOCALAPPDATA\PackageManagement\ProviderAssemblies"} +$script:FastPackRefHashtable = @{ } +$script:NuGetBinaryProgramDataPath = if ($script:IsWindows) { "$env:ProgramFiles\PackageManagement\ProviderAssemblies" } +$script:NuGetBinaryLocalAppDataPath = if ($script:IsWindows) { "$env:LOCALAPPDATA\PackageManagement\ProviderAssemblies" } # go fwlink for 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' $script:NuGetClientSourceURL = 'https://aka.ms/psget-nugetexe' $script:NuGetExeMinRequiredVersion = [Version]'4.1.0' @@ -261,7 +269,7 @@ $script:PackageManagementSaveModuleMessageResolverScriptBlock = { switch ($i) { 'ActionInstallPackage' { return "Save-Module" } - 'QueryInstallUntrustedPackage' {return $QuerySaveUntrustedPackage} + 'QueryInstallUntrustedPackage' { return $QuerySaveUntrustedPackage } 'TargetPackage' { return $PackageTarget } Default { $Message = $Message -creplace "Install", "Download" @@ -326,7 +334,7 @@ function PackageManagementMessageResolver($MsgID, $Message) { 'SourceNotFound' { return $SourceNotFound } 'CaptionPackageNotTrusted' { return $ModuleIsNotTrusted } 'CaptionSourceNotTrusted' { return $RepositoryIsNotTrusted } - 'QueryInstallUntrustedPackage' {return $QueryInstallUntrustedPackage} + 'QueryInstallUntrustedPackage' { return $QueryInstallUntrustedPackage } Default { if ($Message) { $tempMessage = $Message -creplace "PackageSource", "PSRepository" @@ -359,7 +367,7 @@ $script:PackageManagementSaveScriptMessageResolverScriptBlock = { switch ($i) { 'ActionInstallPackage' { return "Save-Script" } - 'QueryInstallUntrustedPackage' {return $QuerySaveUntrustedPackage} + 'QueryInstallUntrustedPackage' { return $QuerySaveUntrustedPackage } 'TargetPackage' { return $PackageTarget } Default { $Message = $Message -creplace "Install", "Download" @@ -418,7 +426,7 @@ function PackageManagementMessageResolverForScripts($MsgID, $Message) { 'SourceNotFound' { return $SourceNotFound } 'CaptionPackageNotTrusted' { return $ScriptIsNotTrusted } 'CaptionSourceNotTrusted' { return $RepositoryIsNotTrusted } - 'QueryInstallUntrustedPackage' {return $QueryInstallUntrustedPackage} + 'QueryInstallUntrustedPackage' { return $QueryInstallUntrustedPackage } Default { if ($Message) { $tempMessage = $Message -creplace "PackageSource", "PSRepository" diff --git a/src/PowerShellGet/private/modulefile/PartTwo.ps1 b/src/PowerShellGet/private/modulefile/PartTwo.ps1 index c30e82ca..3d9bec59 100644 --- a/src/PowerShellGet/private/modulefile/PartTwo.ps1 +++ b/src/PowerShellGet/private/modulefile/PartTwo.ps1 @@ -1,29 +1,26 @@ # Create install locations for scripts if they are not already created -if(-not (Microsoft.PowerShell.Management\Test-Path -Path $script:ProgramFilesInstalledScriptInfosPath) -and (Test-RunningAsElevated)) -{ +if (-not (Microsoft.PowerShell.Management\Test-Path -Path $script:ProgramFilesInstalledScriptInfosPath) -and (Test-RunningAsElevated)) { $ev = $null $null = Microsoft.PowerShell.Management\New-Item -Path $script:ProgramFilesInstalledScriptInfosPath ` - -ItemType Directory ` - -Force ` - -ErrorVariable ev ` - -ErrorAction SilentlyContinue ` - -WarningAction SilentlyContinue ` - -Confirm:$false ` - -WhatIf:$false + -ItemType Directory ` + -Force ` + -ErrorVariable ev ` + -ErrorAction SilentlyContinue ` + -WarningAction SilentlyContinue ` + -Confirm:$false ` + -WhatIf:$false - if($ev) - { + if ($ev) { $script:IsRunningAsElevated = $false } } -if(-not (Microsoft.PowerShell.Management\Test-Path -Path $script:MyDocumentsInstalledScriptInfosPath)) -{ +if (-not (Microsoft.PowerShell.Management\Test-Path -Path $script:MyDocumentsInstalledScriptInfosPath)) { $null = Microsoft.PowerShell.Management\New-Item -Path $script:MyDocumentsInstalledScriptInfosPath ` - -ItemType Directory ` - -Force ` - -Confirm:$false ` - -WhatIf:$false + -ItemType Directory ` + -Force ` + -Confirm:$false ` + -WhatIf:$false } # allow -repository params to be tab-completed @@ -49,10 +46,8 @@ $commandsWithRepositoryAsName = @( Add-ArgumentCompleter -Cmdlets $commandsWithRepositoryParameter -ParameterName "Repository" Add-ArgumentCompleter -Cmdlets $commandsWithRepositoryAsName -ParameterName "Name" -try -{ - if (Get-Command -Name Register-ArgumentCompleter -ErrorAction SilentlyContinue) - { +try { + if (Get-Command -Name Register-ArgumentCompleter -ErrorAction SilentlyContinue) { Register-ArgumentCompleter -CommandName Publish-Module -ParameterName Name -ScriptBlock { param ($commandName, $parameterName, $wordToComplete) @@ -62,8 +57,7 @@ try } } } -catch -{ +catch { # All this functionality is optional, so suppress errors Write-Debug -Message "Error registering argument completer: $_" } @@ -74,4 +68,4 @@ Set-Alias -Name upmo -Value Update-Module Set-Alias -Name pumo -Value Publish-Module Set-Alias -Name uimo -Value Uninstall-Module -Export-ModuleMember -Alias fimo, inmo, upmo, pumo, uimo +Export-ModuleMember -Alias fimo, inmo, upmo, pumo, uimo -Variable PSGetPath From b5384663ed8f5111e2f8af990eeaea999930f86b Mon Sep 17 00:00:00 2001 From: Thomas Nieto <38873752+tnieto88@users.noreply.github.com> Date: Wed, 29 May 2019 19:56:10 -0500 Subject: [PATCH 4/5] Add PSGetPath format --- src/PowerShellGet/PSGet.Format.ps1xml | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/PowerShellGet/PSGet.Format.ps1xml b/src/PowerShellGet/PSGet.Format.ps1xml index 370d1ca1..b6ea816b 100644 --- a/src/PowerShellGet/PSGet.Format.ps1xml +++ b/src/PowerShellGet/PSGet.Format.ps1xml @@ -17,7 +17,7 @@ 20 - + @@ -52,7 +52,7 @@ 20 - + @@ -87,7 +87,7 @@ 20 - + @@ -126,7 +126,7 @@ 35 - + @@ -164,7 +164,7 @@ 35 - + @@ -186,5 +186,31 @@ + + PSGetPath + + Microsoft.PowerShell.Commands.PSGetPath + + + + + + + AllUsersModules + + + AllUsersScripts + + + CurrentUserModules + + + CurrentUserScripts + + + + + + From 2db7d63f7e6d433845abb0bc5327196db37e92e6 Mon Sep 17 00:00:00 2001 From: Thomas Nieto <38873752+tnieto88@users.noreply.github.com> Date: Wed, 29 May 2019 20:04:08 -0500 Subject: [PATCH 5/5] Add PSGetPath tests --- Tests/PowerShellGet.Tests.ps1 | 118 ++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 54 deletions(-) diff --git a/Tests/PowerShellGet.Tests.ps1 b/Tests/PowerShellGet.Tests.ps1 index 6a922a82..8d59c761 100644 --- a/Tests/PowerShellGet.Tests.ps1 +++ b/Tests/PowerShellGet.Tests.ps1 @@ -19,12 +19,11 @@ function IsCoreCLR { $PSVersionTable.ContainsKey('PSEdition') -and $PSVersionTab #region Install locations for modules and scripts -if(IsInbox) -{ +if (IsInbox) { $script:ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell" } -elseif(IsCoreCLR){ - if(IsWindows) { +elseif (IsCoreCLR) { + if (IsWindows) { $script:ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramFiles -ChildPath 'PowerShell' } else { @@ -32,40 +31,31 @@ elseif(IsCoreCLR){ } } -try -{ +try { $script:MyDocumentsFolderPath = [Environment]::GetFolderPath("MyDocuments") } -catch -{ +catch { $script:MyDocumentsFolderPath = $null } -if(IsInbox) -{ - $script:MyDocumentsPSPath = if($script:MyDocumentsFolderPath) - { - Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath "WindowsPowerShell" - } - else - { - Microsoft.PowerShell.Management\Join-Path -Path $env:USERPROFILE -ChildPath "Documents\WindowsPowerShell" - } +if (IsInbox) { + $script:MyDocumentsPSPath = if ($script:MyDocumentsFolderPath) { + Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath "WindowsPowerShell" + } + else { + Microsoft.PowerShell.Management\Join-Path -Path $env:USERPROFILE -ChildPath "Documents\WindowsPowerShell" + } } -elseif(IsCoreCLR) { - if(IsWindows) - { - $script:MyDocumentsPSPath = if($script:MyDocumentsFolderPath) - { +elseif (IsCoreCLR) { + if (IsWindows) { + $script:MyDocumentsPSPath = if ($script:MyDocumentsFolderPath) { Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath 'PowerShell' - } - else - { + } + else { Microsoft.PowerShell.Management\Join-Path -Path $HOME -ChildPath "Documents\PowerShell" } } - else - { + else { $script:MyDocumentsPSPath = Split-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('USER_MODULES')) -Parent } } @@ -80,20 +70,17 @@ $script:MyDocumentsScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path #region Register a test repository -function Initialize -{ +function Initialize { # Cleaned up commands whose output to console by deleting or piping to Out-Null Import-Module PackageManagement Get-PackageProvider -ListAvailable | Out-Null $repo = Get-PSRepository -ErrorAction SilentlyContinue | - Where-Object {$_.SourceLocation.StartsWith($SourceLocation, [System.StringComparison]::OrdinalIgnoreCase)} - if($repo) - { + Where-Object { $_.SourceLocation.StartsWith($SourceLocation, [System.StringComparison]::OrdinalIgnoreCase) } + if ($repo) { $script:RepositoryName = $repo.Name } - else - { + else { Register-PSRepository -Name $RepositoryName -SourceLocation $SourceLocation -InstallationPolicy Trusted $script:RegisteredINTRepo = $true } @@ -101,11 +88,39 @@ function Initialize #endregion -function Remove-InstalledModules -{ +function Remove-InstalledModules { Get-InstalledModule -Name $ContosoServer -AllVersions -ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module -Force } +Describe "PowerShellGet - Module public variable tests" { + BeforeAll { + if ($script:Initialized -eq $false) { + Initialize + $script:Initialized = $true + } + } + + It "PSGetPath variable should exist" { + Test-Path -Path variable:PSGetPath | Should -BeTrue + } + + It "PSGetPath - AllUsersModules should be $ProgramFilesModulesPath" { + $PSGetPath.AllUsersModules | Should -Be $script:ProgramFilesModulesPath + } + + It "PSGetPath - AllUsersScripts should be $ProgramFilesScriptsPath" { + $PSGetPath.AllUsersScripts | Should -Be $script:ProgramFilesScriptsPath + } + + It "PSGetPath - CurrentUserModules should be $ProgramFilesModulesPath" { + $PSGetPath.CurrentUserModules | Should -Be $script:MyDocumentsModulesPath + } + + It "PSGetPath - CurrentUserScripts should be $ProgramFilesScriptsPath" { + $PSGetPath.CurrentUserScripts | Should -Be $script:MyDocumentsScriptsPath + } +} + Describe "PowerShellGet - Module tests" -tags "Feature" { BeforeAll { @@ -162,8 +177,7 @@ Describe "PowerShellGet - Module tests (Admin)" -tags @('Feature', 'RequireAdmin $installedModuleInfo | Should Not Be $null $installedModuleInfo.Name | Should Be $ContosoServer - if ($script:IsCoreCLR) - { + if ($script:IsCoreCLR) { $installedModuleInfo.InstalledLocation.StartsWith($script:MyDocumentsModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should Be $true } else { @@ -180,8 +194,7 @@ Describe "PowerShellGet - Module tests (Admin)" -tags @('Feature', 'RequireAdmin } } -function Remove-InstalledScripts -{ +function Remove-InstalledScripts { Get-InstalledScript -Name $FabrikamServerScript -ErrorAction SilentlyContinue | Uninstall-Script -Force } @@ -237,22 +250,20 @@ Describe "PowerShellGet - Script tests (Admin)" -tags @('Feature', 'RequireAdmin $installedScriptInfo | Should Not Be $null $installedScriptInfo.Name | Should Be $FabrikamServerScript - if ($script:IsCoreCLR) - { + if ($script:IsCoreCLR) { $installedScriptInfo.InstalledLocation.StartsWith($script:MyDocumentsScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should Be $true } - else - { + else { $installedScriptInfo.InstalledLocation.StartsWith($script:ProgramFilesScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should Be $true } - } + } AfterAll { Remove-InstalledScripts } } -Describe 'PowerShellGet Type tests' -tags @('BVT','CI') { +Describe 'PowerShellGet Type tests' -tags @('BVT', 'CI') { BeforeAll { Import-Module PowerShellGet -Force } @@ -263,15 +274,15 @@ Describe 'PowerShellGet Type tests' -tags @('BVT','CI') { InternalWebProxy = @('GetProxy', 'IsBypassed') } - if((IsWindows)) { - $PowerShellGetTypeDetails['CERT_CHAIN_POLICY_PARA'] = @('cbSize','dwFlags','pvExtraPolicyPara') - $PowerShellGetTypeDetails['CERT_CHAIN_POLICY_STATUS'] = @('cbSize','dwError','lChainIndex','lElementIndex','pvExtraPolicyStatus') + if ((IsWindows)) { + $PowerShellGetTypeDetails['CERT_CHAIN_POLICY_PARA'] = @('cbSize', 'dwFlags', 'pvExtraPolicyPara') + $PowerShellGetTypeDetails['CERT_CHAIN_POLICY_STATUS'] = @('cbSize', 'dwError', 'lChainIndex', 'lElementIndex', 'pvExtraPolicyStatus') $PowerShellGetTypeDetails['InternalSafeHandleZeroOrMinusOneIsInvalid'] = @('IsInvalid') - $PowerShellGetTypeDetails['InternalSafeX509ChainHandle'] = @('CertFreeCertificateChain','ReleaseHandle','InvalidHandle') + $PowerShellGetTypeDetails['InternalSafeX509ChainHandle'] = @('CertFreeCertificateChain', 'ReleaseHandle', 'InvalidHandle') $PowerShellGetTypeDetails['Win32Helpers'] = @('CertVerifyCertificateChainPolicy', 'CertDuplicateCertificateChain', 'IsMicrosoftCertificate') } - if('Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI' -as [Type]) { + if ('Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI' -as [Type]) { $PowerShellGetTypeDetails['Telemetry'] = @('TraceMessageArtifactsNotFound', 'TraceMessageNonPSGalleryRegistration') } @@ -284,7 +295,6 @@ Describe 'PowerShellGet Type tests' -tags @('BVT','CI') { } } -if($RegisteredINTRepo) -{ +if ($RegisteredINTRepo) { Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue | Unregister-PSRepository }