diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 index acd5a45939..398bc49271 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 @@ -83,7 +83,7 @@ try $result = Get-Command NestedFn1 2> $null; return ($result -ne $null) '@ - $isCommandAccessible = powershell.exe -noprofile -nologo -c $command + $isCommandAccessible = pwsh.exe -noprofile -nologo -c $command } finally { diff --git a/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 b/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 index ef9eec8a0c..fb5d632765 100644 --- a/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 +++ b/test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1 @@ -104,7 +104,24 @@ function Initialize function Remove-InstalledModules { - Get-InstalledModule -Name $TestModule -AllVersions -ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module -Force + try { + $mod = Get-InstalledModule -Name $TestModule -AllVersions -ErrorAction SilentlyContinue + if ($null -eq $mod) { + return + } + + if (Get-Module -Name $TestModule -ErrorAction Ignore) { + Remove-Module -Force -Name $TestModule + } + + $installedPath = $mod.InstalledLocation + if (Test-Path $installedPath) { + Remove-Item -Force -Recurse $installedPath -ErrorAction Ignore + } + } + catch { + Write-Warning "Remove-InstalledModules: $_" + } } Describe "PowerShellGet - Module tests" -tags "Feature" { @@ -172,7 +189,20 @@ Describe "PowerShellGet - Module tests (Admin)" -Tags @('Feature', 'RequireAdmin function Remove-InstalledScripts { - Get-InstalledScript -Name $TestScript -ErrorAction SilentlyContinue | Uninstall-Script -Force + $installedScript = Get-InstalledScript -Name $TestScript -ErrorAction SilentlyContinue + if ($null -eq $installedScript) { + return + } + + $scriptPath = Join-Path ${installedScript}.InstalledLocation "${TestScript}.ps1" + if (test-Path -Type Leaf -Path $scriptPath) { + Remove-Item -Force -Path $scriptPath -ErrorAction Ignore + } + + $xmlPath = Join-Path ${installedScript}.InstalledLocation InstalledScriptInfos "${TestScript}_InstalledScriptInfo.xml" + if (test-Path -Type Leaf -Path $xmlPath) { + Remove-Item -Force -Path $xmlPath -ErrorAction Ignore + } } Describe "PowerShellGet - Script tests" -tags "Feature" {