Below is what I'm trying to do. When the script runs, I want it to parse the csv for accounts that have not been moved, move them, then update the two fields for that account. I can't find a good blog article on manipulating a csv.
CSV is formatted like so: UserPrincipalName,MoveInitiated,MoveDate [email protected],, #Read CSV $UsersToMove = Import-Csv -Path E:\AutomationScripts\O365Automation\Users_to_Move_on_Prem.csv | Select UserPrincipalName, MoveInitiated, MoveDate | Where-Object {$_.MoveInitiated -ne "Yes"} | ForEach-Object { #Set variable to use later. $UserPrincipalName = $_.UserPrincipalName #Initiate the mailbox move. new-moverequest -identity $UserPrincipalName -OutBound -RemoteTargetDatabase 'Mailbox Database' -RemoteHostName 'exchange.domain.com' -RemoteCredential $mycred1 -TargetDeliveryDomain 'domain.mail.onmicrosoft.com' #Update the values in the CSV $MoveDateValue = Get-Date -Format d $UpdateCsv = Import-Csv -Path E:\AutomationScripts\O365Automation\Users_to_Move_on_Prem.csv | Select UserPrincipalName, MoveInitiated, MoveDate | Where-Object {$_.UserPrincipalName -eq $UserPrincipalName} | ForEach-Object { $_.MoveInitiated = "Yes"; $_ $_.MoveDate = $MoveDateValue} | Export-Csv -Path E:\AutomationScripts\O365Automation\Users_to_Move_on_Prem.csv -NoTypeInformation } Christopher Catlett Consultant | Detroit [MCTS_2013_small] Sogeti USA Office 248-876-9738 |Fax 877.406.9647 26957 Northwestern Highway, Suite 130, Southfield, MI 48033-8456 www.us.sogeti.com<http://www.us.sogeti.com/> ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1
<<inline: image001.jpg>>
