![見出し画像](https://assets.st-note.com/production/uploads/images/55943864/rectangle_large_type_2_f753294f9a232b0ec65d7a2c1f677306.png?width=800)
WIndowsのサービスの停止をBat、Powershell、Intune、GPOでそれぞれやってみる。
下記の記事にある「PrintNightmare」の対処として2021/07/03時点での推奨対応であるWindows Print Spoolerサービスを無効にすることを題材としてやってみる。
-----------------------------------------------------------------
追記1:2021/07/03
以下の方が影響が少ない。パッチの更新情報などは以下に記載
2022/05/18
脆弱性の対応はされたので、タイトルを「Windows 10の印刷スプーラに任意コード実行の脆弱性をIntuneとGPOで暫定対応してみる」から変更。
-----------------------------------------------------------------
今回の方法を適用すると印刷することもできなくなるので注意
あくまでも配布する方法の手順として残す。
Power shellスクリプトの作成
下記の内容の.ps1ファイルを作成して、管理者として実行する。
# Spoolerサービスの停止
Stop-Service -Name Spooler -Force
# Spoolerサービスの無効化け
Set-Service -Name Spooler -StartupType Disabled
batファイルの作成
下記の内容の.batファイルを作成して、管理者として実行する。
rem Spoolerサービスの停止
net stop Spooler
rem Spoolerサービスの無効化
sc config Spooler sart=disable
exit
Intuneでの止め方
適用すると印刷するもできなくなるので注意
「デバイス」-「スクリプト」-「追加」-「Windows 10」とクリック
![画像1](https://assets.st-note.com/production/uploads/images/55942247/picture_pc_debb5eff9d28d8d7ae619ba7fbf13f57.png?width=800)
名前を適当に入れて「次へ」
![画像2](https://assets.st-note.com/production/uploads/images/55942274/picture_pc_5aae678a845d2a9950fe1aa51eab31d6.png?width=800)
PowerShellスクリプトの作成で作ったファイルをアップロードする
![画像3](https://assets.st-note.com/production/uploads/images/55943069/picture_pc_9b84f71559c75e6ca47650a07412578f.png?width=800)
配布するグループを選択する
![画像4](https://assets.st-note.com/production/uploads/images/55943116/picture_pc_14fc2d50d2842738f793572a7b88a5a6.png?width=800)
問題ないことを確認する。
![画像5](https://assets.st-note.com/production/uploads/images/55943119/picture_pc_d1b7f47967d3ed75656cd716a80e76a0.png?width=800)
出来上がり
![画像6](https://assets.st-note.com/production/uploads/images/55943133/picture_pc_a59bb09ed42f88d995ce912bc2dc3738.png?width=800)
GPOでの止め方
即効性はないので再起動が必要
適用すると印刷するもできなくなるので注意
「コンピュータの構成」-「ポリシー」-「Windowsの設定」-「セキュリティの設定」-「システム サービス」-「Print Spooler」を開く
![画像8](https://assets.st-note.com/production/uploads/images/55943778/picture_pc_4f28d705be8a930a7a38b80950948607.png?width=800)
「このポリシーの設定を定義する」をチェックして、「無効」
![画像8](https://assets.st-note.com/production/uploads/images/55943756/picture_pc_6be8ec3def4a8d0068b10c5b92fab117.png?width=800)
GPOでの止め方2
「コンピュータの構成」-「ポリシー」-「管理用テンプレート」-「プリンター」-「印刷スプーラーにクライアント接続の受け入れを許可する」をクリック
![画像10](https://assets.st-note.com/production/uploads/images/55963322/picture_pc_e0f58cae35e84c26c752fa1db6fade04.png?width=800)
無効にする
![画像11](https://assets.st-note.com/production/uploads/images/55963467/picture_pc_619450c63aa55d69b1918bb7aaee609c.png?width=800)
元に戻す(Powershell)
# Spoolerサービスを自動起動にする
Set-Service -Name Spooler -StartupType Automatic
# Spoolerサービスを起動する
Start-Service -Name Spooler
Intuneではこれを配布するようにすればいい。
元に戻す(bat)
rem Splloerサービスの自動起動化
sc config Spooler sart=auto
rem Spoolerサービスの開始
net start Spooler
exit
Intuneでの元に戻し方
元に戻す(Powershell)で作成したps1ファイルを配布するスクリプトを作成する。
GPOで元に戻す
「Print Splloer」の「自動」を選択する。
![画像9](https://assets.st-note.com/production/uploads/images/55943814/picture_pc_04ec4c6cb71d764040d107a84860786f.png?width=800)
以上
この記事が気に入ったらサポートをしてみませんか?