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?
- Edited by Diversion00 19 hours 6 minutes ago