remove computer from join with powershell
Remove-Computer
[-UnjoinDomainCredential] <PSCredential>
[-LocalCredential <PSCredential>]
[-Restart]
[-ComputerName <String[]>]
[-Force]
[-PassThru]
[-WorkgroupName <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Remove-Computer cmdlet removes the local computer and remote computers from their current domains.
When you remove a computer from a domain, Remove-Computer also disables the domain account of the computer. You must provide explicit credentials to unjoin the computer from its domain, even when they are the credentials of the current user. You must restart the computer to make the change effective. Also, when you remove a computer from a domain, you must move it to a workgroup. Use the WorkgroupName parameter to specify the workgroup.
To move a computer from a workgroup to a domain, from one workgroup to another, or from one domain to another, use the Add-Computer cmdlet.
To get the results of the command, use the Verbose and PassThru parameters. To suppress the user prompt, use the Force parameter.
Remove-Computer removes the local computer and remote computers from domains. It includes credential parameters that specify alternate credentials for connecting to remote computers, and unjoining from a domain, a Restart parameter for restarting the affected computers, and a WorkgroupName parameter for specifying the name of the workgroup to which computers are added.
Examples
Example 1: Remove the local computer from its domain
PS C:\> Remove-Computer -UnjoinDomaincredential Domain01\Admin01 -PassThru -Verbose -Restart
This command removes the local computer from the domain to which it is joined.
The command uses the UnjoinDomainCredential parameter to supply the credentials of a domain administrator. It uses the PassThru parameter and the Verbose common parameter to display information about the success or failure of the command and the Restart parameter restart the computer, which is required to complete the remove operation.
Because the command does not specify a workgroup name, the local computer is moved to the WORKGROUP workgroup after it is removed from its domain.
Example 2: Move several computers to a legacy workgroup
PS C:\> Remove-Computer -ComputerName (Get-Content OldServers.txt) -LocalCredential Domain01\Admin01 -UnJoinDomainCredential Domain01\Admin01 -WorkgroupName "Legacy" -Force -Restart
This command removes all of the computers that are listed in the OldServers.txt file from their domains and includes them in the Legacy workgroup.
The command uses the LocalCredential parameter to supply the credentials of a user who has permission to connect to remote computers and the UnjoinDomainCredential parameter to supply the credentials of a user who has permission to remove the computers from their domains. It uses the Force parameter to suppress the confirmation prompts for each computer and the Restart parameter to restart each of the computers after it is removed from its domain.
Example 3: Remove computers from a workgroup without confirmation
PS C:\> Remove-Computer -ComputerName "Server01", "localhost" -UnjoinDomainCredential Domain01\Admin01 -WorkgroupName "Local" -Restart -Force
This command removes the Server01 remote computer and the local computer from their domains and adds them to the Local workgroup. It uses the Force parameter to suppress the confirmation prompt for each computer and the Restart parameter to restart the computers to make the change effective.
Refer:
https://docs.microsoft.com/zh-cn/powershell/module/Microsoft.PowerShell.Management/Remove-Computer?view=powershell-5.1
https://ss64.com/ps/remove-computer.html
remove computer from join with powershell的更多相关文章
- 让Windows加入域的PowerShell
$domain = "midrange.lab" $password = "MyPassword!" | ConvertTo-SecureString -asP ...
- PowerShell读取Windows产品密钥
之前大多数人可能用过VBS读取Windows产品密钥的VBS脚本,VBS脚本通常都比较隐晦.难懂,今天忙里偷闲,随手写了一个用于读取Windows产品密钥的PowerShell脚本. 代码如下: == ...
- SharePoint自动化系列——Add/Remove “Hold” from items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 问题1: 1.如果SharePoint item被添加了hold,通过UI界面来对SharePoi ...
- C#调用PowerShell的经历
好久没有写程序了, 再次上手也处于功能强大的Windows PowerShell的缘故. 不多话, 先上段代码引入正题.... static Collection<PSObject> Ru ...
- Windows Management Instrumentation WMI Security Technology Learning
目录 . 引言 . WMI(Windows Management Instrumentation)简介 . 基于WMI的攻击向量 . WMI编程示例 0. 引言 在进行服务器主机的入侵检测.安全攻防的 ...
- python面试题库——1Python基础篇
第一部分 Python基础篇(80题) 为什么学习Python? 语言本身简洁,优美,功能超级强大,跨平台,从桌面应用,web开发,自动化测试运维,爬虫,人工智能,大数据处理都能做 Python和Ja ...
- 如何使用python移除/删除非空文件夹?
移除/删除非空文件夹/目录的最有效方法是什么? 1.标准库参考:shutil.rmtree. 根据设计,rmtree在包含只读文件的文件夹树上失败.如果要删除文件夹,不管它是否包含只读文件,请使用 i ...
- ASP.NET MVC关于Ajax以及Jquery的无限级联动
---恢复内容开始--- 第一次发表博文,发表博文的目的是巩固自己的技术,也能够共享给大家.写的不好的地方,希望大家多给给意见.老司机勿喷 数据结构() NewsTypeId 新闻ID, NewsTy ...
- python学习 第一天
正式学习python第一天,网上找到了python教程,带练习题的,又装了ubuntu. 这是学习笔记: list[]: 可变,append/1,insert/2,pop/index? tuple() ...
随机推荐
- vue---day01
1.let和const var 全局作用域和函数作用域 存在变量提升 其实是个bug 可以重复声明 let 块级作用域 不存在变量提升 不能重复声明 const 常量 和let一样还有另外两个 定义的 ...
- SQL Server附加数据库拒绝访问错误解决方法
今天在MsSQL里附加数据库时提示操作系统错误5(拒绝访问),这里我没给出了两个解决方案供大家解决问题. 方案一:切换登录方式 出现这种情况是由于用“混合验证方式”(SQL Server身份验证)登录 ...
- 常用操作提高效率 之 for 与in
问题如何而来: 对于刚参加工作的我 批量删除数据通常采用的是前端传递到后台一个对象的id字符串 通过逗号分隔的多个id 或者收的直接是一个id数组 两个原理一样第一个后台要在次使用split(& ...
- 自定义T4模板去掉实体对象中的下划线
在EF Power Tool 默认使用的T4模板中,如果数据库表有下划线,那么生成的实体也有下划线,但是我们实际使用的过程中,是不希望有下划线的,要解决这个问题,可以自定义这个T4模板 ...
- NMON记录服务器各项性能数据
1.将下载下来的nmon文件通过ftp传入服务器下,将nmon权限全开chmod +x nmon 2.查看nmon可以看到如下内容 查看各项指标 输入C,CPU数据 M,内存 N,网络 D,磁盘 T, ...
- 对SE的认识
对SE的认识 简述 “架构师”,也就是SE,总是给外人一种比较牛逼的感觉,其实踏实做开发的真的很少关注这个title. 抛开这个名词,这个角色的存在的确有一定的意义,因为项目中需要一个能“带领大家前进 ...
- Nginx 配置 HTTPS自签名证书
工具: OpenSSL ssl的开源实现,几乎实现了市面上所有的加密 libcrypto: 通用加密库, 任何软件要实现加密功能 链接调用这个库 libssl: TLS/SSL 加密库 openssl ...
- Daily Scrum02 12.02
今天是黑色星期一,虽然大家最近被各种大作业压得身心疲惫,但是团队的凝聚力战胜了一切不快. 看看同志们今天的战绩,是不是又有一种充实感油然而生呢??? By Ryan Mao who? Today? T ...
- Mininet实验 动态改变转发规则
介绍 拓扑如下: 在该环境下,假设H1 ping H4,初始的路由规则是S1-S2-S5,一秒后,路由转发规则变为S1-S3-S5,再过一秒,规则变为S1-S4-S5,然后再回到最初的转发规则S1-S ...
- cygwin上编译RPC框架thrift
cygwin的配置就不多说了,缺什么就通过安装器安装好了. 在thrift的官网下载 thrift-0.11.0源码,通过cmake编译,生成Makefile之后,make出现编译错误 /cygdri ...