From a7849b8b50eb33de3d5a604150896a034142f209 Mon Sep 17 00:00:00 2001 From: mrsh Date: Sat, 10 Jan 2026 01:45:04 +0100 Subject: [PATCH] File Management at 12:52 --- .../File Management with PowerShell.md | 67 +++++++++++++++++++ README.md | 6 ++ 2 files changed, 73 insertions(+) create mode 100644 6.File_Management/File Management with PowerShell.md diff --git a/6.File_Management/File Management with PowerShell.md b/6.File_Management/File Management with PowerShell.md new file mode 100644 index 0000000..ffd8677 --- /dev/null +++ b/6.File_Management/File Management with PowerShell.md @@ -0,0 +1,67 @@ +# File Management with PowerShell + +## Get-ChildItem + +Get the content of a curent directory +Alias = ls + +```powershell +Get-ChildItem + +Get-ChildItem C:\Windows +``` + +## Set-Location + +Change current directory +Alias = cd + +```powershell +Set-Location +``` + +## ACL + +Windows Access Control Lists (ACLs) are a core security +mechanism used to control access to files, +folders, and other system objects. +An ACL defines which users or groups are allowed +or denied specific permissions, such as read, +write, modify, or execute. +Each ACL is made up of Access Control Entries (ACEs) +that explicitly grant or restrict these permissions. +By using ACLs, Windows ensures that only authorized users can access or modify +resources, helping to protect system integrity and sensitive data. + +### Get-Acl + +for listing permision for a file + +```powershell +Get-ACL "C:\mrsh\test.ps1" + +$file = Get-ACL + +$file.Access + +Get-ACL "C:\mrsh\test.ps1" | Format-List +``` + +### Set-ACL + +```powershell +$acl = Get-Acl "C:\mrsh\test.ps1" +$permission = "Administrator", "FullControl", "Allow" +$accessRule = New=Object System.Security.AccessControl.FileSystemAccessRule $permission +$acl.SetAccessRule($accessRule) + +Set-ACL "C:\mrsh\test.ps1" $acl +``` + +## File size + +```powershell +$fileSize = Get-ChildItem -Path "C:\mrsh\test.ps1" -Recurse -Force | Measure-Object -Property Length -Sum + +$fileSize.Sum/1KB +``` diff --git a/README.md b/README.md index 5481129..10a3e84 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,9 @@ Networking with powershell System Magement with powershell [Link to the video](https://youtu.be/46K4SxQdPIo?si=LW2iATNHcspsvrzR) + +## 6.File Management + +File Magement with powershell + +[Link to the video](https://youtu.be/iGb-e_6uL98?si=gzj1BHK1E_cC6lYg)