Working with PowerShell for my Office 365 projects, I have created a couple of scripts to provision users and to run through and assign users specific address books.
One of things I do is dump all my new users to a CSV file. However, I want a file created each time its run showing me which users are created.
First thing is to make a variable with the current date in the format you would like.
$CurrentDate = Get-Date -format dd.MMM.yyyy
Next I create the filename in a variable using the combination of the filename I want and the date variable. (The code is all one line, but might not display that way here.)
$filename1 = "c:\Export\Users\Provision-Student" + $CurrentDate + ".csv"
Finally I then call the file by piping a command to export-csv.
Get-MsolUsers -All Domain "contoso.com"| Select UserPrincipalName | export-csv -path $filename1
I schedule this to run once daily and every day I have a file all my users in the contoso.com domain.
In another post I’ll show you how to clean up these files so you aren’t overrun with them.