-
Notifications
You must be signed in to change notification settings - Fork 72
Manual Execution of DSC Scripts
Roberto Rodriguez edited this page Oct 6, 2022
·
1 revision
First, RDP to the server where you want to execute your DSC scripts manually
If you want to update your script, you need to delete the MOF folder
Switch directory to C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3
cd C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3\
delete the PrepareAD-MSExchange
folder which contains MOF files.
Open the DSC script in C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3
folder and add the following at the end of the script:
$cd = @{
AllNodes = @(
@{
NodeName = 'localhost'
PSDscAllowPlainTextPassword = $true
PSDscAllowDomainUser = $true
}
)
}
PrepareAD-MSExchange -ConfigurationData $cd
Set-DscLocalConfigurationManager -Path .\PrepareAD-MSExchange -Verbose
Open PowerShell and run the following:
& C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3\PrepareAD-MSExchange.ps1 -verbose
You will be asked to pass parameters to the script. At the end you should be able to see something similar
PS C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3> & C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3\PrepareAD-MSExchange.ps1 -Verbose
cmdlet PrepareAD-MSExchange at command pipeline position 1
Supply values for the following parameters:
DomainFQDN: blacksmith.local
DomainController: DC01
AdminCreds
MXSISODirectory: C:\ProgramData
MXSRelease: MXS2016-x64-CU22-KB5005333
Directory: C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3\PrepareAD-MSExchange
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 10/6/2022 2:46 AM 16794 localhost.mof
-a---- 10/6/2022 2:46 AM 1152 localhost.meta.mof
VERBOSE: Performing the operation "Start-DscConfiguration: SendMetaConfigurationApply" on target "MSFT_DSCLocalConfigurationManager".
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendMetaConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer MXS01 with user sid S-1-5-21-1429921801-2150675542-1128058305-500.
VERBOSE: [MXS01]: LCM: [ Start Set ]
VERBOSE: [MXS01]: LCM: [ Start Resource ] [MSFT_DSCMetaConfiguration]
VERBOSE: [MXS01]: LCM: [ Start Set ] [MSFT_DSCMetaConfiguration]
VERBOSE: [MXS01]: LCM: [ End Set ] [MSFT_DSCMetaConfiguration] in 0.0070 seconds.
VERBOSE: [MXS01]: LCM: [ End Resource ] [MSFT_DSCMetaConfiguration]
VERBOSE: [MXS01]: LCM: [ End Set ]
VERBOSE: [MXS01]: LCM: [ End Set ] in 0.0850 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Set-DscLocalConfigurationManager finished in 0.194 seconds.
PS C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3>
Start-DscConfiguration -wait -force -path C:\Packages\Plugins\Microsoft.Powershell.DSC\2.83.2.0\DSCWork\PrepareAD-MSExchange.3\PrepareAD-MSExchange -Verbose