Powershell Import-GPO : The Data Is Invalid Fixed
By: Brenton Blawat
This article is to aid those who are receiving the “Data is Invalid” error message in Powershell on Windows Server 2008 R2. This issue occurs while trying to import policies from one domain into their a different domain using a migration table. This issue has to do with the migration table editor referring to the “Pre-Windows 2000 Username” to migrate users instead of their Standard Username.
Syntax of Command Used for Error:
Import-GPO –BackupID {GUIDGOESHERE} –TargetName “Default_AccountingPolicy” –path “c:\scriptloc\” –MigrationTable “C:\scriptloc\DefaultMig.migtable” –CreateIfNeeded | Out-Null
Error:
“ Import-GPO : The Data is invalid. (Exception from HRESULT: 0x8007000D) “
Solution:
The issue has to do with creating Users and User Groups without the ‘SAMACCOUNTNAME’ field while coding with Powershell. Windows Server 2008 R2 generates a unique Pre-2000 username starting with ‘$’ and a series of numbers following. When using the ‘-migrationtable’ trigger, it causes import-gpo cmdlet to validate the “destination users” PRIOR to importing the group policy. If it cannot resolve the User or User group, it will cause the ‘’HRESULT error’.
The following lines were added to the Powershell Script for creating a User Group, which corrected this issue:
1: # Where $objworker was the AD method and $ADobjname was the name of the user / group
2: $objworker.put("sAMAccountName", "$ADobjname")
3: $objworker.SetInfo()
Depending on your network, the fix can be done in two ways:
- Ensure the “Pre-Windows 2000 name” is the same as the “Standard Windows Name”
- Correct the Migration Table to Use the Pre-Windows 2000 Names for the ‘Destination’
Simple fix – just wish that the error would be more like “Errors in Migration Table”. The error message of “The Data Is Invalid “ is useless in my opinion.
Happy Coding!



I came across the same error when using the Copy-GPO command. It turns out that my .migtable file did not have enough entries. My source GPO has lots of folder redirections and my .migtable file did not have an entry for the Downloads redirection. Once I added that entry everthing worked fine.
Box293
October 11, 2011
Thanks for the comment!
brentblawat
October 11, 2011