1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Windows10でセキュアチャネルをps1で修復する

Last updated at Posted at 2021-08-08

AD環境で、「このワークステーションとプライマリドメインの信頼関係に失敗しました」
上のエラーが出た時に毎回ドメイン再参加するのか大変なので作ってみました

zipファイル

zipファイルをダウンロード

# ソースコード
Securechannel_repair.ps1
# $Checkへセキュアチャネル状況結果を代入(ture、false)
$check = Test-ComputerSecureChannel

# $Checkの結果出力
write-output $check

pause

# $Checkの結果で条件分岐
if("True" -eq $check){

# Ture処理
echo Domain-OK
pause
exit

}Else{

# False処理
# 「domainname\username」は利用している「ドメイン名\監視者アカウント名」に変更すること。
echo Domain-NG
Test-ComputerSecureChannel -Repair -Credential domainname\username

pause

# 1分後に再起動
shutdown /r /t 60

}


exit


# $Checkへセキュアチャネル状況結果を代入
# 出力結果を目視確認後、ture or falseで処理変更
# tureの場合:Domain-OKを返して終了
# Falseの場合:ドメイン名\監視者アカウント名でログインスクリプト起勁
#        パスワードを入力後、Enterで60秒後に再起動

使い方

①Securechannel_repair.ps1をメモ帳等で開き以下を修正する。

  修正前:Test-ComputerSecureChannel -Repair -Credential domainname\username
  修正後:Test-ComputerSecureChannel -Repair -Credential 利用中のドメイン名\ドメインの管理者アカウント名

 ■以下記入例(ドメイン名:test01.local 管理者アカウント名:administratorの場合)
  記入例:Test-ComputerSecureChannel -Repair -Credential test01.local\administrator

②エラーが出ているPCにて「.\administrator」または、
 NWを切断し他状態で「該当のドメインユーザ」でログインする。
  ※「.\administrator」はローカルのadministratorアカウントになります。

③Securechannel_repair.ps1を右クリックし「powershellで実行」を押下する。

④-①セキュアチャネルに異常がない場合は「Domain-OK」が表示され終了する、
 ※異常がない場合はここまで

④-②セキュアチャネルに異常がある場合は「Domain-NG」が表示され、ログインスクリプトが起動する。

⑤以下の画面が表示されるので、ドメインの管理者パスワードを入力する。
image.png

⑥修復完了後、「True」と表示され60秒後に再起動される。
 ※パスワードを打ち間違った場合は「False」と表示されるので、
  先に進まずps1を閉じて再度実行してください。

⑦再起動完了後に該当のドメインユーザでログインを行う。

以上

2021/8/21追記

たまたま気づいたんですが
「このワークステーションとプライマリドメインの信頼関係に失敗しました」
上は、AD登録されてるコンピュータに対して
別ユーザが同時にアクセスしてるとセキュアチャネル破損するみたいですね、、

根本原因はHDDの入れ替えとかでホスト名が競合して同じsidのpcが乱立してる可能性もあるので、発生頻度が多ければ確認してみてもいいかもしれません。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?