SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 476 | Next

Steve Seguis

"Microsoft Windows Server 2008 Administration"

In the United States, for example, the beginning and
end of daylight savings time was shifted, so any system that was time-sensitive needed
to be aware of this change. One of the nice methods included with the Get-Date cmdlet
is the IsDaylightSavingTime method. It returns whether the current date and time
are adjusted for daylight savings time in the current locale:
(Get-Date).IsDaylightSavingTime()
Whenever I write scripts that generate log files, I typically like to give them names
that are based on the current date and time. Not only does this guarantee uniqueness,
but it also lets me quickly determine when a log file was created. Let??™s say I wanted to
generate a string that represents the time so I could later use it in a file name. I could use
the following script to get the job done:
$filename = "myfile"
$datestring = Get-Date -uformat %Y%M%d
$newfilename = $filename + "_" + $datestring + ".txt"
Write-Host $newfilename
You should be able to follow this code snippet. I define a file name and then generate
a string that represents the current date. I then combine the file name with an underscore
character, the date string, and the file extension to generate a new file name that is output
to the screen. The interesting part is the second line. The -uformat switch of the Get-
Date cmdlet technically stands for UNIX format. It??™s not that we will use this in UNIX,
but that you can then define how the date will be presented using a set of modifiers.


Pages:
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
druga wojna światowa Free English grammar and study guid hotel jelenia góra Russian bride counter strike 1.6