The tricky bit that I got stuck on was when i tried Get-date I tried like this thinking it would work.
$users | Export-Csv c:\temp\LNCUS-$(Get-Date -format dd-MM-yyyy) .csv -NoTypeInformation
The error happens because the output from Get-Date is not in a string format. To fix this we just need to convert the date format to string by doing the following
$users | Export-Csv c:\temp\LNCUS-$((Get-Date).ToString('MM-dd-yyyy')).csv -NoTypeInformation
If you find this article useful please leave me a comment or click on an ad to show your support.
thanks for keeping it simple and easy
ReplyDeleteThis got my logs going. Thank you.
ReplyDeleteNot a problem. Thanks for reading and taking the time to comment.
ReplyDeleteHey Joe, thanks for taking the time to put this together. Clear, concise and correct. I appreciate it.
ReplyDeleteHow about storing the Get-date in a variable? That will give a clean look to the script.
ReplyDelete$CurrentDate = Get-Date
$CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hh-mm-ss')
$CurrentDate = Get-Date
ReplyDelete$CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hh-mm-ss')
very helpful, thanks!
ReplyDelete