Posts

Showing posts from September, 2019

Power shell - Deleting files and folders older than X days

#delete files older than 30 days Get-ChildItem $Folder -Recurse -Force -ea 0 | ? {!$_.PsIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays(-30)} | ForEach-Object {    $_ | del -Force    $_.FullName | Out-File C:\log\deletedbackups.txt -Append } #delete empty folders and subfolders if any exist Get-ChildItem $Folder -Recurse -Force -ea 0 | ? {$_.PsIsContainer -eq $True} | ? {$_.getfiles().count -eq 0} | ForEach-Object {     $_ | del -Force     $_.FullName | Out-File C:\log\deletedbackups.txt -Append }

Powershell to export COMPUTER list from OU

Powershell to export COMPUTER list from OU: Get-ADcomputer -Filter * -SearchBase 'OU=Windows 7 Desktops,OU=Workplace,DC=PUGAZH,DC=COM' -Properties Name,CanonicalName,DistinguishedName,Description,Enabled,OperatingSystem | select-object Name,CanonicalName,DistinguishedName,Description,Enabled,OperatingSystem | Sort-Object -Property Name | Export-Csv AllComputers_2019.csv

Newly Created Scheduled Tasks Event ID 4698

Hi If we created the new Scheduled Tasks, Event ID 4698 will appear in the  Security log.