0

My goal is to make a PS script that creates a CSV file with specefied domain users given name and a timestamp when that user was last modified in unix timestamp format.

I have figured out everything except how to convert the "Modified" AD Attribute value to unix timestamp and how to use that inline in the Select-Object "loop"

I have the following:

get-aduser -filter {name -like test} -property GivenName, Modified | Select-Object GivenName, Modified | Export-CSV -path C:\PS\user.csv

That gives me the following output

Test,2016-02-09 11:48:48

How do i go about doing something like this?:

...| Select-Object GivenName, Modified.convertedToUnixTimestamp() |...
2

2 Answers 2

1

Found it out myself:

get-aduser -filter {name -like "Test*"} -property GivenName, Modified | Select-Object GivenName, @{name="Modified_unix";Expression={Get-Date -date $_.modified -UFormat %s}} | Export-CSV -path C:\PS\user.csv
Sign up to request clarification or add additional context in comments.

1 Comment

FYI This is called a calculated property.
0

Using the link in the comments, try something like this to change the property in the pipe:

... | Select-Object GivenName,@{n="unixtimestamp";e={$_.Modified -UFormat ℅s}} |...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.