Quantcast
Channel: Configuration Manager 2012 - Operating System Deployment forum
Viewing all articles
Browse latest Browse all 9126

unjoin domain & uninstall configmgr client in task sequence

$
0
0

Hi there,

because of several reasons i tried to setup a task sequence for our windows 7 OSD to

1. unjoin the domain (=join workgroup) with a powershell-script and

2. uninstall configmgr client.



so here is my script for unjoining the domain:

$WID=[System.Security.Principal.WindowsIdentity]::GetCurrent();
$WIP=new-object System.Security.Principal.WindowsPrincipal($WID);
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator;
If ($WIP.IsInRole($adminRole)){
}else {
  $newProcess = new-object System.Diagnostics.ProcessStartInfo 'PowerShell';
  $newProcess.Arguments = $myInvocation.MyCommand.Definition
  $newProcess.Verb = 'runas'
  [System.Diagnostics.Process]::Start($newProcess);Write-Host 'Prompting for Elevation'
  exit
}
#####################
# Add Scripts Below #
#####################
$Workgroup = "private" #IF you want to add computer to domain edit here(Domain name)
$Password = "******" | ConvertTo-SecureString -asPlainText -Force
$Username = "$domain\username"
$Credential = New-Object System.Management.Automation.PSCredential($Username,$Password)
Add-Computer -WorkGroup $Workgroup -Credential $credential -Force

the script does work when executed manually but does not work in task sequence.

also i am not quite sure in which order both steps should be executed and if this is really possible!

does anyone have experience with unjoining the domain in the task sequence?




Viewing all articles
Browse latest Browse all 9126

Trending Articles



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