计算机服务器退域,powershell 如何实现电脑加域退域?

1442611a019ccaafbbd7044433a1b1fd?s=16&d=monsterid&r=gscp420

replied 7年 ago

function JoinDomain{$DomainName = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties().DomainNameif ($DomainName.Length -gt 0){$textbox1.AppendText(“此服务器已加入域,请先退域后再加入新域!`n”)break}elseif ($DomainName.Length -eq 0){$domain = Read-Host “请输入你所要加入的AD域名:”Add-Computer -DomainName $domain}}function LevelDomain{$DomainName = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties().DomainNameif ($DomainName -is [string]){$textbox1.AppendText(“此服务器即将退出域,请确认!`n”)$inputY2N = Read-Host “请输入Yes or No!”if ($inputY2N -eq ‘yes’){$DomainUserAdmin = Read-Host “请输入域管理员帐号”remove-computer -credential $DomainUserAdmin -passthru -verbose$textbox1.AppendText(“此服务器已退出域”)Restart-Computer -ComputerName .}elseif ($inputY2N -eq ‘no’){return}}}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值