codaamok / PoSH

A collection of PowerShell scripts I've written.
MIT License
24 stars 6 forks source link

Invoke-InstallCM.ps1 - Erroraction set to Stop if 'NO_SMS_ON_DRIVE.SMS' already exists #6

Closed hkystar35 closed 4 years ago

hkystar35 commented 4 years ago

Working through some other issues with the AutomatedLab build for ConfigMgr TP 2002 baseline, when re-running the script, it throws a terminating error if NO_SMS_ON_DRIVE.SMS already exists on the target VM for the ConfigMgr Primary Site Server. I'm guessing this is left as a check in case the environment is already up and running, but it would be great to have a way to ignore this for cases like re-running the CM-2002.ps1 build.

Adding a switch to cm-2002.ps1 -IgnoreExistingSteps or something similar would be great to avoid this, especially while troubleshooting the actual ConfigMgr TP install issues so it takes less time to re-run.

Full error:

10:38:24|00:11:50|00:00:00.000|       - Bringing online additional disks
10:38:24|00:11:50|00:00:00.265|         - ..
10:38:28|00:11:54|00:00:04.295|         - Activity done
10:38:28|00:11:54|00:00:00.000|       - Saving NO_SMS_ON_DRIVE.SMS file on C: and F:
10:38:28|00:11:54|00:00:00.223|         - ..
10:38:29|00:11:54|00:00:00.251|         - Failed to create NO_SMS_ON_DRIVE.SMS (The file 'C:\NO_SMS_ON_DRIVE.SMS' already exists.)
System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The file 'C:\NO_SMS_ON_DRIVE.SMS' already exists.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
At C:\LabSources\CustomRoles\CM-2002\Invoke-InstallCM.ps1:330 char:9
+         throw $ReceiveJobErr
+         ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (System.Collections.ArrayList:ArrayList) [], RuntimeException
    + FullyQualifiedErrorId : System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The file 'C:\NO_SMS_ON_DRIVE.SMS' already exists.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
codaamok commented 4 years ago

I've addressed that NO_SMS_ON_DRIVE.SMS file already exists issue for now. I will continue to ponder about the -IgnoreExistingSteps idea (and allowing static IP config for DC + CM like we discussed in Discord)

Cheers for your help