Git Product home page Git Product logo

cleanup_script's Introduction

Cleanup Script

Ein Powershellscript für die ICT-BZ welches Dateien welche Älter als 30 Tage sind, löscht.

alt text

Anwendung

Das Script soll Dateien im Scanner Ordner löschen welche älter als 30 Tage alt sind.

Pfad: G:\scanner

Script

Get-ChildItem –Path "C:\path\to\folder"-Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-30))} | Remove-Item 

Pfad anpassen

-Path "C:\your\path"

In wievielen Tagen

Vom heutigen Datum -30 Tage.

(Get-Date).AddDays(-30)

Was Passiert

Mit | Remove-Item werden Dateien gelöscht. Zusätzlich konnen nöch Filter dazu angewendet werden.

| Remove-Item
    options: 
    Remove-Item
        [-Path] <String[]>
        [-Filter <String>]
        [-Include <String[]>]
        [-Exclude <String[]>]
        [-Recurse]
        [-Force]
        [-Credential <PSCredential>]
        [-WhatIf]
        [-Confirm]
        [-Stream <String[]>]
        [<CommonParameters>]

Example

| Remove-Item -include .PDF

Nun werden nur .PDF Dateien entfernt.

Child-Item

Zeigt alle dateien im angegebenen Verzeichnis an.

| Get-ChildItem -Path C:\Users\Julian\Donload -Recurse
   options: 
   Get-ChildItem
       [-Path] Sucht im nachfolgenden Pfad
       [-Recurse] Durchsucht auch unterordner. 

Backup davon erstellen

| Copy-Item 'G:\scanner\*' 'C:\backup\pfad\Backup'

Mit diesem Befehl wird ein backup des Ordners in ein Wunschverzeichnis erstellt.

cleanup_script's People

Contributors

julianbruegger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.