jaols / ADExportImport

3 stars 1 forks source link

Unable to run any Import as all 3 get the same "AllScope option cannot be removed" #6

Open StachStach opened 1 week ago

StachStach commented 1 week ago

This is a Great collection of scripts that I'm hoping to fully use. I have successfully Exported the OUs, Groups and Users to 3 separate files. However, when I try to run the import commands, as shown below, I get the same error every time. I'm using your default Import and Export settings files, but did rename them to the source domain (peroot.json) and new destination domain (qa-peroot.json). Like I said, the export works perfectly with the renamed settings file to peroot.json, so my question for the imports is:

The scripts speak of a mandatory parameter, which I'm assuming is the filename that I'm passing for the data. Are there other parameters that I'm missing? Also, if I comment out the other parameters in the script after the "data filename", then the script will run, but then I can't pass in the SetProperties switch.

Could you provide complete examples for running the powershell scripts and what the parameters should look like that can be passed?

Also, I would like to do the imports one type of object at a time (OUs, then Users, then Groups, then what), so could you list out the series of commands needed since the SetProperties switch needs to be set after running without it for the users and groups?

PS C:\Powershell\ADExportImport> .\Import-AdOuStructure.ps1 PEROOT.OU.2024-10-03.json WriteError: The AllScope option cannot be removed from the variable 'ImportExcludeAttributes'.

PS C:\Powershell\ADExportImport> .\Import-AdUsers.ps1 "PEROOT.Users.2024-10-03.json" WriteError: The AllScope option cannot be removed from the variable 'ImportExcludeAttributes'.

PS C:\Powershell\ADExportImport> .\Import-AdGroups.ps1 peroot.Groups.2024-10-04.json WriteError: The AllScope option cannot be removed from the variable 'ImportExcludeAttributes'.

Thanks in advance for your help!

jaols commented 1 week ago

When importing objects you need to run ALL imports to create empty AD-objects. This needs to be done as a member-list for a group cannot be set as there may be no users in place.

First copy the provided "Example for Import-Domain.json" to the target domain name (peroot.json?) Then check if you want to add any extra replacment texts in that file. Then run the first series of commands:

.\Import-AdOuStructure.ps1 -ImportFile PEROOT.OU.2024-10-03.json .\Import-AdUsers.ps1 -ImportFile "PEROOT.Users.2024-10-03.json" .\Import-AdGroups.ps1 -ImportFile "peroot.Groups.2024-10-04.json"

THEN use the same commands but add the -SetProperties option:

.\Import-AdOuStructure.ps1 -ImportFile PEROOT.OU.2024-10-03.json -SetProperties .\Import-AdUsers.ps1 -ImportFile "PEROOT.Users.2024-10-03.json" -SetProperties .\Import-AdGroups.ps1 -ImportFile "peroot.Groups.2024-10-04.json" -SetProperties

I do not understand where your error

"WriteError: The AllScope option cannot be removed from the variable 'ImportExcludeAttributes'."

comes from. It may come from some problem in the settings for the "Msg"-function, but that would not include 'ImportExcludeAttributes'.

Try using the -verbose option to get some information. There is a deeper description of how to configure the settings for "Msg" in the PSJumpstart module readme.md file here at GitHub.