Hi there,

My client requested to remove 150 PCs from domain for training. I have created a powershell and worked on the PC, but I couldn't get it to work via KACE.
Here is my script
$credential = New-Object System.Management.Automation.PsCredential("domain\adminaccount", (ConvertTo-SecureString "password" -AsPlainText -Force))
Remove-computer -Credential $credential -Force -passthru -verbose;Restart-Computer

I found a post here that suggested to push the powershell as an application. I created a distribution

The command is
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -executionpolicy bypass -noprofile -file "$(KACE_DEPENDENCY_DIR)\RemovefromDomain.ps1"
I have also tried like
powershell.exe -nologo -executionpolicy bypass -noprofile -file "RemovefromDomain.ps1"
The script download fine to KACE download folder on C drive but doesn't seem to run correctly. I am not sure where and how to check why is not running correctly.

Thanks in advance

Answer Summary:
0 Comments   [ + ] Show Comments


Please log in to comment

Answer Chosen by the Author

you can do this with wmic also

wmic.exe /interactive:off ComputerSystem Where "Name='%computername%'" Call UnJoinDomainOrWorkgroup FUnjoinOptions=0
wmic.exe /interactive:off ComputerSystem Where "Name='%computername%'" Call JoinDomainOrWorkgroup name="WORKGROUP"
Answered 07/14/2015 by: SMal.tmcc
Red Belt

  • Thanks so much. I got this working using your command. I pushed it out as an application and added a reboot in the end and it worked.
Please log in to comment


Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja