/build/static/layout/Breadcrumb_cap_w.png

Powershell Removing PC from Domain using KACE

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


0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
Posted by: SMal.tmcc 8 years ago
Red Belt
2

Top Answer

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"

Comments:
  • 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. - yzhang 8 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ