Adventures in Powershell. These posts have been created as a record of the successful powershell commands I have used.
Sunday, August 21, 2016
Change the file date
Here's a little look at file properties and particularly changing the date.
This lists all the properties you might want to use/set/mess with
get-item "c:\test.txt" | get-member *
This list the time relevent properties
get-item "c:\test.txt" | get-member *time
This changes the CreationTime (remember to use US date format)
get-item "c:\test.txt" | % {$_.CreationTime = '07/28/2016 15:28'}
keywords metadata
Here's an explanation of the % sign usage courtesy of Jeffery Hicks who posted this here
The % symbol is also an alias for ForEach-Object. You would use it in an
expression like this:
cat servers.txt | % { get-wmiobject win32_operatingsystem -computer $_}
And you're right, it is also the modulo operator. In the example you saw,
the expression went through numbers 0 to 15 and formatted them using the -f
operator. The $_ is the current object in the pipeline, ie the numbers 0
through 15.
Hope this explanation helps.
--
Jeffery Hicks MCSE, MCSA, MCT
Microsoft PowerShell MVP