2
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 5 years have passed since last update.

Windowsのログアウト(サインアウト)時にごみ箱を空にする

Last updated at Posted at 2019-07-01

#容量にシビアなサービス
ディスク容量を増やす前、削れるところは削ること。クラウドサービスは増やしたら簡単に減らせない。
ログイン・アウト時、実行する仕組みはいろいろカスタム処理で愛用している。

#グループポリシー
ユーザの構成→ポリシー→Windwosの設定→スクリプトーログイン->プロパティ(PowerShellスクリプト)
\{ADサーバ}\sysvol\hoge.local\scripts\RemoveItem-Recyclebin.ps1

#スクリプト

RemoveItem-Recyclebin.ps1
function RemoveItem-Recyclebin {
    $Shell = New-Object -ComObject Shell.Application;
    $RecycleBin = $Shell.Namespace(0xA);
    $RecycleBin.Items() | ForEach-Object { Remove-Item $_.Path -Recurse -Confirm:$false }
}
RemoveItem-Recyclebin

#参考
PowerShell – ごみ箱を空にする方法

2
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
2
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?