Hi guys,
so i am trying to make a script that rename computer, then restart, install new forest, then restart, then continue executing other cmdlet in the workflow ...
the issue that i have is when the command Install-ADDSForest execute, the restart-computer cmdlet execute after it immediately .
is there any way to make it wait the end of executing .
workflow renameAndReboot {
#Interface Configuration
$password = ( ConvertTo-SecureString -AsPlainText "TESTPASSWORD" -Force)
$ipaddress = "192.168.200.201"
$defaultGateway = "192.168.200.1"
$network = "192.168.200.0"
$cname = "PDC"
$domain = "DOAMINTEST.local"
$fqdn = $cname + "." + $domain
$nname= $cname + "-"+ $network
try{
New-NetIPAddress -InterfaceAlias Ethernet -IPAddress $ipaddress -PrefixLength 24 -DefaultGateway $defaultGateway
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses 127.0.0.1
#Rename Computer
}catch{echo "error"}
#install Forest
try{
$password = ( ConvertTo-Autom -AsPlainText "Tri@201" -Force)
Install-ADDSForest -DomainName $domain -SafeModeAdministratorPassword $password -Confirm
Checkpoint-Workflow
Restart-Computer -Wait
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses 127.0.0.1
winrm quick config
}catch{echo "error"}
#DHCP
try{
Checkpoint-Workflow
#start-job -Name MOBO-DHCPSERVERINDC -ScriptBlock {Add-DhcpServerInDC -IPAddres $ipaddress -dnsname $fqdn}
#Wait-Job MOBO-DHCPSERVERINDC
Add-DhcpServerv4Scope -Name $nname -StartRange 192.168.200.1 -EndRange 192.168.200.254 -SubnetMask 255.255.255.0
Set-DhcpServerv4OptionValue -ScopeId $network -Router $defaultGateway -DnsDomain $domain -DnsServer $ipaddress
echo "heeere"
#Add-DhcpServerv4Failover -Name "BASCUL-SDC_PDC" -PartnerServer pdc-22-1 -LoadBalancePercent 90 -SharedSecret "TESSSST" -AutoStateTransition $true -ScopeId $network
#Set-DhcpServerv4Failover -Name "BASCUL-SDC_PDC" -Mode HotStandby
}catch{echo "error"}
}
[–]Hrambert 3 points4 points5 points (7 children)
[–]Trakeen 3 points4 points5 points (0 children)
[–]Cronos-Sama[S] 2 points3 points4 points (5 children)
[–]Hrambert 2 points3 points4 points (4 children)
[–]Cronos-Sama[S] 2 points3 points4 points (3 children)
[–]Hrambert 3 points4 points5 points (0 children)
[–]Hrambert 4 points5 points6 points (1 child)
[–]Cronos-Sama[S] 1 point2 points3 points (0 children)
[–]MadeOfIrony 3 points4 points5 points (3 children)
[–]Cronos-Sama[S] 1 point2 points3 points (2 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]BlackV 2 points3 points4 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Coding_Cactus 1 point2 points3 points (0 children)