diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/SetDateCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/SetDateCommand.cs index 11e6b12d4ed..1f7e91e8230 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/SetDateCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/SetDateCommand.cs @@ -117,7 +117,7 @@ protected override void ProcessRecord() internal static class NativeMethods { [StructLayout(LayoutKind.Sequential)] - public class SystemTime + public struct SystemTime { public UInt16 Year; public UInt16 Month; diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 index c313ac4965d..8a7f664e854 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 @@ -7,11 +7,16 @@ Describe "Set-Date" -Tag "CI" { } It "Set-Date should be able to set the date in an elevated context" -Skip:(! $IsElevated) { - { get-date | set-date } | Should not throw + { Get-Date | Set-Date } | Should Not Throw + } + + It "Set-Date should be able to set the date with -Date parameter" -Skip:(! $IsElevated) { + $target = Get-Date + $expected = $target + Set-Date -Date $target | Should Be $expected } It "Set-Date should produce an error in a non-elevated context" -Skip:($IsElevated) { - { get-date | set-date} | should throw - $Error[0].FullyQualifiedErrorId | should be "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand" + { Get-Date | Set-Date } | ShouldBeErrorId "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand" } }