Powershell - Set System Date


Advertisements

Cmdlet

Set-Date cmdlet is used to set System Date.

In this example, we're using Get-Date to get current date

Type the following command in PowerShell ISE Console

Get-Date

Output

You can see following output in PowerShell console.

Get-Date
Saturday, May 05, 2018 9:58:06 AM

In this example, we're using Set-Date to add one more day to current date.

Type the following command in PowerShell ISE Console

set-date -Date (Get-Date).AddDays(1)

Output

You can see following output in PowerShell console.

Sunday, May 06, 2018 9:59:16 AM

Now revert back to substract added day to current date.

Type the following command in PowerShell ISE Console

set-date -Date (Get-Date).AddDays(-1)

Output

You can see following output in PowerShell console.

Saturday, May 05, 2018 10:00:37 AM
powershell_dates_timers.htm
Advertisements