Change Microsoft.PowerShell.Commands.SetDateCommand.SystemTime to struct. (#6006)
Change Microsoft.PowerShell.Commands.SetDateCommand.SystemTime class to struct and resolve the error in Set-Date cmdlet - SetLocalTime function is causing a parameter error (error code 0x00000057).
This commit is contained in:
parent
874f5c1a85
commit
f86371e347
|
@ -117,7 +117,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
internal static class NativeMethods
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class SystemTime
|
||||
public struct SystemTime
|
||||
{
|
||||
public UInt16 Year;
|
||||
public UInt16 Month;
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue