Skip to content

Set-Date did not work #5163

Description

@chucklu

Steps to reproduce

Set-Date -Date (Get-Date).AddDays(3)

I find this command on official document

Expected behavior

should change the datetime on my computer

Actual behavior

Set-Date : The parameter is incorrect
At line:1 char:1
+ Set-Date -Date (Get-Date).AddDays(3)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-Date], Win32Exception
    + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.6
OS                             Microsoft Windows 10.0.10586
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

I also checked the issue list, and find another issue about set-date test. I am not sure if they are the same issue.

Activity

  1. SteveL-MSFT commented on Jan 24, 2018

    @SteveL-MSFT
    Member

    This works on Ubuntu, but fails on Windows 10 for me

  2. stknohg commented on Jan 24, 2018

    @stknohg
    Contributor

    I reproduced this problem on Windows 10.

    Microsoft.PowerShell.Commands.SetDateCommand.SystemTime should be struct.

    internal static class NativeMethods
    {
    [StructLayout(LayoutKind.Sequential)]
    public class SystemTime
    {
    public UInt16 Year;
    public UInt16 Month;
    public UInt16 DayOfWeek;
    public UInt16 Day;
    public UInt16 Hour;
    public UInt16 Minute;
    public UInt16 Second;
    public UInt16 Milliseconds;
    }
    [DllImport(PinvokeDllNames.SetLocalTimeDllName, SetLastError = true)]
    public static extern bool SetLocalTime(ref SystemTime systime);
    } // NativeMethods

  3. MaximoTrinidad commented on Jan 24, 2018

    @MaximoTrinidad

    Confirmed!
    Works in Ubuntu but not Windows 10.

    ubuntusetdate_01_2018-01-24_9-18-40
    windowssetdate_01_2018-01-24_9-14-17

  4. chucklu commented on Jan 25, 2018

    @chucklu
    ContributorAuthor

    Maximo Trinidad (@MaximoTrinidad) I have checked the release list, the latest version is released five days ago with sha-1 2f81861.
    I will wait for next release version, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions