Working with Move-Mailbox XML file


hello,

i'm still new powershell, , i'm working on move mailbox script. know after each user move create xml file. inside xml file there 2 lines i'm interested in, main 1 error code , status of move.

<result iswarning="false" errorcode="0">this mailbox has been moved target database.</result>

basically need after each user move check xml file user, status , write sql database. i've never worked xml files in powershell , honest never dealt xml files in general.

i searched around , saw import-clixml gives me schema error when trying import, found way

$usermoved = [xml] (get-content mailboxmove.xml)

at point there isnt can it, when type $usermoved returns 2 properties , bunch of methods. 2 properties are
xml blank
move-mailbox move-mailbox

can give me quick run down on how work xml file , error status line set variable, once line in variable easy part writing variable sql table.

thanks

if want error code:

$usermoved = [xml](get-content "c:\mailboxmove.xml")
$errorcode = $usermoved."move-mailbox".taskdetails.item.result.errorcode

thing may want consider using single xml report file every mailbox move. error code , warning status each mailbox using code:

$usermoved = [xml](get-content "c:\mailboxmove.xml")
$usermoved."move-mailbox".taskdetails.item | select mailboxname,@{n="errorcode";e={$_.result.errorcode}},@{n="warning";e={$_.result.iswarning}}

output this:

mailboxname   errorcode  warning
-----------        ---------      -------
administrator   0               false
testuser0001   0               false


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607