• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Quick and dirty Power shell help

SimonMac

TykeLike
Joined
Aug 27, 2010
Messages
24,897
Likes received
5,244
Thanks received
1,850
Location
God's Own Republic Of Yorkshire
Code:
  $date = Get-Date ($_.LastWriteTime)

returns the date as a number, how would I get it to return JAN/FEB/etc?

Code:
  $date = Get-Date -format D ($_.LastWriteTime)

Doesn't seem to work
 
Code:
  $date = Get-Date ($_.LastWriteTime)

returns the date as a number, how would I get it to return JAN/FEB/etc?

Code:
  $date = Get-Date -format D ($_.LastWriteTime)

Doesn't seem to work

Scrap that :D
 
Last edited: 16:29
not sure why and how you are putting that object into a variable but to format a date

get-date -f dd/MMM/yyy



uppercase here refers to month lower case m's give minutes
 
not sure why and how you are putting that object into a variable but to format a date

get-date -f dd/MMM/yyy



uppercase here refers to month lower case m's give minutes

I thought Windows wasn't case-sensitive?
 
it is(can) be in powershell

to work in date and time formats

MM is months mm is minutes if you dont believe me try it
 
it is(can) be in powershell

to work in date and time formats

MM is months mm is minutes if you dont believe me try it

Not saying I don't believe you, just odd. Conversely similar in Unix, case sometimes is ignored.

'nslookup host1' and 'nslookup HOST1' both return the same correct resolution. Here Unix ignores case - just find it interesting....
 
i'm used to using both so i tend to obey case even where it is not necessary,
powershell tries to be clever, and usually succeeds, in working out case, just can be unnecessarily verbose at times
 

Advertisers

Back
Top