Skip to content

Commit 07399b3

Browse files
SteveL-MSFTkilasuit
authored andcommitted
Add back Get-HotFix cmdlet (PowerShell#10740)
1 parent 5729d9b commit 07399b3

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,16 @@ protected override void ProcessRecord()
8787
foreach (string computer in ComputerName)
8888
{
8989
bool foundRecord = false;
90-
StringBuilder queryString = new StringBuilder();
91-
ManagementScope scope = new ManagementScope(ComputerWMIHelper.GetScopeString(computer, ComputerWMIHelper.WMI_Path_CIM), _connectionOptions);
90+
StringBuilder QueryString = new StringBuilder();
91+
ConnectionOptions conOptions = new ConnectionOptions
92+
{
93+
Authentication = AuthenticationLevel.Packet,
94+
Impersonation = ImpersonationLevel.Impersonate,
95+
Username = Credential?.UserName,
96+
SecurePassword = Credential?.Password
97+
};
98+
99+
ManagementScope scope = new ManagementScope(ComputerWMIHelper.GetScopeString(computer, ComputerWMIHelper.WMI_Path_CIM), conOptions);
92100
scope.Connect();
93101
if (Id != null)
94102
{

src/Modules/Windows/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,5 @@ CmdletsToExport=@("Add-Content",
6969
"Get-ComputerInfo",
7070
"Get-TimeZone",
7171
"Set-TimeZone",
72-
"Get-HotFix",
73-
"Clear-RecycleBin")
72+
"Get-HotFix")
7473
}

test/powershell/Modules/Microsoft.PowerShell.Management/Get-HotFix.Tests.ps1

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,4 @@ Describe "Get-HotFix Tests" -Tag CI {
5858
$hotfixes = Get-HotFix -ComputerName localhost
5959
$hotfixes.Count | Should -Be $qfe.Count
6060
}
61-
62-
It "Get-Hotfix can accept ComputerName via pipeline" {
63-
{ [PSCustomObject]@{ComputerName = 'UnavailableComputer'} | Get-HotFix } |Should -Throw -ErrorID 'Microsoft.PowerShell.Commands.GetHotFixCommand'
64-
[PSCustomObject]@{ComputerName = 'localhost'} | Get-HotFix | Should -Not -BeNullOrEmpty
65-
}
6661
}

0 commit comments

Comments
 (0)