Posts

Showing posts with the label Windwos

Compress Old Files with PowerShell

 http://www.thesysadminhimself.com/2014/01/compress-old-files-with-powershell.html Compress Old Files with PowerShell The Story The following  PowerShell  script will compress files that are older than the specified amount of time. It is handy for archiving  IIS Logs, SQL Backups , etc. The script uses  7-zip  so you obviously have to have it installed (or the exe copied somewhere). It's using maximum compression which is resource intensive, if you don't want that just remove the " -mx9 -m0=lzma2 " parameters. The Script $path = "C:\inetpub\logs\LogFiles\" $mask = "*.log" $days = 7 $files = dir $path -Recurse -Include $mask | where {($_.LastWriteTime -lt (Get-Date).AddDays(-$days).AddHours(-$hours).AddMinutes(-$mins)) -and ($_.psIsContainer -eq $false)} ForEach ($file in $files) { & "C:\Program Files\7-Zip\7z.exe" u -mx9 -t7z -m0=lzma2 ($file.FullName + ".7z") $file.FullName if ($LASTEXITCODE -eq 0) { Re...

How to block multiple EXE files with in a folder with Windows Firewall

How to block multiple EXE files with in a folder with Windows Firewall 1)  Paste ALL the following into NotePad (including the last line that's hidden from view) and obviously edit to show the folder path where the applications that you want to block are. 2)  Save the text file and rename it to BlockInOut.bat 3)  Right-click BlockInOut.bat and run as administrator. 4)  Check your Inbound and Outbound firewall rules afterward for %% G in ( "C:\Program Files (x86)\Test Folder\*.exe" ) do ( netsh advfirewall firewall add rule name = "Blocked With Batchfile %%G" dir = in action = block program = "%%G" enable = yes profile = any netsh advfirewall firewall add rule name = "Blocked With Batchfile %%G" dir = out action = block program = "%%G" enable = yes profile = any )

How to detect enable and disable SMBv1, SMBv2, and SMBv3 in Windows command

How to detect enable and disable SMBv1, SMBv2, and SMBv3 in Windows https://docs.microsoft.com/en-us/windows-server/storage/file-server/troubleshoot/detect-enable-and-disable-smbv1-v2-v3 SMB v1 on SMB Client Detect cmd Copy sc.exe qc lanmanworkstation Disable: cmd Copy sc.exe config lanmanworkstation depend= bowser/mrxsmb20/nsi sc.exe config mrxsmb10 start = disabled Enable: cmd Copy sc.exe config lanmanworkstation depend= bowser/mrxsmb10/mrxsmb20/nsi sc.exe config mrxsmb10 start = auto SMB v2/v3 on SMB Client Detect: cmd Copy sc.exe qc lanmanworkstation Disable: cmd Copy sc.exe config lanmanworkstation depend= bowser/mrxsmb10/nsi sc.exe config mrxsmb20 start = disabled Enable: cmd Copy sc.exe config lanmanworkstation depend= bowser/mrxsmb10/mrxsmb20/nsi sc.exe config mrxsmb20 start = auto