Hi guys, been a while since I posted - guess my code is getting better!!
I’ve been working on writing a huge DC promotion tool for our servers here, which is specific to Windows Server 2012 and 2016, in an attempt to provide a single script to promote either version to our root domain, or 4 child domains.
It basically does a whole bunch of validation, user input and reporting, and generates an answer file as it goes.
The issue I’m having however happens normally after a reboot. The script handles reboots in a simple drop-and-run type deployment, which writes a batch file to the Startup start menu folder. This just calls the dropper script again to resume from where it left off. When this happens, the first part of the script always loads in the required modules. When you manually kick the script off for the first time, it gets through this section just fine. However, when the script gets called through the batch file, it gives me a non-critical but nonthelesss weird error when trying to import modules. Specifically this error is generated by the ‘ServerManager’ PS module…
Exception calling "Translate" with "1" argument(s): "Some or all identity references could not be translated." At C:\Windows\system32\WindowsPOwershell\v1.0\Modules\servermanager\ServerManager.psm1:32 char 21
In all my years using PowerShell, I have never, not once, seen that message appear when trying to import modules. Let alone the servermanager module.
The code used to import is:
# Load modules Write-Host "`nInitialising modules..." -foregroundcolor yellow Import-Module servermanager | Out-Null Add-WindowsFeature RSAT-AD-PowerShell,RSAT-AD-AdminCenter | Out-Null Import-Module activedirectory,dnsclient | Out-Null
Basic stuff. Works fine when manually executing script, but if you kick it off outside PowerShell it throws up that weird error. Script continues and functions normally, I just dont like seeing sea’s of red text for no reason!
Any ideas?