Quantcast
Channel: Configuration Manager 2007 Operating System Deployment forum
Viewing all articles
Browse latest Browse all 1063

Cannot import ActiveDirectory PowerShell module during OSD

$
0
0

I am attempting to run a script during OSD to move the OU of the current computer to support our Windows 7 migration. I have the Windows 7 RSAT installed with the ActiveDirectory PowerShell feature enabled in the base WIM image. We are running PowerShell 3.0 on Windows 7 SP1 x64.

My command line is:

powershell.exe -NoLogo -ExecutionPolicy Bypass -NoProfile -Command "& {Import-Module ActiveDirectory; Get-ADComputer $env:ComputerName | Move-ADObject -TargetPath ('%OSDDomainOUName%').Substring(7)}"

and is set to run as a specific (Domain Admin) account. If I run this command in the full Windows it completes successfully (via RunAs). If I run it during the OSD process, I get the following errors in SMSTS.log

Attempting to perform the InitializeDefaultDrives operation on the 'FileSystem' provider failed. Import-Module : Access to the path 'PowerShell_CommandAnalysis_Lock' is denied. At line:1 char:4
+ & {Import-Module ActiveDirectory; Get-ADComputer $env:ComputerName |Move-ADObje ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.ImportModuleCommand

Move-ADObject : The operation could not be performed because the object's parent is either uninstantiated or deleted
At line:1 char:70
+ & {Import-Module ActiveDirectory; Get-ADComputer $env:ComputerName | Move-ADObje ... 
+                                                                      ~~~~~~~~~~~ 
   + CategoryInfo          : NotSpecified: (CN=TESTOSD2,OU=...:ADComputer) [Move-ADObject], ADException 
    + FullyQualifiedErrorId : The operation could not be performed because the object's parent is either uninstantiated or deleted,Microsoft.ActiveDirectory.Management.Commands.MoveADObject



Viewing all articles
Browse latest Browse all 1063

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>